Question how big can nvram rc_startup be and a tip

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
mQQm
DD-WRT Novice


Joined: 09 Jun 2006
Posts: 2

PostPosted: Fri Jun 09, 2006 22:59    Post subject: Question how big can nvram rc_startup be and a tip Reply with quote
Hi hello everyone,

As title, is the rc_startup variable a fixed size or limited only by free memory?

And here's the tip if anyone is interested, probably a dupe. I'm running the std version of the firmware so I don't seem to get any jffs storage for running scripts. I got the ssh_users.sh script running from boot by adding the following to rc_startup (hence I'd like to know how big it can be).

Code:

echo '#!/bin/sh' > /tmp/ssh.sh
echo 'led=2' >> /tmp/ssh.sh
echo 'interval=5' >> /tmp/ssh.sh
echo 'on=0' >> /tmp/ssh.sh
echo '/sbin/gpio enable 2' >> /tmp/ssh.sh
echo 'while sleep 5' >> /tmp/ssh.sh
echo 'do' >> /tmp/ssh.sh
echo -n 'users=$(/bin/netstat -n | /usr/bin/awk ' >> /tmp/ssh.sh
echo -n "'" >> /tmp/ssh.sh
echo -n '$4~/:22$/ {++x}; END {print x+0}' >> /tmp/ssh.sh
echo -n "'" >> /tmp/ssh.sh
echo ')' >> /tmp/ssh.sh
echo '   if [ "$users" -gt 0 ]; then' >> /tmp/ssh.sh
echo '      if [ $on -eq 0 ]; then' >> /tmp/ssh.sh
echo '          /sbin/gpio disable $led' >> /tmp/ssh.sh
echo '          on=1' >> /tmp/ssh.sh
echo '      fi' >> /tmp/ssh.sh
echo '   else' >> /tmp/ssh.sh
echo '      if [ $on -eq 1 ]; then' >> /tmp/ssh.sh
echo '          /sbin/gpio enable $led' >> /tmp/ssh.sh
echo '          on=0' >> /tmp/ssh.sh
echo '      fi' >> /tmp/ssh.sh
echo '   fi' >> /tmp/ssh.sh
echo 'done' >> /tmp/ssh.sh
chmod 700 /etc/ssh.sh
sh /etc/ssh.sh &


Dave.
Sponsor
maxzerker
DD-WRT Novice


Joined: 09 Jun 2006
Posts: 25

PostPosted: Sat Jun 10, 2006 2:03    Post subject: Re: Question how big can nvram rc_startup be and a tip Reply with quote
I don't know but i use this code for start up
and it works fine.

Code:
if [ $(ps | grep grep -v | grep cpuload.sh -c) -eq 0 ];then
# --- CPULOAD.SH --- BEGIN
echo "#!/bin/sh

amber_on=\"gpio disable 3\"
amber_off=\"gpio enable 3\"
white_on=\"gpio disable 2\"
white_off=\"gpio enable 2\"

load4=150
load3=100
load2=50
load1=0

delay4=50000
delay3=100000
delay2=150000
delay1=200000

while sleep 1
do
load=\$(cat /proc/loadavg | cut -d \" \" -f1 | tr -d \".\")

if [ \$load -gt \$load4 ];then
\$white_on
\$amber_on
usleep \$delay4
\$amber_off
usleep \$delay4
\$amber_on
usleep \$delay4
\$amber_off
usleep \$delay4
\$amber_on
usleep \$delay4
\$amber_off
\$white_off

elif [ \$load -gt \$load3 ];then
\$white_off

\$amber_on
usleep \$delay3
\$amber_off
usleep \$delay3
\$amber_on
usleep \$delay3
\$amber_off
usleep \$delay3
\$amber_on
usleep \$delay3
\$amber_off

elif [ \$load -gt \$load2 ];then
\$amber_on
\$white_on
usleep \$delay2
\$amber_off
\$white_off
usleep \$delay2
\$amber_on
\$white_on
usleep \$delay2
\$amber_off
\$white_off
usleep \$delay2
\$amber_on
\$white_on
usleep \$delay2
\$amber_off
\$white_off

elif [ \$load -gt \$load1 ];then
\$amber_off

\$white_on
usleep \$delay1
\$white_off
usleep \$delay1
\$white_on
usleep \$delay1
\$white_off
usleep \$delay1
\$white_on
usleep \$delay1
\$white_off

fi
unset \$load
done" > /tmp/cpuload.sh
# --- CPULOAD --- END
chmod +x /tmp/cpuload.sh
/tmp/cpuload.sh &
fi

if [ $(ps | grep grep -v | grep ddnsfix.sh -c) -eq 0 ];then
# --- DDNSFIX.SH --- BEGIN
echo "#!/bin/sh

delay=5
retry=3

while sleep \$delay
do
ddns_opt=`nvram get ddns_enable`
if [ \$ddns_opt -eq 1 ];then
ddns_ip=\$(cat /tmp/ddns.cache | cut -d \",\" -f2)
wan_ip=`nvram get wan_ipaddr`
if [ \${wan_ip:-not_exist} != \${ddns_ip:-not_exist} ];then
ez-ipupdate -r \$retry -b /tmp/ddns.cache -a \$wan_ip -c /tmp/ddns.conf
delay=30
else
delay=300
fi
else
exit 0
fi
done" > /tmp/ddnsfix.sh
# --- DDNSFIX.SH --- END
chmod +x /tmp/ddnsfix.sh
/tmp/ddnsfix.sh &
fi
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware 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