#!/bin/sh
#
# chkconfig: - 91 35
# description: Starts and stops the Openstack Nova \
#	Console Console Proxy Server daemon.
#
# pidfile: /var/run/nova/nova-console.pid
# config:  /etc/nova/nova.conf


# Source function library.
if [ -f /etc/init.d/functions ] ; then
  . /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
  . /etc/rc.d/init.d/functions
else
  exit 1
fi

# Avoid using root's TMPDIR
unset TMPDIR

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 1

. /usr/share/nova/init-functions.sh

NAME="Nova Console"
SERVICE=console
LOCKFILE=/var/lock/subsys/nova-$SERVICE

# Allow status as non-root.
if [ "$1" = status ]; then
	status $SERVICE "$NAME"
	exit $?
fi

# Check that nova.conf exists.
[ -f $CONFIG ] || exit 6

# Check that we can read from it... so non-root users stop here
[ -r $CONFIG ] || exit 4

case "$1" in
start)
	start $SERVICE "$NAME"
	;;
stop)
	stop $SERVICE "$NAME"
	;;
restart)
	restart $SERVICE "$NAME"
	;;
reload)
	restart $SERVICE "$NAME"
	;;
status)
	status $SERVICE "$NAME"
	;;
condrestart)
	[ -f $LOCKFILE ] && restart $SERVICE "$NAME" || :
	;;
condstop)
	[ -f $LOCKFILE ] && stop $SERVICE "$NAME" || :
	;;
*)
	echo $"Usage: $0 {start|stop|restart|reload|status|condrestart|condstop}"
	exit 2
esac
