Debian: How to run a script on startup without having to write 30 lines of shell script?

Solution 1:

Consider using /etc/rc.local (executed as root) or crontab (executed as a user of your choice).

Two examples:

  • /etc/rc.local

    #!/bin/sh -e
    #(Multiple lines of comments removed.)
    /usr/local/bin/your-script.sh
    exit 0
    
  • crontab (edited via, for example, crontab -e)

    #(Multiple lines of comments removed.)
    @reboot /usr/local/bin/your-script.sh
    

If your script needs to run continuously in the background, I would advise against using rc.local or crontab, and instead write a proper (or multiple) init.d script(s). This way you / your system is able to cleanly restart/reload/start/stop etc. the daemons.

The LSB tags provide some value: "By documenting the run-time dependencies for init.d scripts, it becomes possible to verify the current boot order, order the boot using these dependencies, and run boot scripts in parallel to speed up the boot process." For more details, head over to the Debian wiki.

By the way, the missing headers: It's a warning, so actually, it's up to you, how and what to do with this.