distil/packaging/fs/etc/init.d/artifice

64 lines
1.5 KiB
Bash

#!/bin/sh
set -e
### BEGIN INIT INFO
# Provides: artifice
# Required-Start: $local_fs $remote_fs $network $time
# Required-Stop: $local_fs $remote_fs $network $time
# Should-Start: $syslog
# Should-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Artifice-Openstack billing server
### END INIT INFO
ARTIFICE_PATH=/opt/stack/artifice
DAEMON="$ARTIFICE_PATH/bin/web"
NAME=artifice
PIDFILE="/var/run/artifice/${NAME}.pid"
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
# versions can be specified explicitly
case "$1" in
start)
start-stop-daemon --start --quiet --pidfile $PIDFILE\
--startas $DAEMON
;;
stop)
start-stop-daemon --stop --quiet --pidfile $PIDFILE\
--oknodo
;;
restart)
start-stop-daemon --stop --quiet --pidfile $PIDFILE --retry TERM/10/KILL/5 --quiet --oknodo
start-stop-daemon --start --quiet --pidfile $PIDFILE \
--startas $DAEMON -- $NAME
;;
status)
if [ -f $PIDFILE ]; then
PID=`cat $PIDFILE`
RUNNING=`ps aux | awk '{print $2}' | grep $PIDFILE`
if [ $RUNNING = $PID ]; then
log_success_msg "$NAME is running"
else
log_failure_msg "$NAME is not running"
fi
else
log_failure_msg "$PIDFILE not found."
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0