PDA

View Full Version : Customizing Startup Script



gwl
29-12-2004, 21:25
Hello,
After reading a few posts on the forum, I tried a (simple) startup customization script:
(this is the 1st customization on the WL500g I ever did...)



mkdir /usr/local/sbin
echo '#!/bin/sh' > /usr/local/sbin/post-firewall
echo 'alias d="ls -la"' >> /usr/local/sbin/post-firewall
chmod +x /usr/local/sbin/post-firewall
flashfs save
flashfs commit
flashfs enable
reboot


It does get saved, but the "alias" isn't avaliable...
even if I run
[admin@(none) /tmp]$ /usr/local/sbin/post-firewall
[admin@(none) /tmp]$ d
I always get: "-sh: d: not found"

can anyone give some help?
thanks.

Phantome
29-12-2004, 23:28
You missed a >
in
echo '#!/bin/sh' > /usr/local/sbin/post-firewall
should be
echo '#!/bin/sh' >> /usr/local/sbin/post-firewall

you can check this by typing
cat /usr/local/sbin/post-firewall
if "#!/bin/sh" is missing then you have to edit the file
and add it.

gwl
29-12-2004, 23:44
thanks for your reply... but...
In the first echo I was creating the file, so I only needed one ">"...
on the second one.. I was appending the text.. so I need ">>"...
:rolleyes:


[Update]:
"...The variables, functions and aliases created in this subshell are only known to the particular bash session of that subshell. When that shell exits and the parent regains control, everything is cleaned up and all changes to the state of the shell made by the script, are forgotten..."
in: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_01.html

I need to use the "source" command... but it isn't avaliable...
The solution I found was:

Create "/root/.profile" with:
# customized profile
alias d="ls -la"

then saved&commited.
now I always get the alias. :)


Does anyone know any other solution?

thanks.