-
Notifications
You must be signed in to change notification settings - Fork 1
/
broadleaf-demo.initscript
61 lines (51 loc) · 1.84 KB
/
broadleaf-demo.initscript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=broadleaf-demo
DESC="Broadleaf Jetty Demo on localhost:8080 (could take several minutes to start)"
PROJECTDIR=/vagrant/eclipse-workspace/DemoSite
JETTY_HOME=/vagrant/eclipse-workspace/DemoSite/site
JETTY_USER=vagrant
PIDFILE=$JETTY_HOME/pidfile
if [ `id -u` -ne 0 ]; then
echo "You need root privileges to run this script"
exit 1
fi
# Make sure jetty is started with system locale
if [ -r /etc/default/locale ]; then
. /etc/default/locale
export LANG
fi
. /lib/lsb/init-functions
if [ -r /etc/default/rcS ]; then
. /etc/default/rcS
fi
##################################################
# Do the action
##################################################
case "$1" in
start)
log_daemon_msg "Starting $DESC." "$NAME"
if [ ! -d "/home/$JETTY_USER/.m2/repository" ]; then
log_daemon_msg "Initializing maven repository."
su $JETTY_USER -c "cd $PROJECTDIR; mvn install"
fi
# running under bash -c exec gives the right pid and allows output to be captured
start-stop-daemon --start --pidfile "$PIDFILE" --chuid "$JETTY_USER" \
--chdir "$JETTY_HOME" --background --make-pidfile \
--startas /bin/bash -- -c "exec /usr/bin/ant jetty-demo > stdout.log 2>&1"
;;
stop)
log_daemon_msg "Stopping $DESC." "$NAME"
cd $JETTY_HOME; ant jetty-stop
# jetty-stop should have stopped it gracefully, but I'm including the daemon approach for good measure / reference
log_progress_msg " (killing) "
start-stop-daemon --stop --signal 9 --oknodo \
--quiet --pidfile "$PIDFILE" \
--user "$JETTY_USER"
;;
*)
log_success_msg "Usage: $0 {start|stop}"
exit 1
;;
esac
exit 0