Note- If you are using this method then the services which you have listed in the below script would have to be disabled else they will start up parallely along with this service, Making this script redundant.
Make a script startup.sh in /usr/local/epi/scripts/py folder. Below is an example script
#!/bin/bash set -x exec > /tmp/startup-debug.log 2>&1
services=( "nats-server" "irapodwatcher" "irapodtracker" "cpatracker" "irapass" "iracpa" "iracallrouter" "iraswitch" ) delay=3 for service in "${services[@]}"; do echo "Starting $service..." systemctl start "$service" if [ $? -eq 0 ]; then echo "$service started successfully. Waiting $delay seconds." sleep $delay else echo "Failed to start $service." exit 1 fi done echo "All core services started successfully." sleep 20 echo "Starting the first Python script..." /usr/local/epi/scripts/py/venv/bin/python /usr/local/epi/scripts/py/add_gateway_djump.py & echo "waiting 5 seconds." sleep 5 echo "Starting the secondscript." /usr/local/epi/scripts/py/venv/bin/python /usr/local/epi/scripts/py/add_gateway_media_server.py & sleep 5 echo "Starting the third Python script." /usr/local/epi/scripts/py/venv/bin/python /usr/local/epi/scripts/py/add_logical_gateway_tetherfi_demo.py & sleep 5 echo "All services and scripts are now running." |
Give it executable permissions with the following command
sudo chmod 755 /usr/local/epi/scripts/py |
Make a service file in /etc/systemd/system called startup.service with the following content.
startup.service
[Unit] Description=Custom Service Startup Script with Delays After=network.target
[Service] Type=oneshot ExecStart=/usr/local/epi/scripts/py/startup.sh
[Install] WantedBy=multi-user.target |
Run
sudo systemctl enable startup.service |
To verify if the service is running as expected you can check the startup-debug.log in the /tmp folder
Note- in the python scripts make sure to add the absolute path instead of the relative path
Before-
After-
nkeys_seed="/usr/local/epi/scripts/py/mysign.nk" |