File openstack-glance-registry.init of Package openstack-glance
#!/bin/bash
#
# glance-registry OpenStack Glance Registry reference server implementation
#
# chkconfig: 2345 96 04
# description: OpenStack Glance Registry reference server implementation
#
# config: /etc/glance/glance-registry.conf
# pidfile: /var/run/glance/glance-registry.pid
### BEGIN INIT INFO
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $syslog
# Should-Start: $syslog
# Should-Stop: $network $syslog
# Default-Start: 3 4 5
# Default-Stop: 0 2 1 6
# Short-Description: OpenStack Glance Registry reference server implementation
# Description: The Glance project provides services for discovering,
# registering, and retrieving virtual machine images. Glance has a
# RESTful API that allows querying of VM image metadata as well as
# retrieval of the actual image.
### END INIT INFO
# Source function library.
. /etc/init.d/functions
prog="OpenStack Glance Registry Server"
suffix="registry"
flgfile=/etc/glance/glance-registry.conf
logconf=/etc/glance/logging-$suffix.conf
pidfile=/var/run/glance/glance-$suffix.pid
lckfile=/var/lock/subsys/openstack-glance-$suffix
binfile=/usr/bin/glance-$suffix
start() {
if [ -f "$pidfile" ]; then
pid=`cat $pidfile`
checkpid $pid
r=$?
if [ "$r" -eq 0 ]; then
cmd=$(basename $binfile)
echo -n "$cmd is already running (pid $pid)"; passed
echo
exit 0
fi
fi
echo -n "Starting $prog: "
cd /var/lib/glance
/sbin/start-stop-daemon --start -b -c glance:nobody --make-pidfile --pidfile $pidfile --exec /usr/bin/glance-$suffix -- -d -v --log-config=$logconf
sleep 1
if [ -f "$pidfile" ]; then
checkpid `cat $pidfile`
r=$?
if [ "$r" -eq 0 ]; then
touch $lckfile
success
else
failure
fi
else
failure
fi
echo
return
}
stop() {
echo -n "Stopping $prog: "
if [ -n "`pidofproc -p $pidfile $binfile`" ] ; then
killproc -p $pidfile $binfile
else
failure $"Stopping $prog"
fi
retval=$?
[ $retval -eq 0 ] && rm -f $lckfile
echo
return $retval
}
rh_status() {
status -p $pidfile $binfile
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
rh_status
retval=$?
if [ $retval -eq 3 -a -f $lckfile ] ; then
retval=2
fi
;;
restart)
restart
;;
condrestart)
if [ -n "`pidofproc -p $pidfile $binfile`" ] ; then
restart
fi
;;
*)
echo "Usage: service openstack-glance-$suffix {start|stop|status|restart|condrestart}"
exit 1
;;
esac
exit $?