1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#!/bin/sh
### BEGIN INIT INFO
# Provides: prads
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Prads Realtime Asset Detection System
# Description: Prads is a server that listens on your network, and
# logs the presence of any servers and clients
### END INIT INFO
#
# Author: Stig Sandbeck Mathisen <ssm@debian.org>
#
DESC="Prads Realtime Asset Detection System"
NAME="prads"
DAEMON="/usr/bin/${NAME}"
test -f $DAEMON || exit 0
# Read LSB init functions
. /lib/lsb/init-functions
# Read DAEMON_OPTS from defaults file, if it exists
if [ -r /etc/default/$NAME -a -f /etc/default/$NAME ]
then
. /etc/default/$NAME
fi
USER="prads"
GROUP="prads"
CHROOT="/run/prads"
PIDFILE="prads.pid"
DAEMON_OPTS="-D -u $USER -g $GROUP -C $CHROOT -p $PIDFILE ${DAEMON_OPTS:-}"
create_chroot() {
install -o $USER -g $GROUP -d $CHROOT
}
start_service() {
log_begin_msg "Starting $DESC..."
[ ! -d $CHROOT ] && create_chroot
start-stop-daemon --start --quiet --pidfile $CHROOT/$PIDFILE \
--umask "007" \
--exec $DAEMON -- $DAEMON_OPTS
log_end_msg $?
}
stop_service() {
log_begin_msg "Stopping $DESC..."
start-stop-daemon --stop --quiet --oknodo --retry 60 \
--exec $DAEMON \
--user $USER \
--pidfile $CHROOT/$PIDFILE
log_end_msg $?
}
status_service() {
status_of_proc -p "$CHROOT/$PIDFILE" "$DAEMON" "$NAME"
}
restart_service() {
$0 stop && $0 start
}
fail() {
echo "usage: $0 <start|stop|restart|status>"
exit 1
}
case "$1" in
start) start_service;;
stop) stop_service;;
status) status_service;;
restart) restart_service;;
force-reload) restart_service;;
*) fail;;
esac
|