1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

separate novnc from sunstone to implement an dedicated init script for nonvnc

This commit is contained in:
Arnold Bechtoldt 2014-05-01 21:30:07 +02:00
parent 6cecb17f2d
commit 4c23f50044
5 changed files with 216 additions and 16 deletions

View File

@ -0,0 +1,105 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: opennebula-novnc
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: novnc init script
# Description: OpenNebula novnc server
### END INIT INFO
# Author: Arnold Bechtoldt <mail@arnoldbechtoldt.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="OpenNebula novnc server"
NAME=opennebula-novnc
DAEMON=/usr/bin/$NAME
DAEMON_ARGS=""
SCRIPTNAME=/etc/init.d/novnc-server
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
mkdir -p /var/lock/one /var/log/one
chown oneadmin /var/lock/one /var/log/one
su oneadmin -s /bin/sh -c "$DAEMON start"
}
#
# Function that retrives the status of the daemon/service
#
do_status()
{
su oneadmin -s /bin/sh -c "$DAEMON status"
}
#
# Function that stops the daemon/service
#
do_stop()
{
su oneadmin -s /bin/sh -c "$DAEMON stop"
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
do_status && exit 0 || exit $?
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
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
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -13,7 +13,7 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Sunstone Web interface"
NAME=sunstone-server
NAME=opennebula-sunstone
DAEMON=/usr/bin/$NAME
DAEMON_ARGS=""
SCRIPTNAME=/etc/init.d/$NAME
@ -33,6 +33,7 @@ SCRIPTNAME=/etc/init.d/$NAME
#
do_start()
{
service opennebula-novnc start || exit $?
mkdir -p /var/run/one /var/lock/one /var/log/one
chown oneadmin /var/run/one /var/lock/one /var/log/one
su oneadmin -s /bin/sh -c "$DAEMON start"
@ -44,6 +45,7 @@ do_start()
do_stop()
{
su oneadmin -s /bin/sh -c "$DAEMON stop"
service opennebula-novnc stop || exit $?
}
case "$1" in

View File

@ -0,0 +1,105 @@
#! /bin/sh
### BEGIN INIT INFO
# Provides: opennebula-novnc
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: novnc init script
# Description: OpenNebula novnc server
### END INIT INFO
# Author: Arnold Bechtoldt <mail@arnoldbechtoldt.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="OpenNebula novnc server"
NAME=opennebula-novnc
DAEMON=/usr/bin/$NAME
DAEMON_ARGS=""
SCRIPTNAME=/etc/init.d/novnc-server
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
#
# Function that starts the daemon/service
#
do_start()
{
mkdir -p /var/lock/one /var/log/one
chown oneadmin /var/lock/one /var/log/one
su oneadmin -s /bin/sh -c "$DAEMON start"
}
#
# Function that retrives the status of the daemon/service
#
do_status()
{
su oneadmin -s /bin/sh -c "$DAEMON status"
}
#
# Function that stops the daemon/service
#
do_stop()
{
su oneadmin -s /bin/sh -c "$DAEMON stop"
}
case "$1" in
start)
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
status)
do_status && exit 0 || exit $?
;;
stop)
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
esac
;;
restart|force-reload)
#
# If the "reload" option is implemented then remove the
# 'force-reload' alias
#
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
;;
*)
# Failed to stop
log_end_msg 1
;;
esac
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
exit 3
;;
esac
:

View File

@ -13,7 +13,7 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Sunstone Web interface"
NAME=sunstone-server
NAME=opennebula-sunstone
DAEMON=/usr/bin/$NAME
DAEMON_ARGS=""
SCRIPTNAME=/etc/init.d/$NAME
@ -33,6 +33,7 @@ SCRIPTNAME=/etc/init.d/$NAME
#
do_start()
{
service opennebula-novnc start || exit $?
mkdir -p /var/run/one /var/lock/one /var/log/one
chown oneadmin /var/run/one /var/lock/one /var/log/one
su oneadmin -s /bin/sh -c "$DAEMON start"
@ -44,6 +45,7 @@ do_start()
do_stop()
{
su oneadmin -s /bin/sh -c "$DAEMON stop"
service opennebula-novnc stop || exit $?
}
case "$1" in

View File

@ -24,7 +24,6 @@ if [ -z "$ONE_LOCATION" ]; then
SUNSTONE_LOG=/var/log/one/sunstone.log
SUNSTONE_LOG_ERROR=/var/log/one/sunstone.error
SUNSTONE_CONF=/etc/one/sunstone-server.conf
NOVNC_SERVER=/usr/bin/novnc-server
else
SUNSTONE_PID=$ONE_LOCATION/var/sunstone.pid
SUNSTONE_SERVER=$ONE_LOCATION/lib/sunstone/sunstone-server.rb
@ -32,7 +31,6 @@ else
SUNSTONE_LOG=$ONE_LOCATION/var/sunstone.log
SUNSTONE_LOG_ERROR=$ONE_LOCATION/var/sunstone.error
SUNSTONE_CONF=$ONE_LOCATION/etc/sunstone-server.conf
NOVNC_SERVER=$ONE_LOCATION/bin/novnc-server
fi
setup()
@ -67,13 +65,6 @@ start()
exit 1
fi
# Start novnc server
$NOVNC_SERVER start
if [ "$?" != "0" ]; then
echo "Could not start novnc server" 1>&2
fi
# Start the sunstone daemon
touch $SUNSTONE_LOCK_FILE
ruby $SUNSTONE_SERVER > $SUNSTONE_LOG 2>$SUNSTONE_LOG_ERROR &
@ -82,7 +73,6 @@ start()
if [ $? -ne 0 ]; then
echo "Error executing sunstone-server."
echo "Check $SUNSTONE_LOG_ERROR and $SUNSTONE_LOG for more information"
$NOVNC_SERVER stop
exit 1
else
echo $LASTPID > $SUNSTONE_PID
@ -94,7 +84,6 @@ start()
if [ $? -ne 0 ]; then
echo "Error executing sunstone-server."
echo "Check $SUNSTONE_LOG_ERROR and $SUNSTONE_LOG for more information"
$NOVNC_SERVER stop
exit 1
fi
@ -106,9 +95,6 @@ start()
#
stop()
{
# Stop novnc server
$NOVNC_SERVER stop
if [ ! -f $SUNSTONE_PID ]; then
echo "Couldn't find sunstone-server process pid."
exit 1