diff --git a/webservice/spawn.sh b/webservice/spawn.sh new file mode 100644 index 0000000000000000000000000000000000000000..fc95021fb0ca30d7e8247add02f61a03b39c4d6f --- /dev/null +++ b/webservice/spawn.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +trap cleanUp EXIT + +function cleanUp() { + kill $pids +} + + cd /home/datasid/apache-tomcat/bin/ + sh catalina.sh run >> /home/datasid/apache-tomcat/logs/catalina.out 2>&1 & pids=$! + +wait $pids \ No newline at end of file diff --git a/webservice/webservice b/webservice/webservice new file mode 100644 index 0000000000000000000000000000000000000000..5264461522925e1f8d3fffb2771b1fff4928a9a4 --- /dev/null +++ b/webservice/webservice @@ -0,0 +1,57 @@ +#!/bin/bash + +### BEGIN INIT INFO +# Provides: datasid +# Required-Start: $local_fs $named $network +# Required-Stop: $local_fs $named $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: start datasid web portal +# Description: Script to start datasid at boot +### END INIT INFO + +set -e + +DATASID_USER="datasid" +NAME="datasid" +DATASID_PIDFILE="/var/run/$NAME.pid" +DATASID="/home/datasid/spawn.sh" +DATASID_OPTS="" + +do_start () { + printf "Starting WebService datasid\n" + + start-stop-daemon --start --quiet --chuid $DATASID_USER --background \ + --make-pidfile --pidfile $DATASID_PIDFILE --exec $DATASID -- $DATASID_OPTS +} + +do_stop () { + printf "WebService datasid dead\n" + start-stop-daemon --stop --oknodo --pidfile $DATASID_PIDFILE +} + +case "$1" in + start) + do_start + ;; + restart) + do_stop + do_start + ;; + stop) + do_stop + ;; + status) + printf "%-50s" "Checking $NAME..." + if [ -f $DATASID_PIDFILE ]; then + PID=`cat $DATASID_PIDFILE` + if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then + printf "%s\n" "Process dead but pidfile exists" + else + echo "Running" + fi + else + printf "%s\n" "Service not running" + fi + ;; +esac \ No newline at end of file