Jonathan Hart
Committed by Gerrit Code Review

Proposal for replacing Upstart with init.d script.

Change-Id: I22ad1faac713bb50f0b7ad3dde132363a6588723
......@@ -50,4 +50,4 @@ for app in ${SYS_APPS//,/ } ${ONOS_APPS//,/ }; do
fi
done
exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/karaf $KARAF_ARGS
exec ${ONOS_HOME}/apache-karaf-$KARAF_VERSION/bin/start $KARAF_ARGS
......
#! /bin/bash
# -----------------------------------------------------------------------------
# init.d script to run ONOS.
# -----------------------------------------------------------------------------
start () {
# TODO check if ONOS is already running first
[ -f /opt/onos/options ] && . /opt/onos/options
ONOS_USER=${ONOS_USER:-root}
# Ensure that the environment is initialized
[ -d /opt/onos ] && mkdir /opt/onos/var 2>/dev/null && chown $ONOS_USER.$ONOS_USER /opt/onos/var
[ -d /opt/onos ] && mkdir /opt/onos/config 2>/dev/null && chown $ONOS_USER.$ONOS_USER /opt/onos/config
[ -d /opt/onos ] && [ ! -h /opt/onos/log ] \
&& ln -s /opt/onos/karaf/data/log /opt/onos/log || :
[ -f /opt/onos/options ] && . /opt/onos/options
start-stop-daemon --signal INT --start --chuid ${ONOS_USER:-root} \
--exec /opt/onos/bin/onos-service -- ${ONOS_OPTS:-server} \
>/opt/onos/var/stdout.log 2>/opt/onos/var/stderr.log
}
stop () {
/opt/onos/karaf/bin/stop
}
restart () {
stop
start
}
status () {
/opt/onos/karaf/bin/status
}
case $1 in
start)
start
;;
stop | force-stop)
stop
;;
restart)
shift
restart "$@"
;;
status)
status
exit $?
;;
*)
echo "Usage: $0 {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0
......@@ -61,6 +61,7 @@ ssh $remote "
# Make a link to the log file directory and make a home for auxiliaries
ln -s $ONOS_INSTALL_DIR/$KARAF_DIST/data/log /opt/onos/log
ln -s $ONOS_INSTALL_DIR/$KARAF_DIST /opt/onos/karaf
mkdir $ONOS_INSTALL_DIR/var
mkdir $ONOS_INSTALL_DIR/config
......@@ -70,6 +71,7 @@ ssh $remote "
# Install the upstart configuration file and setup options for debugging
[ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/init/onos.conf /etc/init/onos.conf
[ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/init/onos.initd /etc/init.d/onos
echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options
# Setup correct user to run onos-service
......
......@@ -43,7 +43,7 @@ case $2 in
# Execute the remote commands
for node in $nodes; do
ssh $ONOS_USER@${node} "sudo ${2:-status} onos"
ssh $ONOS_USER@${node} "sudo /etc/init.d/onos ${2:-status}"
done
;;
*)
......