Skip to content

Instantly share code, notes, and snippets.

@yury-egorenkov
Created February 25, 2014 14:04
Show Gist options
  • Save yury-egorenkov/9209362 to your computer and use it in GitHub Desktop.
Save yury-egorenkov/9209362 to your computer and use it in GitHub Desktop.
Start script for xbt_tracker
#!/bin/sh
### BEGIN INIT INFO
# Provides: XBTT
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts XBT Tracker
### END INIT INFO
. /lib/lsb/init-functions
NAME=xbt
DESC="XBT Tracker"
PIDDIR=/var/run/xbt
PIDFILE=$PIDDIR/xbt_tracker.pid
USER=daemon
GROUP=daemon
SSD_OPTS="--pidfile=$PIDFILE --user=$USER --name=xbt_tracker"
DAEMON=/usr/local/bin/xbt_tracker
OPTIONS="--conf_file /etc/xbt/xbt_tracker.conf"
test -f $DAEMON || exit 0
if test ! -e $PIDDIR; then
mkdir $PIDDIR
chown $USER:$GROUP $PIDDIR
fi
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start $SSD_OPTS --startas "$DAEMON" --chuid "$USER" -- $OPTIONS
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop $SSD_OPTS --retry 10
log_end_msg $?
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment