
This commit modifies the baremetal horizon init script to kill the horizon pod so it restarts. This gives it the chance to pick up any new branding files when they're installed. Change-Id: Ic122bb359e00d76ab967b2ddcdc278c8cbfde818 Story: 2003909 Task: 27080 Signed-off-by: Tyler Smith <tyler.smith@windriver.com>
162 lines
4.4 KiB
Bash
Executable File
162 lines
4.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: OpenStack Dashboard
|
|
# Required-Start: networking
|
|
# Required-Stop: networking
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: OpenStack Dashboard
|
|
# Description: Web based user interface to OpenStack services including
|
|
# Nova, Swift, Keystone, etc.
|
|
### END INIT INFO
|
|
|
|
RETVAL=0
|
|
DESC="openstack-dashboard"
|
|
PIDFILE="/var/run/$DESC.pid"
|
|
PYTHON=`which python`
|
|
# Centos packages openstack_dashboard under /usr/share
|
|
#MANAGE="@PYTHON_SITEPACKAGES@/openstack_dashboard/manage.py"
|
|
MANAGE="/usr/share/openstack-dashboard/manage.py"
|
|
EXEC="/usr/bin/gunicorn"
|
|
BIND="localhost"
|
|
PORT="8080"
|
|
WORKER="eventlet"
|
|
WORKERS=`grep workers /etc/openstack-dashboard/horizon-config.ini | cut -f3 -d' '`
|
|
# Increased timeout to facilitate large image uploads
|
|
TIMEOUT="200"
|
|
STATICDIR="/www/pages/static"
|
|
BRANDDIR="/opt/branding"
|
|
APPLIEDDIR="/opt/branding/applied"
|
|
TMPUPLOADDIR="/scratch/horizon"
|
|
|
|
source /usr/bin/tsconfig
|
|
|
|
start()
|
|
{
|
|
# Change workers if combined controller/compute
|
|
. /etc/platform/platform.conf
|
|
if [ "${WORKERS}" -lt "2" ]; then
|
|
WORKERS=2
|
|
fi
|
|
|
|
if [ -e $PIDFILE ]; then
|
|
PIDDIR=/proc/$(cat $PIDFILE)
|
|
if [ -d ${PIDDIR} ]; then
|
|
echo "$DESC already running."
|
|
return
|
|
else
|
|
echo "Removing stale PID file $PIDFILE"
|
|
rm -f $PIDFILE
|
|
fi
|
|
fi
|
|
|
|
# Clean up any possible orphaned worker threads
|
|
if lsof -t -i:${PORT} 1> /dev/null 2>&1; then
|
|
kill $(lsof -t -i:${PORT}) > /dev/null 2>&1
|
|
fi
|
|
|
|
rm -rf ${TMPUPLOADDIR}
|
|
mkdir -p ${TMPUPLOADDIR}
|
|
|
|
echo -n "Starting $DESC..."
|
|
|
|
start-stop-daemon --start --quiet --background --pidfile ${PIDFILE} \
|
|
--make-pidfile --exec ${PYTHON} -- ${EXEC} --bind ${BIND}:${PORT} \
|
|
--worker-class ${WORKER} --workers ${WORKERS} --timeout ${TIMEOUT} \
|
|
--log-syslog \
|
|
--config '/usr/share/openstack-dashboard/guni_config.py' \
|
|
--pythonpath '/usr/share/openstack-dashboard' \
|
|
openstack_dashboard.wsgi
|
|
RETVAL=$?
|
|
if [ $RETVAL -eq 0 ]; then
|
|
echo "done."
|
|
else
|
|
echo "failed."
|
|
fi
|
|
|
|
# now copy customer branding file to CONFIG_PATH/branding if anything updated
|
|
sm-query service drbd-platform | grep enabled-active > /dev/null 2>&1
|
|
IS_ACTIVE=$?
|
|
|
|
# Handle horizon region exclusions
|
|
if [ $IS_ACTIVE -eq 0 ]; then
|
|
# Only copy if the file has been modified
|
|
if ! cmp --silent ${BRANDDIR}/horizon-region-exclusions.csv ${CONFIG_PATH}/branding/horizon-region-exclusions.csv ; then
|
|
mkdir -p ${CONFIG_PATH}/branding
|
|
cp -r ${BRANDDIR}/horizon-region-exclusions.csv ${CONFIG_PATH}/branding 1>/dev/null 2>&1
|
|
fi
|
|
fi
|
|
|
|
if ls ${BRANDDIR}/*.tgz 1> /dev/null 2>&1; then
|
|
LATESTBRANDING=$(ls $BRANDDIR |grep '\.tgz$' | tail -n 1)
|
|
if [ $IS_ACTIVE -eq 0 ]; then
|
|
# Only do the copy if the tarball has changed
|
|
if ! cmp --silent ${BRANDDIR}/${LATESTBRANDING} ${CONFIG_PATH}/branding/${LATESTBRANDING} ; then
|
|
mkdir -p ${CONFIG_PATH}/branding
|
|
rm -rf ${CONFIG_PATH}/branding/*.tgz
|
|
cp -r ${BRANDDIR}/${LATESTBRANDING} ${CONFIG_PATH}/branding
|
|
fi
|
|
fi
|
|
fi
|
|
|
|
# As part of starting horizon we should kill containerized horizon so that it
|
|
# will pickup branding changes
|
|
kubectl --kubeconfig=/etc/kubernetes/admin.conf delete pods -n openstack -l application=horizon 1>/dev/null
|
|
}
|
|
|
|
stop()
|
|
{
|
|
if [ ! -e $PIDFILE ]; then return; fi
|
|
|
|
echo -n "Stopping $DESC..."
|
|
|
|
start-stop-daemon --stop --quiet --pidfile $PIDFILE
|
|
RETVAL=$?
|
|
if [ $RETVAL -eq 0 ]; then
|
|
echo "done."
|
|
else
|
|
echo "failed."
|
|
fi
|
|
rm -rf ${TMPUPLOADDIR}
|
|
rm -f $PIDFILE
|
|
}
|
|
|
|
status()
|
|
{
|
|
pid=`cat $PIDFILE 2>/dev/null`
|
|
if [ -n "$pid" ]; then
|
|
if ps -p $pid &> /dev/null ; then
|
|
echo "$DESC is running"
|
|
RETVAL=0
|
|
return
|
|
else
|
|
RETVAL=1
|
|
fi
|
|
fi
|
|
echo "$DESC is not running"
|
|
RETVAL=3
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
restart|force-reload|reload)
|
|
stop
|
|
start
|
|
;;
|
|
status)
|
|
status
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|force-reload|restart|reload|status}"
|
|
RETVAL=1
|
|
;;
|
|
esac
|
|
|
|
exit $RETVAL
|