mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
131 lines
2.2 KiB
Bash
Executable File
131 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
### BEGIN INIT INFO
|
|
# Provides: cloud
|
|
# Required-Start: mountkernfs $local_fs cloud-early-config
|
|
# Required-Stop: $local_fs
|
|
# Should-Start:
|
|
# Should-Stop:
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: Start up the cloud.com service
|
|
### END INIT INFO
|
|
|
|
#set -x
|
|
|
|
ENABLED=0
|
|
[ -e /etc/default/cloud ] && . /etc/default/cloud
|
|
|
|
CMDLINE=$(cat /var/cache/cloud/cmdline)
|
|
|
|
TYPE="router"
|
|
for i in $CMDLINE
|
|
do
|
|
# search for foo=bar pattern and cut out foo
|
|
FIRSTPATTERN=$(echo $i | cut -d= -f1)
|
|
case $FIRSTPATTERN in
|
|
type)
|
|
TYPE=$(echo $i | cut -d= -f2)
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# Source function library.
|
|
if [ -f /etc/init.d/functions ]
|
|
then
|
|
. /etc/init.d/functions
|
|
fi
|
|
|
|
if [ -f ./lib/lsb/init-functions ]
|
|
then
|
|
. /lib/lsb/init-functions
|
|
fi
|
|
|
|
_success() {
|
|
if [ -f /etc/init.d/functions ]
|
|
then
|
|
success
|
|
else
|
|
echo "Success"
|
|
fi
|
|
}
|
|
|
|
_failure() {
|
|
if [ -f /etc/init.d/functions ]
|
|
then
|
|
failure
|
|
else
|
|
echo "Failed"
|
|
fi
|
|
}
|
|
RETVAL=$?
|
|
CLOUD_COM_HOME="/usr/local/cloud"
|
|
|
|
# mkdir -p /var/log/vmops
|
|
|
|
get_pids() {
|
|
local i
|
|
for i in $(ps -ef| grep java | grep -v grep | awk '{print $2}');
|
|
do
|
|
echo $(pwdx $i) | grep "$CLOUD_COM_HOME" | awk -F: '{print $1}';
|
|
done
|
|
}
|
|
|
|
start() {
|
|
local pid=$(get_pids)
|
|
echo -n "Starting cloud.com service (type=$TYPE) "
|
|
if [ -f $CLOUD_COM_HOME/systemvm/run.sh ];
|
|
then
|
|
if [ "$pid" == "" ]
|
|
then
|
|
(cd $CLOUD_COM_HOME/systemvm; nohup ./run.sh > /var/log/cloud/cloud.out 2>&1 & )
|
|
pid=$(get_pids)
|
|
echo $pid > /var/run/cloud.pid
|
|
fi
|
|
_success
|
|
else
|
|
_failure
|
|
fi
|
|
echo
|
|
}
|
|
|
|
stop() {
|
|
local pid
|
|
echo -n "Stopping cloud.com service (type=$TYPE): "
|
|
for pid in $(get_pids)
|
|
do
|
|
kill $pid
|
|
done
|
|
_success
|
|
echo
|
|
}
|
|
|
|
status() {
|
|
local pids=$(get_pids)
|
|
if [ "$pids" == "" ]
|
|
then
|
|
echo "cloud.com service is not running"
|
|
return 1
|
|
fi
|
|
echo "cloud.com service (type=$TYPE) is running: process id: $pids"
|
|
return 0
|
|
}
|
|
|
|
[ "$ENABLED" != 0 ] || exit 0
|
|
|
|
case "$1" in
|
|
start) start
|
|
;;
|
|
stop) stop
|
|
;;
|
|
status) status
|
|
;;
|
|
restart) stop
|
|
start
|
|
;;
|
|
*) echo "Usage: $0 {start|stop|status|restart}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit $RETVAL
|