Simpel autostart Script for Linux/Debian/Ubuntu

Exampel Script:

#!/bin/sh
### BEGIN INIT INFO
case "$1" in
start)
echo "Starting NAME"
start-stop-daemon --start -quiet -u counterstrike --chuid counterstrike --exec /home/counterstrike/source/server1/csStart.sh start ca
;;
stop)
echo "Stopping NAME"
start-stop-daemon --start -quiet -u counterstrike --chuid counterstrike --exec /home/counterstrike/source/server1/csStart.sh stop
;;
*)
echo "Usage: /etc/init.d/css1 {start|stop}"
exit 1
;;
esac
exit 0

 

Template and Instruction:

#!/bin/sh
### BEGIN INIT INFO
### 1. Replace NAME with the name of your service
### 2. Replace USER with the user you will run the service
### 3. Replace PATH with path to your programm
### 4. Replace COMMAND with command for your programm
### 5. Save the file with service NAME in the /etc/init.d/
### 7. got to /etc/init.d/
### 6. run "sudo update-rc.d NAME defaults"

case "$1" in
start)
echo "Starting NAME"
start-stop-daemon --start -quiet -u USER --chuid USER --exec PATH COMMAND
;;
stop)
echo "Stopping NAME"
start-stop-daemon --start -quiet -u USER --chuid USER --exec PATH COMMAND
;;
*)
echo "Usage: service NAME {start|stop}"
exit 1
;;
esac
exit 0

Schreibe einen Kommentar