/usr/bin/pkgos-gen-upstart-job is in openstack-pkg-tools 54.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #!/bin/sh
if [ $# -ne 1 ] ; then
echo "Usage: $0 <init_template>"
exit 1
fi
INIT_TEMPLATE=${1}
UPSTART_FILE=`echo ${INIT_TEMPLATE} | sed 's/.init.in/.upstart/'`
# Get the variables defined in the init template
. ${INIT_TEMPLATE}
if [ -z "${NAME}" ] ; then
echo "Variable NAME is not set!"
exit 1
fi
if [ -z "${PROJECT_NAME}" ] ; then
echo "Variable PROJECT_NAME is not set!"
exit 1
fi
if [ -z "${DESC}" ] ; then
echo "Variable DESC is not set!"
exit 1
fi
## Find out what should go in After=
#SHOULD_START=`cat ${INIT_TEMPLATE} | grep "# Should-Start:" | sed 's/# Should-Start://'`
#
#if [ -n "${SHOULD_START}" ] ; then
# AFTER="After="
# for i in ${SHOULD_START} ; do
# AFTER="${AFTER}${i}.service "
# done
#fi
if [ -z "${DAEMON}" ] ; then
DAEMON=/usr/bin/${NAME}
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
echo "description \"${DESC}\"
author \"Thomas Goirand <zigo@debian.org>\"
start on runlevel [2345]
stop on runlevel [!2345]
chdir /var/run
respawn
respawn limit 20 5
limit nofile 65535 65535
pre-start script
for i in lock run lib ; do
mkdir -p /var/\$i/${PROJECT_NAME}
chown ${SYSTEM_USER}:${SYSTEM_GROUP} /var/\$i/${PROJECT_NAME}
done
for i in log ; do
mkdir -p /var/\$i/${PROJECT_NAME}
chown ${SYSTEM_USER}:adm /var/\$i/${PROJECT_NAME}
done
end script
script
[ -x \"${DAEMON}\" ] || exit 0
DAEMON_ARGS=\"${DAEMON_ARGS}\"
CONFIG_FILE=\"${CONFIG_FILE}\"
USE_SYSLOG=\"${USE_SYSLOG}\"
USE_LOGFILE=\"${USE_LOGFILE}\"
NO_OPENSTACK_CONFIG_FILE_DAEMON_ARG=\"${NO_OPENSTACK_CONFIG_FILE_DAEMON_ARG}\"
[ -r /etc/default/openstack ] && . /etc/default/openstack
[ -r /etc/default/\$UPSTART_JOB ] && . /etc/default/\$UPSTART_JOB
[ \"x\$USE_SYSLOG\" = \"xyes\" ] && DAEMON_ARGS=\"\$DAEMON_ARGS --use-syslog\"
[ \"x\$USE_LOGFILE\" != \"xno\" ] && DAEMON_ARGS=\"\$DAEMON_ARGS --log-file=${LOGFILE}\"
[ -z \"\$NO_OPENSTACK_CONFIG_FILE_DAEMON_ARG\" ] && DAEMON_ARGS=\"\$DAEMON_ARGS --config-file=\$CONFIG_FILE\"
exec start-stop-daemon --start --chdir /var/lib/${PROJECT_NAME} \\
${STARTDAEMON_CHUID} --make-pidfile --pidfile ${PIDFILE} \\
--exec ${DAEMON} -- \${DAEMON_ARGS}
end script
" >${UPSTART_FILE}
|