User:Tc23emp
From DD-WRT Wiki
(Difference between revisions)
Revision as of 17:13, 30 August 2010 (edit) Tc23emp (Talk | contribs) (Use cron_jobs over startup crontab) ← Previous diff |
Revision as of 17:16, 30 August 2010 (edit) (undo) Tc23emp (Talk | contribs) m (br) Next diff → |
||
Line 1: | Line 1: | ||
- | These scripts can be added via the web interface. | + | These scripts can be added via the web interface.<br> |
Tested on DD-WRT v24-sp2 (08/12/10) std-nokaid-small (SVN revision 14929) | Tested on DD-WRT v24-sp2 (08/12/10) std-nokaid-small (SVN revision 14929) | ||
- | Administration -> Management -> | + | Administration -> Management -><br> |
- | Enable Cron | + | Enable Cron = true<br> |
Additional Cron Jobs: | Additional Cron Jobs: | ||
<pre> | <pre> |
Revision as of 17:16, 30 August 2010
These scripts can be added via the web interface.
Tested on DD-WRT v24-sp2 (08/12/10) std-nokaid-small (SVN revision 14929)
Administration -> Management ->
Enable Cron = true
Additional Cron Jobs:
5 0 * * * root /tmp/custom.sh bwmail */5 * * * * root /tmp/custom.sh wlclient
Administration -> Commands -> Custom Script
#!/bin/sh fnc_mail() { subj="$1" msg="$2" if [ -z "$3" -o "$(dirname $3)" = "." ]; then logfile="/tmp/lastmail.log"; else logfile="$3"; fi sendmail -S"smtp.comcast.net" -f"sender@comcast.net" -F"DD-WRT" -d"comcast.net" -s"$subj" -m"$msg" me@gmail.com > $logfile 2>&1 } if [ "$1" = "bwmail" ]; then #Parse the previous day and monthly totals and send an email aff="aff" #keyword workaround msg=$(nvram get $(date +tr$aff-%m-%Y) | awk '{print $'$(expr $(date +%d) - 1)', $NF}'\ | sed -e 's;\([^:]*\):\([^ ]*\) \[\([^:]*\):\([^]]*\)];Totals for Yesterday\nIncoming: \1 MB\nOutgoing: \2 MB\n\nTotals for Month to Date\nIncoming: \3 MB\nOutgoing: \4 MB\n;') fnc_mail "Bandwidth Report" "$msg" "/tmp/bwmail.log" fi if [ "$1" = "wlclient" ]; then #Send a e-mail whenever a new wireless client connects, remember them until the next router reboot #Uncomment the following line and edit the list MAC addresses you don't want to be notified about (seperated by spaces) #macignore="0A:1B:2C:3D:4E:5F" for mac in $macignore; do grep -q $mac /tmp/wlclient.lst if [ $? -gt 0 ]; then echo $mac >> /tmp/wlclient.lst fi done maclist=$(wl -i $(nvram get wl0_ifname) assoclist | cut -d" " -f2) for mac in $maclist; do grep -q $mac /tmp/wlclient.lst if [ $? -gt 0 ]; then echo $mac >> /tmp/wlclient.lst inf=$(arp | grep $mac) if [ $? -gt 0 ]; then msg="$msg""Unknown at ${mac}\n" else msg="$msg""${inf}\n" fi fi done #Uncomment the following line if you want to remove disconnected clients from the previously connected list #echo "$maclist" | tr ' ' '\n' > /tmp/wlclient.lst if [ -n "$msg" ]; then msg=$(echo -e "$msg") fnc_mail "New Wireless Client(s)" "$msg" fi fi