Location: /mnt/HD_a2/ffp/start/crontab_update
Make it executable: chmod +x /mnt/HD_a2/ffp/start/crontab_update
Contents of crontab_update:
#!/ffp/bin/sh
# PROVIDE: crontab_update
# REQUIRE: LOGIN
#
# Email settings are taken from webadmin!
#
. /ffp/etc/ffp.subr
name="crontab_update"
start_cmd="crontab_update_start"
## CHANGES SECTION
# You must CHANGE settings below
SMTP=smtp.mail.com
USER=user@mail.com
SOURCE=user@mail.com
DEST=dest@mail.com
PASS=secret
## END OF CHANGES
crontab_update_start() {
CRONTXT=/tmp/crontab.txt
# start with existing crontab
/bin/crontab -l > $CRONTXT
# add the Rsync job to execute at 2:05 am - also create a logfile
/bin/echo "0 20 * * 1-4 /mnt/HD_a2/ffp/bin/do_sth.sh &" >> $CRONTXT
/bin/echo "15 16 * * 5 /mnt/HD_a2/ffp/bin/do_sth.sh &" >> $CRONTXT
# We are now booting - send test email and enable mail
if [ ! -e /.msmtprc -o ! -e /.muttrc ] ; then
email -m 63 -h $SMTP -p 25 -a 1 -u $USER -w $PASS -s $SOURCE -d $DEST -t
test -e /home/root/.msmtprc && ln -s /.msmtprc /home/root/
test -e /home/root/.muttrc && ln -s /.muttrc /home/root/
fi
# install the new crontab
/bin/crontab $CRONTXT
# clean up tmp crontab
/bin/rm $CRONTXT
}
run_rc_command "$1"
Location: /mnt/HD_a2/ffp/bin/do_sth.sh
Make it executable: chmod +x /mnt/HD_a2/ffp/bin/do_sth.sh
Contents of: /mnt/HD_a2/ffp/bin/do_sth.sh
#!/bin/sh
#
# Simple script to do something
#
PATH=/mnt/HD_a2/ffp/bin/:$PATH
SRC_PATH='/mnt/HD_a2'
SPACE_REMAINING=`df -h`
RESULT=$?
echo -e "Process ended with result ===> $RESULT\n"\
"Space remaining:\n\n"\
"$SPACE_REMAINING"\
"\n\n"\
"Your DNS-323 (dlink-storage)"\
| mutt -s "Process status ("`date -I`")" dest@mail.com
http://blog.0x1fff.com/2009/11/howto-send-email-from-bash-on-dlink-dns.html (thank you, 0x1fff)