Skip to content

Instantly share code, notes, and snippets.

@k14i
Created August 25, 2013 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k14i/6334693 to your computer and use it in GitHub Desktop.
Save k14i/6334693 to your computer and use it in GitHub Desktop.
A /etc/init.d script for starting/stopping CloudStack Client UI.
#!/bin/bash
#
### BEGIN INIT INFO
# Provides: cloud-client-ui
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $network $time
# Should-Stop: $network $time
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
#
set -e
set -u
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}
test -d /root/cloudstack || exit 0
. /lib/lsb/init-functions
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
# Safeguard (relative paths, core dumps..)
cd /
umask 077
#
# main()
#
case "${1:-''}" in
'start')
pid=`ps -ef | grep cloudstack | grep jetty | grep -v grep | awk '{print $2}'`
if test x$pid == x; then
echo "Starting cloudstack"
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=800m -Xmx1g -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
cd /root/cloudstack
mvn -pl :cloud-client-ui jetty:run > /dev/null 2>&1 &
else
echo "cloudstack is already running. pid = $pid"
fi
;;
'stop')
pid=`ps -ef | grep cloudstack | grep jetty | grep -v grep | awk '{print $2}'`
if test x$pid == x; then
echo "No cloudstack process is running."
else
echo "Stopping cloudstack (pid = $pid)"
kill $pid
if test $? -ne 0; then
echo "Stopping cloudstack failed. Force stopping."
kill -9 $pid
fi
fi
;;
'restart')
stop
start
;;
'status')
pid=`ps -ef | grep cloudstack | grep jetty | grep -v grep | awk '{print $2}'`
if test x$pid == x; then
echo "No cloudstack process is running."
else
echo "cloudstack is running. pid = $pid"
fi
;;
*)
echo "Usage: $SELF start|stop|restart|status"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment