Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh -e
- ### BEGIN INIT INFO
- # Provides: utserver
- # Required-Start: $local_fs $remote_fs $network
- # Required-Stop: $local_fs $remote_fs $network
- # Default-Start: 2 3 4 5
- # Default-Stop: 0 1 6
- # Short-Description: Start or stop the utserver.
- ### END INIT INFO
- CHDIR=<dir containing utserver program>
- NAME=utserver
- OPTIONS="-LOGFILE"
- DAEMON=$CHDIR/$NAME
- USER=<username>
- PIDFILE=/var/run/$NAME.pid
- STOP_TIMEOUT=5
- [ -x $DAEMON ] || exit 1
- . /lib/lsb/init-functions
- start_daemon () {
- pgrep -U $USER $NAME >/dev/null && echo "$NAME is already running" && log_end_msg 1
- rm -f $PIDFILE >/dev/null
- start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE --chuid $USER --chdir $CHDIR --background --exec $DAEMON -- $OPTIONS
- }
- case "$1" in
- start)
- log_daemon_msg "Starting $NAME daemon" "$NAME"
- start_daemon
- log_end_msg 0
- ;;
- stop)
- log_daemon_msg "Stopping $NAME daemon" "$NAME"
- start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON --retry $STOP_TIMEOUT || log_end_msg 1
- pgrep -U $USER $NAME >/dev/null || rm -f $PIDFILE >/dev/null
- log_end_msg 0
- ;;
- restart)
- log_daemon_msg "Restarting $NAME daemon" "$NAME"
- start-stop-daemon --stop --quiet --pidfile $PIDFILE --exec $DAEMON --retry $STOP_TIMEOUT || log_end_msg 1
- start_daemon
- log_end_msg 0
- ;;
- *)
- echo "Usage: /etc/init.d/$NAME {start|stop|restart}"
- exit 2
- ;;
- esac
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement