1

I'm trying to write a script which starts a program with some parameters at startup (after boot) and therefore I'm using /etc/init.d.

This is my script:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          GetTempValues in /var/www/modules/programs
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts a program
# Description:       Starts a program

### END INIT INFO

#Actions
case "$1" in
    start)
        # START

        sudo chmod +x /var/www/modules/programs/GetTemperatureValues/startProgramm.sh
        sudo /var/www/modules/programs/GetTemperatureValues/startProgramm.sh 11 4 /var/www/modules/programs/GetTemperatureValues//logfile_11_4.txt

        ;;
    stop)
        # STOP
        echo "This does not do anything..."
        ;;
    restart)
        # RESTART
        sudo chmod +x /var/www/modules/programs/GetTemperatureValues/startProgramm.sh
        sudo /var/www/modules/programs/GetTemperatureValues/startProgramm.sh 11 4 /var/www/modules/programs/GetTemperatureValues//logfile_11_4.txt
        ;;
    esac

exit 0

But whenever I execute this command, so the script will be executed at bootup, I get a bunch of errors:

 sudo update-rc.d start_GetTempValues.sh defaults

I get these errors:

insserv: can not remove(../rc0.d/K01bluetooth): No such file or directory
insserv: can not remove(../rc0.d/K06hwclock.sh): No such file or directory
insserv: can not remove(../rc0.d/K06networking): No such file or directory
insserv: can not remove(../rc0.d/K07umountfs): No such file or directory
insserv: can not remove(../rc0.d/K05rpcbind): No such file or directory
insserv: can not remove(../rc0.d/K05nfs-common): No such file or directory
insserv: can not remove(../rc0.d/K04umountnfs.sh): No such file or directory
insserv: can not remove(../rc0.d/K03rsyslog): No such file or directory
insserv: can not remove(../rc0.d/K02sendsigs): No such file or directory
insserv: can not remove(../rc0.d/K08umountroot): No such file or directory
insserv: can not remove(../rc0.d/K09halt): No such file or directory
insserv: can not remove(../rc1.d/K01bluetooth): No such file or directory
insserv: can not remove(../rc1.d/K05rpcbind): No such file or directory
insserv: can not remove(../rc1.d/K05nfs-common): No such file or directory
insserv: can not remove(../rc1.d/K03rsyslog): No such file or directory
insserv: can not remove(../rc6.d/K01bluetooth): No such file or directory
insserv: can not remove(../rc6.d/K06hwclock.sh): No such file or directory
insserv: can not remove(../rc6.d/K06networking): No such file or directory
insserv: can not remove(../rc6.d/K07umountfs): No such file or directory
insserv: can not remove(../rc6.d/K09reboot): No such file or directory
insserv: can not remove(../rc6.d/K05rpcbind): No such file or directory
insserv: can not remove(../rc6.d/K05nfs-common): No such file or directory
insserv: can not remove(../rc6.d/K04umountnfs.sh): No such file or directory
insserv: can not remove(../rc6.d/K03rsyslog): No such file or directory
insserv: can not remove(../rc6.d/K02sendsigs): No such file or directory
insserv: can not remove(../rc6.d/K08umountroot): No such file or directory
insserv: can not remove(../rc0.d/K01bluetooth): No such file or directory
insserv: can not remove(../rc0.d/K06hwclock.sh): No such file or directory
insserv: can not remove(../rc0.d/K06networking): No such file or directory
insserv: can not remove(../rc0.d/K07umountfs): No such file or directory
insserv: can not remove(../rc0.d/K05rpcbind): No such file or directory
insserv: can not remove(../rc0.d/K05nfs-common): No such file or directory
insserv: can not remove(../rc0.d/K04umountnfs.sh): No such file or directory
insserv: can not remove(../rc0.d/K03rsyslog): No such file or directory
insserv: can not remove(../rc0.d/K02sendsigs): No such file or directory
insserv: can not remove(../rc0.d/K08umountroot): No such file or directory
insserv: can not remove(../rc0.d/K09halt): No such file or directory
insserv: can not remove(../rc0.d/K07umountfs): No such file or directory
insserv: can not symlink(../init.d/umountfs, ../rc0.d/K04umountfs): File exists
insserv: can not remove(../rc0.d/K04umountnfs.sh): No such file or directory
insserv: can not symlink(../init.d/umountnfs.sh, ../rc0.d/K03umountnfs.sh): File exists
insserv: can not remove(../rc0.d/K08umountroot): No such file or directory
insserv: can not symlink(../init.d/umountroot, ../rc0.d/K05umountroot): File exists
insserv: can not remove(../rc0.d/K09halt): No such file or directory
insserv: can not symlink(../init.d/halt, ../rc0.d/K06halt): File exists
insserv: can not remove(../rc1.d/K01bluetooth): No such file or directory
insserv: can not remove(../rc1.d/K05rpcbind): No such file or directory
insserv: can not remove(../rc1.d/K05nfs-common): No such file or directory
insserv: can not remove(../rc1.d/K03rsyslog): No such file or directory
insserv: can not remove(../rc6.d/K01bluetooth): No such file or directory
insserv: can not remove(../rc6.d/K06hwclock.sh): No such file or directory
insserv: can not remove(../rc6.d/K06networking): No such file or directory
insserv: can not remove(../rc6.d/K07umountfs): No such file or directory
insserv: can not remove(../rc6.d/K09reboot): No such file or directory
insserv: can not remove(../rc6.d/K05rpcbind): No such file or directory
insserv: can not remove(../rc6.d/K05nfs-common): No such file or directory
insserv: can not remove(../rc6.d/K04umountnfs.sh): No such file or directory
insserv: can not remove(../rc6.d/K03rsyslog): No such file or directory
insserv: can not remove(../rc6.d/K02sendsigs): No such file or directory
insserv: can not remove(../rc6.d/K08umountroot): No such file or directory
insserv: can not remove(../rc6.d/K07umountfs): No such file or directory
insserv: can not symlink(../init.d/umountfs, ../rc6.d/K04umountfs): File exists
insserv: can not remove(../rc6.d/K04umountnfs.sh): No such file or directory
insserv: can not symlink(../init.d/umountnfs.sh, ../rc6.d/K03umountnfs.sh): File exists
insserv: can not remove(../rc6.d/K08umountroot): No such file or directory
insserv: can not symlink(../init.d/umountroot, ../rc6.d/K05umountroot): File exists
insserv: can not remove(../rc6.d/K09reboot): No such file or directory
insserv: can not symlink(../init.d/reboot, ../rc6.d/K06reboot): File exists

Please don't give me security advices, I'd be really thankful for working solutions.

2
  • sudo in an init.d script? not only is it not required, it may be the problem. Also, if you just want something to just run on boot (and not be a daemon) init.d is probably not the place to put it anyway ... and finally, if you're running jessie, then init.d is old school, learn/use the dreaded systemd Commented Jun 10, 2016 at 13:22
  • I recommend you to load/call your script from /etc/rc.local, init.d is a bit deprecated, use systemd instead.
    – MadAntrax
    Commented Jun 10, 2016 at 13:56

1 Answer 1

0

ouch, you must take care of the rights
Setup executable permission on script, take care the system runs as root best practice is to login as root, or

# su - (to transform in a real root)

# chown root:root /etc/init.d/mystartup.sh
# chmod +x /etc/init.d/mystartup.sh

Make sure this script get executed every time Debian Linux system comes up:

# update-rc.d mystartup.sh defaults 100

have fun

4
  • What does the 100 mean?
    – Dan
    Commented Jun 13, 2016 at 17:52
  • Its the two-digit sequence number that determines where in the sequence init will run the scripts.
    – Max Muster
    Commented Jun 13, 2016 at 18:00
  • 1
    two digits? Two hex digits, maybe? Because 100 is three digits... What am I missing?
    – Dan
    Commented Jun 13, 2016 at 18:08
  • Sure you are right the start sequence goes from S00 to S99 and the kill sequence from K00 to K99 .I was making fun . :P You could also specify the start or kill sequence as SS KK like this : update-rc.d [-n] name defaults [NN | SS KK]
    – Max Muster
    Commented Jun 13, 2016 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.