diff options
Diffstat (limited to 'conductor/examples/distribution/ubuntu/init.d/conductor-controller')
-rw-r--r-- | conductor/examples/distribution/ubuntu/init.d/conductor-controller | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/conductor/examples/distribution/ubuntu/init.d/conductor-controller b/conductor/examples/distribution/ubuntu/init.d/conductor-controller new file mode 100644 index 0000000..f09d302 --- /dev/null +++ b/conductor/examples/distribution/ubuntu/init.d/conductor-controller @@ -0,0 +1,148 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: conductor-controller +# Required-Start: $network $local_fs $remote_fs $syslog +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Conductor Controller +# Description: Conductor Controller server +### END INIT INFO + +# Author: Joe D'Andrea <jdandrea@research.att.com> +# Based on work by Thomas Goirand <zigo@debian.or> + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="Conductor Controller" +PROJECT_NAME=conductor +NAME=${PROJECT_NAME}-controller +PYTHON_HOME= + +#!/bin/sh +# The content after this line comes from openstack-pkg-tools +# and has been automatically added to a .init.in script, which +# contains only the descriptive part for the daemon. Everything +# else is standardized as a single unique script. + +# Author: Joe D'Andrea <jdandrea@research.att.com> +# Based on work by Thomas Goirand <zigo@debian.or> + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +if [ -z "${DAEMON}" ] ; then + if [ -d "${PYTHON_HOME}" ] ; then + DAEMON=${PYTHON_HOME}/bin/${NAME} + else + DAEMON=/usr/bin/${NAME} + fi +fi +PIDFILE=/var/run/${PROJECT_NAME}/${NAME}.pid +if [ -z "${SCRIPTNAME}" ] ; then + SCRIPTNAME=/etc/init.d/${NAME} +fi +if [ -z "${SYSTEM_USER}" ] ; then + SYSTEM_USER=${PROJECT_NAME} +fi +if [ -z "${SYSTEM_GROUP}" ] ; then + SYSTEM_GROUP=${PROJECT_NAME} +fi +if [ "${SYSTEM_USER}" != "root" ] ; then + STARTDAEMON_CHUID="--chuid ${SYSTEM_USER}:${SYSTEM_GROUP}" +fi +if [ -z "${CONFIG_FILE}" ] ; then + CONFIG_FILE=/etc/${PROJECT_NAME}/${PROJECT_NAME}.conf +fi +LOGFILE=/var/log/${PROJECT_NAME}/${NAME}.log +if [ -z "${NO_OPENSTACK_CONFIG_FILE_DAEMON_ARG}" ] ; then + DAEMON_ARGS="${DAEMON_ARGS} --config-file=${CONFIG_FILE}" +fi + +# Exit if the package is not installed +[ -x $DAEMON ] || exit 0 + +# If ran as root, create /var/lock/X, /var/run/X, /var/lib/X and /var/log/X as needed +if [ `whoami` = "root" ] ; then + for i in lock run log lib ; do + mkdir -p /var/$i/${PROJECT_NAME} + chown ${SYSTEM_USER} /var/$i/${PROJECT_NAME} + done +fi + +# This defines init_is_upstart which we use later on (+ more...) +. /lib/lsb/init-functions + +# Manage log options: logfile and/or syslog, depending on user's choosing +[ -r /etc/default/openstack ] && . /etc/default/openstack +[ -r /etc/default/$NAME ] && . /etc/default/$NAME +[ "x$USE_SYSLOG" = "xyes" ] && DAEMON_ARGS="$DAEMON_ARGS --use-syslog" +[ "x$USE_LOGFILE" != "xno" ] && DAEMON_ARGS="$DAEMON_ARGS --log-file=$LOGFILE" + +do_start() { + start-stop-daemon --start --quiet --background ${STARTDAEMON_CHUID} --make-pidfile --pidfile ${PIDFILE} --chdir /var/lib/${PROJECT_NAME} --startas $DAEMON \ + --test > /dev/null || return 1 + start-stop-daemon --start --quiet --background ${STARTDAEMON_CHUID} --make-pidfile --pidfile ${PIDFILE} --chdir /var/lib/${PROJECT_NAME} --startas $DAEMON \ + -- $DAEMON_ARGS || return 2 +} + +do_stop() { + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE + RETVAL=$? + rm -f $PIDFILE + return "$RETVAL" +} + +do_systemd_start() { + exec $DAEMON $DAEMON_ARGS +} + +case "$1" in +start) + #init_is_upstart > /dev/null 2>&1 && exit 1 + log_daemon_msg "Starting $DESC" "$NAME" + do_start + case $? in + 0|1) log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac +;; +stop) + #init_is_upstart > /dev/null 2>&1 && exit 0 + log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case $? in + 0|1) log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac +;; +status) + status_of_proc -p "${PIDFILE}" "$DAEMON" "$NAME" && exit 0 || exit $? +;; +systemd-start) + do_systemd_start +;; +restart|force-reload) + #init_is_upstart > /dev/null 2>&1 && exit 1 + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case $? in + 0|1) + do_start + case $? in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) log_end_msg 1 ;; # Failed to stop + esac +;; +*) + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload|systemd-start}" >&2 + exit 3 +;; +esac + +exit 0 + |