I am new to Linux (obviously), and I need to run some commands whenever my Linux server boots without entering them into the console manually.
I have this file called overpass.conf, which works fine on boot:
description 'Overpass API dispatcher daemon' env DB_DIR=/var/www/osm/db/ env EXEC_DIR=/var/www/osm/ start on (local-filesystems and net-device-up) stop on runlevel [!2345] pre-start script rm $DB_DIR/osm3s* || true rm /dev/shm/osm3s* || true end script exec $EXEC_DIR/bin/dispatcher --osm-base --db-dir=$DB_DIR
However, I also want to run the following:
cp -pR "/root/osm-3s_v0.7.4/rules" "/var/www/osm/db/" nohup /var/www/osm/bin/dispatcher --areas --db-dir="/var/www/osm/db/" & chmod 666 "/var/www/osm/db/osm3s_v0.7.4_areas" nohup /var/www/osm/bin/rules_loop.sh "/var/www/osm/db/" &
I tried adding them to the bottom of the file by adding exec to the executable commands, and even tried to remove the quotes and then checked with start overpass , but it throws errors if I add any commands to the original ones.
How can I execute these 4 commands after the initial ones? I am in distress. Thank you
Edit
I solved this with these commands:
vi /etc/init.d/mystartup.sh
-Add commands to the script
chmod +x /etc/init.d/mystartup.sh update-rc.d mystartup.sh defaults 99
source share