PDA

Bekijk de volledige versie : Shell scripts and post-boot



samoht
03-06-2005, 21:06
Hi you,

I am using Olegs Firmware 1.9.2.7-5a on USB stick and it works fine. But I do not understand, why not all lines in post-boot are executed. Could someone give me a hint please?

Here is my post-boot file. The marked lines are not executed, but the commands can be executed via command line.



#!/bin/sh
dropbear
/usr/sbin/smbd -D
touch /usr/local/sbin/1
/usr/sbin/nmbd -D
touch /usr/local/sbin/2
>>>/sbin/wshaper start "$" 1400 270
touch /usr/local/sbin/3
/bin/crond
touch /usr/local/sbin/4
>>>/tmp/harddisk/accounting/add_iptables.sh
touch /usr/local/sbin/5
>>>busybox_httpd -p 81 -u admin -h /tmp/harddisk/accounting/www81
touch /usr/local/sbin/6

All my shell scripts can only be executed on the command line if I type sh <scriptname>. If I type <scripname> only an error occurs.

Example:

[admin@WL500 root]$ ls -l
-rwxr-xr-x 1 admin root 52 Jun 3 20:17 fix.sh
[admin@WL500 root]$ cat fix.sh
#!/bin/sh
flashfs save
flashfs commit
flashfs enable
[admin@WL500 root]$ fix.sh
-sh: fix.sh: not found
[admin@WL500 root]$ sh fix.sh
tar: Removing leading '/' from member names
var/spool/cron/crontabs/root
etc/smb.conf
...OK


What could that be?

Thx
Thomas

barsju
03-06-2005, 21:18
The wshaper should be $1 no or eth1 if that is you WAN? And should be in post-firewall? And the others are most likely cause harddisk is not mounted yet when post-boot is executed. You should put those lines in post-mount.

Check http://oleg.wl500g.info for details about booting and wondershaper.

B.

Styno
03-06-2005, 21:32
/sbin/wshaper start "$1" 1400 270This line should be put in the post-firewall script because "$1" is a parameter of that script and therefore it doesn't work in the post-boot script.

Edit:

cat fix.sh
#!/bin/sh
flashfs save
flashfs commit
flashfs enableYou better do not put these commands in a script, because you need to check if the resulting file from 'flashfs save' isn't bigger then 64kbytes. If you make an error of some sort and you 'flashfs commit' a file that is larger then 64k your router might suffer unreversable damage.

samoht
03-06-2005, 22:41
Thanks for your quick reply. Booting works now. But why does my fix.sh not work? Do I need it to copy to special folder?

Thomas :rolleyes:

barsju
03-06-2005, 23:23
Don't know why, probably some *nix wiz can tell you, but to run shell script you need to either sh script or ./script. Or you can stick it in /usr/local/sbin/ and run it from anywhere..

B.

Jean-Fabrice
03-06-2005, 23:58
For security reason, ./ directory (i.e the actual directory) is never part of the PATH for root user.
That's why you have to launch your script (or whatever executables) using ./script.sh or place it in a directory which belong to the PATH var (see 'echo $PATH')

jf