Results 1 to 8 of 8

Thread: Adding a script to startup

  1. #1
    Join Date
    Feb 2009
    Posts
    24

    Default Adding a script to startup

    I'm trying to add a script with root privileges to my startup that disables the wifi led:

    Code:
    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.

  2. #2
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    1,578

    Default

    Maybe the stuff isn't yet completely initialized when your script is run?

  3. #3
    Join Date
    Aug 2007
    Posts
    6,613

    Default

    Wouldn't it be simpler to change the driver an add an option for that?

  4. #4
    Join Date
    Jul 2008
    Posts
    314

    Default

    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:
    Code:
    #!/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

  5. #5
    Join Date
    Jul 2008
    Posts
    314

    Default

    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.

  6. #6
    Join Date
    Aug 2007
    Posts
    6,613

    Default

    You can execute scripts on load of a module too.

  7. #7
    Join Date
    Feb 2009
    Posts
    24

    Default

    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.

  8. #8
    Join Date
    Jan 2009
    Location
    UK
    Posts
    331

    Default

    sudo won't even work there, since all it does is run echo as root and then redirect the output as the current user.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •