View Full Version : Adding a script to startup
elsie
10-07-2009, 12:44 PM
I'm trying to add a script with root privileges to my startup that disables the wifi led:
sudo echo none > /sys/class/leds/iwl-phy0::RX/trigger
sudo echo none > /sys/class/leds/iwl-phy0::TX/trigger
sudo echo none > /sys/class/leds/iwl-phy0::radio/trigger
sudo echo none > /sys/class/leds/iwl-phy0::assoc/trigger
Running the script from terminal works, led is off.
I've tried adding the script to init.d & running update-rc.d, tried using visudo & adding the script to my startup applications. Nothing is working.
Anyone have any ideas?
I'm using ubuntu 9.10.
nanonyme
10-07-2009, 01:38 PM
Maybe the stuff isn't yet completely initialized when your script is run?
Wouldn't it be simpler to change the driver an add an option for that?
grantek
10-07-2009, 07:52 PM
If it's run from init.d it'll be run as root, so you don't need the "sudo"s. Also, it needs to be an executable script, what you've posted there is just a bunch of commands that need to be "sourced" from a shell that's already running. To make it a script that can be run from init.d. add:
#!/bin/sh
To the VERY TOP of the file (first line), then make sure the file's permissions allow execution (chmod a+x ledscript)
Then make sure it's in /etc/init.d, and that it makes it into /etc/rc2.d once you run update-rc.d
grantek
10-07-2009, 07:55 PM
Actually, an easier way would be to just add the commands to /etc/rc.local (above the last line which is "exit 0") - rc.local is basically designed for this sort of custom stuff.
You can execute scripts on load of a module too.
elsie
10-07-2009, 09:28 PM
I added #!/bin/sh, removed the sudo's, tried adding to rc.local, tried adding to init.d to be run last...
rc.local kinda worked...for 3 seconds & then the leds came back, so something is triggering the leds even after the script is run.
I tried rmmod led_class just for kicks & sure enough the leds came back on when iwl3945 module was reloaded. Maybe something in iwl3945 is triggering the leds?
All I can think is to have the script load after everything else is done, but adding it to startup applications & editing sudoers & even adding a sleep 10 doesn't work. The script just isn't being executed.
Ant P.
10-07-2009, 10:16 PM
sudo won't even work there, since all it does is run echo as root and then redirect the output as the current user.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.