nkeil / execute-on-startup

Execute an arbituary number of files on startup of Debian based system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

execute-on-startup

Purpose: To execute an arbituary number of files on startup of a Debian based system

This projct is currently a work in progress

Usage

  1. Place all the files you want to run in the 'run' folder with 'run_all.sh' in its parent directory.

  2. Edit 'run_all.sh' to include the full path to the run folder.

  3. Setup the file 'run_all.sh' to run on startup. There are many ways to do this.

    • The most up to date method is through systemd (detailed below).
    • Placing the script in rc.local may work but is not reccomended.
    • Hijacking the end of another script known to execute on startup is also plausible but is messy and not as easily extendable.
  4. Additional notes

    • Make sure that all files are in fact executable. This can be done in the terminal with chmod +x filename for each file involved.
    • Each execuatable should include a shebang as its first line to insure the correct interpreter is loaded.

Systemd

  1. Install systemd if you haven't done so already.

  2. Modify the file 'startup.service' to include the full path to the file 'run_all.sh'.

  3. Add the correct permissions to the file with sudo chmod 644 /etc/systemd/system/startup.service.

  4. Copy the file to the folder '/etc/systemd/system'.

  5. Test the service with the following commands. Ensure the service did not fail. If you have trouble locating the problem, follow this guide to investigate it.

    • sudo systemctl start startup
    • sudo systemctl status startup
  6. Enable the service.

    • sudo systemctl enable startup

Modifying the startup execution

  • If it is necessary for your files to be executed after a network connection is established, add the line After=network.target following the description. This can also be replaced by any other '.service' file that must be run before execution.
  • More information on '.service' files can be found here.

Further Reference

About

Execute an arbituary number of files on startup of Debian based system


Languages

Language:Shell 100.0%