#!/bin/sh ### BEGIN INIT INFO # Provides: rally # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Should-Start: postgresql rabbitmq-server # Should-Stop: postgresql rabbitmq-server # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: OpenStack Block Storage (Rally) - API # Description: OpenStack Block Storage (Rally) - API ### END INIT INFO SUFFIX=@suffix@ DESC="rally-$SUFFIX" DAEMON="/usr/bin/rally-$SUFFIX" PIDFILE="/var/run/rally-$SUFFIX.pid" start() { if [ -e $PIDFILE ]; then PIDDIR=/proc/$(cat $PIDFILE) if [ -d ${PIDDIR} ]; then echo "$DESC already running." exit 1 else echo "Removing stale PID file $PIDFILE" rm -f $PIDFILE fi fi if [ ! -d /var/log/rally ]; then mkdir /var/log/rally fi echo -n "Starting $DESC..." start-stop-daemon --start --quiet --background \ --pidfile ${PIDFILE} --make-pidfile --exec ${DAEMON} \ -- --log-dir=/var/log/rally if [ $? -eq 0 ]; then echo "done." else echo "failed." fi } stop() { echo -n "Stopping $DESC..." start-stop-daemon --stop --quiet --pidfile $PIDFILE if [ $? -eq 0 ]; then echo "done." else echo "failed." fi rm -f $PIDFILE } status() { pid=`cat $PIDFILE 2>/dev/null` if [ -n "$pid" ]; then if ps -p $pid > /dev/null 2>&1 ; then echo "$DESC is running" return fi fi echo "$DESC is not running" } case "$1" in start) start ;; stop) stop ;; restart|force-reload|reload) stop start ;; status) status ;; *) echo "Usage: $0 {start|stop|force-reload|restart|reload|status}" exit 1 ;; esac exit 0