Startup script not running?

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
crrazychicken
DD-WRT Novice


Joined: 17 Jul 2010
Posts: 2

PostPosted: Sat Jul 17, 2010 15:20    Post subject: Startup script not running? Reply with quote
I have a script that works to WOL my PC when I try to remote desktop in. I can kick it off from the shell using the following command

/bin/sh /tmp/custom.sh &

and it'll run until the router reboots which is great but I cannot get the script to kick off on startup for me

I currently have this as the startup script

/bin/sh -c '/bin/sh /tmp/custom.sh' &

I've tried a bunch of different combinations but I'm not that knowledgable of linux

Here are other commands I've tried in the startup script

/bin/sh /tmp/custom.sh
/bin/sh /tmp/custom.sh &
sh /tmp/custom.sh
sh /tmp/custom.sh &

Here is the script main script that works fine if I kick it off from he shell then log out in case it has something to do with it (it's modifed using the Web WOL script)



#!/bin/sh

INTERVAL=5
NUMP=3
OLD=""
WOL=/usr/sbin/wol
TARGET=192.168.2.99
MAC=48:5B:39:C9:E9:76
LOGFILE="/tmp/www/wol.log"

nvram set log_rejected=0
nvram set log_enable=1
nvram set log_level=2
nvram set log_dropped=0
nvram set log_accepted=1
nvram commit


cat /dev/null >/tmp/var/log/messages

while sleep $INTERVAL;do
NEW=`awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT=3389/ {print $3}' /var/log/messages | tail -1`
SRC=`awk -F'[=| ]' '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT=3389/ {print $13}' /var/log/messages | tail -1`
LINE=`awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT=3389/' /var/log/messages`
if [ "$NEW" != "" -a "$NEW" != "$OLD" ]; then
echo "$SRC $LINE" >> $LOGFILE
RET=`ping -c $NUMP $TARGET 2> /dev/null | awk '/packets received/ {print $4}'`
if [ "$RET" -ne "$NUMP" ]; then
echo "$SRC causes WOL at" `date` >> $LOGFILE
$WOL -i 192.168.2.255 -p 9 $MAC >> $LOGFILE
sleep 5
fi
OLD=$NEW
fi
cat /dev/null >/tmp/var/log/messages
done
Sponsor
crrazychicken
DD-WRT Novice


Joined: 17 Jul 2010
Posts: 2

PostPosted: Sun Jul 18, 2010 18:09    Post subject: work around Reply with quote
for whatever reason it's could not work, multiple line firewall scripts didn't seem to work too well either but I enabled cron and put the following 2 lines in

02 * * * * root /usr/bin/killall sh
03 * * * * root /bin/sh /tmp/custom.sh &

to kill and restart the process on the 2nd and 3rd minute of every hour and seems to be working well

now me and my comptuer can sleep
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum