18922761a6
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
112 lines
2.9 KiB
Bash
112 lines
2.9 KiB
Bash
#! /bin/bash
|
|
#
|
|
# Copyright (c) 2015-2017 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
# Linux Standard Base (LSB) Error Codes
|
|
SUCCESS=0
|
|
GENERIC_ERROR=1
|
|
INVALID_ARGS=2
|
|
|
|
NOVA_STARTUP_TAG=${NOVA_STARTUP_TAG:-"NOVA_STARTUP"}
|
|
|
|
function log
|
|
{
|
|
logger -p local1.info -t ${NOVA_STARTUP_TAG} $@
|
|
}
|
|
|
|
NOVA_RUN="/var/run/nova"
|
|
NOVA_CLEANUP_DONE_FILE="${NOVA_RUN}/.nova_cleanup_done"
|
|
NOVA_COMPUTE_ENABLED="${NOVA_RUN}/.nova_compute_enabled"
|
|
|
|
NOVA_COMPUTE_PID_FILE="${NOVA_RUN}/nova-compute.pid"
|
|
NOVA_CLEANUP_PID_FILE="${NOVA_RUN}/nova-cleanup.pid"
|
|
|
|
NOVA_COMPUTE_PMOND_TARGET="/etc/nova/nova-compute.conf"
|
|
NOVA_COMPUTE_PMOND_SYMLINK="/etc/pmon.d/nova-compute.conf"
|
|
|
|
NOVA_CLEANUP_PMOND_TARGET="/etc/nova/nova-cleanup.conf"
|
|
NOVA_CLEANUP_PMOND_SYMLINK="/etc/pmon.d/nova-cleanup.conf"
|
|
|
|
case "$1" in
|
|
start)
|
|
log "Start"
|
|
|
|
mkdir -p ${NOVA_RUN}
|
|
chown nova:root ${NOVA_RUN}
|
|
|
|
if [ -f ${NOVA_COMPUTE_ENABLED} ]
|
|
then
|
|
rm ${NOVA_COMPUTE_ENABLED}
|
|
fi
|
|
|
|
if [ -f ${NOVA_CLEANUP_PID_FILE} ]
|
|
then
|
|
NOVA_CLEANUP_PID=$(cat ${NOVA_CLEANUP_PID_FILE})
|
|
log "About to kill ${NOVA_CLEANUP_PID}"
|
|
kill -9 ${NOVA_CLEANUP_PID}
|
|
log "Killed ${NOVA_CLEANUP_PID}"
|
|
rm ${NOVA_CLEANUP_PID_FILE}
|
|
fi
|
|
|
|
if [ -f ${NOVA_CLEANUP_DONE_FILE} ]
|
|
then
|
|
log "Nova-Cleanup already complete"
|
|
|
|
if [ -e $NOVA_CLEANUP_PMOND_SYMLINK ]
|
|
then
|
|
rm $NOVA_CLEANUP_PMOND_SYMLINK
|
|
fi
|
|
|
|
log "Nova-Compute restart"
|
|
|
|
# Do in the foreground because the nova-compute script wipes
|
|
# and recreates the pid file for nova-compute. Otherwise
|
|
# you could be looking at a stale pid file.
|
|
timeout --signal KILL 10s /etc/init.d/nova-compute restart > /dev/null 2>&1
|
|
while ! [ -f ${NOVA_COMPUTE_PID_FILE} ]
|
|
do
|
|
log "Waiting for Nova-Compute to start"
|
|
sleep 1
|
|
done
|
|
|
|
NOVA_COMPUTE_PID=$(head -1 ${NOVA_COMPUTE_PID_FILE})
|
|
log "Nova-Compute pid ${NOVA_COMPUTE_PID} started"
|
|
|
|
else
|
|
log "Nova-Cleanup is needed"
|
|
|
|
# Do in the background because of the long execution time.
|
|
timeout --signal KILL 300s /etc/init.d/nova-cleanup start &
|
|
|
|
while ! [ -f ${NOVA_CLEANUP_PID_FILE} ]
|
|
do
|
|
log "Waiting for Nova-Cleanup to start"
|
|
sleep 1
|
|
done
|
|
|
|
NOVA_CLEANUP_PID=$(cat ${NOVA_CLEANUP_PID_FILE})
|
|
log "Nova-Cleanup pid ${NOVA_CLEANUP_PID} started"
|
|
fi
|
|
|
|
log "Finished"
|
|
;;
|
|
|
|
stop)
|
|
;;
|
|
|
|
restart|force-reload|reload)
|
|
stop
|
|
start
|
|
;;
|
|
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|force-reload|reload}"
|
|
exit $INVALID_ARGS
|
|
;;
|
|
esac
|
|
|
|
exit $SUCCESS
|