forked from noha/stone-creator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-stop-script
109 lines (94 loc) · 2.32 KB
/
start-stop-script
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
### BEGIN INIT INFO
# Provides: stone
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: stone
# Description: Starts stone
#
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. $STONE_ENV
# PATH should only include /usr/* if it runs after the mountnfs.sh script
DESC="stone"
NAME=$APPLICATION_NAME
SCRIPTNAME=/etc/init.d/$NAME
RUNASUSER=$GEMSTONE_USER
STONE_ENV=$APPLICATION_DIR/env
# exit if no user is set
if [ ! $RUNASUSER ] ;
then
echo "RUNASUSER NOT SET"
exit 3
fi
# source the seaside environment if it exists
if [ ! -r $STONE_ENV ] ;
then
echo "Seaside ENV script doesnt exists at $STONE_ENV"
exit 3
fi
. $STONE_ENV
# Function that starts the daemon/service
do_start()
{
if [ ! -d "$GEMSTONE_LOGDIR/old" ];
then
mkdir "$GEMSTONE_LOGDIR/old" > /dev/null 2>&1
fi
mv $GEMSTONE_LOGDIR/* "$GEMSTONE_LOGDIR/old" > /dev/null 2>&1
su -m $RUNASUSER -c '$GEMSTONE_INSTALLATION/bin/startstone -z $GEMSTONE_SYS_CONF -l $APPLICATION_LOG_DIR/log.txt $APPLICATION_NAME' > $GEMSTONE_LOGDIR/startup.log 2>&1
}
# Function that stops the daemon/service
do_stop()
{
su -m $RUNASUSER -c '$GEMSTONE_INSTALLATION/bin/stopstone -i $APPLICATION_NAME DataCurator swordfish' > $GEMSTONE_LOGDIR/shutdown.log 2>&1
}
case "$1" in
start)
[ "$VERBOSE" != no ] && echo "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && exit 0 ;;
3) [ "$VERBOSE" != no ] && echo "failed" && exit 1 ;;
esac
;;
stop)
[ "$VERBOSE" != no ] && echo "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && exit 0 ;;
2) [ "$VERBOSE" != no ] && exit 1 ;;
esac
;;
restart|force-reload|reload)
# If the "reload" option is implemented then remove the
# 'force-reload' alias
echo "Restarting $DESC" "$NAME" "NO Reload for $NAME"
do_stop
case "$?" in
0|1)
do_start
case "$?" in
0) exit 0 ;;
1) exit 1 ;; # Old process is still running
*) exit 1 ;; # Failed to start
esac
;;
*)
# Failed to stop
exit 1
;;
esac
;;
status)
/opt/gemstone/product/bin/gslist -lcv
exit 3
;;
*)
log_action_msg "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload|status}" >&2
exit 3
;;
esac
: