forked from apache/ofbiz-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc.ofbiz.for.debian
147 lines (136 loc) · 3.62 KB
/
rc.ofbiz.for.debian
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
#####################################################################
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#####################################################################
#
# ofbiz This shell script takes care of starting and stopping
# the OFBiz subsystem. This version is for Debian systems
#
# chkconfig: - 80 10
# description: OFBiz server
### BEGIN INIT INFO
# Provides: OFBiz ERP software
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Apache-OFBiz
# Description: OFBiz ERP Software
### END INIT INFO
# Paths - Edit for your locations
JAVA_BINARY=/usr/java/j2sdk1.4.2/bin/java
OFBIZ_HOME=/home/ofbiz/ofbiz
OFBIZ_LOG=$OFBIZ_HOME/runtime/logs/console.log
# *nix user ofbiz should run as (you must create this user first)
OFBIZ_USER=ofbiz
# OFBiz processes running
ofbizprocs() {
OFBIZ_PROCS=`/bin/ps h -o pid,args -C java | /bin/grep -e "$JAVA_ARGS" | /bin/egrep -o "^[[:space:]]*[[:digit:]]*"`
}
# Checking user...
checkuser() {
if [ "$USER" != "$OFBIZ_USER" ]; then
echo failure
echo
echo "Only users root or $OFBIZ_USER should start/stop the application"
exit 1
fi
}
# Start OFBiz
start() {
echo -n "Starting OFBiz: "
checkuser
ofbizprocs
if [ "$OFBIZ_PROCS" != "" ]; then
echo failure
echo
echo "OFBiz is already running..."
return 1
fi
# All clear
cd $OFBIZ_HOME
umask 007
/bin/rm -f $OFBIZ_LOG
./gradlew ofbiz >>$OFBIZ_LOG 2>>$OFBIZ_LOG&
echo_success
return 0
}
# Stop OFBiz
stop() {
echo -n "Stopping OFBiz: "
checkuser
ofbizprocs
if [ "$OFBIZ_PROCS" == "" ]; then
echo failure
echo
echo "OFBiz is not running..."
return 1
fi
# All clear
cd $OFBIZ_HOME
umask 007
./gradlew "ofbiz --shutdown" >>$OFBIZ_LOG
ofbizprocs
if [ "$OFBIZ_PROCS" != "" ]; then
./gradlew terminateOfbiz
fi
ofbizprocs
if [ "$OFBIZ_PROCS" != "" ]; then
echo_failure
echo
echo "Some processes could not be stopped:"
echo $OFBIZ_PROCS
echo "A possible solution is to try this command once more!"
return 1
else
echo success
return 0
fi
}
# If root is running this script, su to $OFBIZ_USER first
if [ "$USER" = "root" ]; then
exec su - $OFBIZ_USER -c "$0 $1"
fi
case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'status')
ofbizprocs
if [ "$OFBIZ_PROCS" == "" ]; then
echo "OFBiz is stopped"
exit 1
else
echo "OFBiz is running"
exit 0
fi
;;
*)
echo "Usage: $0 {start|stop|kill|restart|status|help}"
exit 1
;;
esac
echo
exit $?