Find the answer to your Linux question:
Results 1 to 4 of 4
I've made a simple script that creates a network tunnel when I run it (I find it silly that the kernel will forget any tunnel settings after a reboot, don't ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2009
    Posts
    59

    How does Linux load init.d scripts?


    I've made a simple script that creates a network tunnel when I run it (I find it silly that the kernel will forget any tunnel settings after a reboot, don't know why it is like that).

    If I simply copy the script to the init.d directory, will it auto run after each boot and simply work (as it always works when using `sh tunnelscript`) or do I need to change it?

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,235
    Quote Originally Posted by SkyHiRider View Post
    I've made a simple script that creates a network tunnel when I run it (I find it silly that the kernel will forget any tunnel settings after a reboot, don't know why it is like that).

    If I simply copy the script to the init.d directory, will it auto run after each boot and simply work (as it always works when using `sh tunnelscript`) or do I need to change it?
    Most distros use the System V startup in which each run level is represented by a directory with a name like rc2.d, rc3.d, etc. These contain links (shortcuts) to the scripts in init.d. So if you wanted to put your script in init.d, you would have to put a link to it into the directory corresponding to your default run level.

    But it's much simpler to edit this kind of thing into the rc.local script, which runs at the end of the startup process. You'll probably find this script either in /etc or in /etc/rc.d.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

  3. #3
    Just Joined!
    Join Date
    Oct 2009
    Posts
    59
    Thanks.

    And what happens if I remove a script from init.d - the links will obviously fail, but will it be a problem during boot or will it just skip on errors.

    I've disabled postfix and dovecot by moving their init scripts to another directory, but I don't know what will happen after a reboot.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,235
    Quote Originally Posted by SkyHiRider View Post
    Thanks.

    And what happens if I remove a script from init.d - the links will obviously fail, but will it be a problem during boot or will it just skip on errors.

    I've disabled postfix and dovecot by moving their init scripts to another directory, but I don't know what will happen after a reboot.
    Don't remove the script. As you rightly point out, that causes trouble all round. As long as the relevant program remains installed on your computer, the init.d script should remain in place. Only edit the links. You can delete links, but they are often replaced during updates, so it is better to replace an S-link with a K-link. So if you have a link S75postfix, replace it by K25postfix.
    "I'm just a little old lady; don't try to dazzle me with jargon!"
    www.hrussman.entadsl.com

Posting Permissions

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