Search code examples
linuxboot

How to start init.d script on bootup in embedded linux. I dont have update-rc.d. Is there any other way to start init.d script on linux boot?


I am have a Linux board on which I have added one init script under /etc/init.d/ directory. I can start,stop,restart service using script manually. For Debian we do use "update-rc.d" to execute this script at boot time. But i don't have this command, How then can i execute the script at boot time? Is there any alternate way to do this?


Solution

  • inittab has some other uses. The main use is creating "unkillable" service, that will be restarted every time it dies.

    If you need just usual service, you can just create symlinks manually. Example from apache, like very typical service with default runlevels.

    # ls -la /etc/rc*.d/*apache2
    lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc0.d/K02apache2 -> ../init.d/apache2
    lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc1.d/K02apache2 -> ../init.d/apache2
    lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc2.d/S02apache2 -> ../init.d/apache2
    lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc3.d/S02apache2 -> ../init.d/apache2
    lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc4.d/S02apache2 -> ../init.d/apache2
    lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc5.d/S02apache2 -> ../init.d/apache2
    lrwxrwxrwx 1 root root 17 Oct  2 13:45 /etc/rc6.d/K02apache2 -> ../init.d/apache2
    

    So it should be killed at runlevels 0 1 6 and started on runlevels 2 3 4 5.