Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Replace `Description` with the description of the application, `/path/to/my/service`, with the command, that should be executed
- # Then save the file under `/etc/init.d/myservice`, where you replace `myservice`, with the name of the application
- # To activate
- service myservice enable
- # To start
- service myservice start
- #!/bin/sh
- ### BEGIN INIT INFO
- # Provides: myservice
- # Required-Start: $remote_fs $syslog
- # Required-Stop: $remote_fs $syslog
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Start/stop my custom service
- # Description: Start/stop my custom service
- ### END INIT INFO
- NAME="myservice"
- DAEMON="/path/to/my/service" # Parameters can be specified with --
- PIDFILE="/var/run/$NAME.pid"
- start() {
- echo "Starting $NAME..."
- start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON
- }
- stop() {
- echo "Stopping $NAME..."
- start-stop-daemon --stop --pidfile $PIDFILE --retry 10
- rm -f $PIDFILE
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- stop
- start
- ;;
- *)
- echo "Usage: $0 {start|stop|restart}"
- exit 1
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement