blob: 837b7b96e444f6dd95d24f9bef4cee0ead446024 (
plain)
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
|
#!/bin/bash
BRMSGW_BASE=${POLICY_HOME}/servers/brmsgw/
COMPONENT=brmsgw
brmsgw_RUNNING="pgrep -f "${BRMSGW_BASE}""
RETVAL=0
function update_monitor() {
COMPONENT=$1
STATUS=$2
if [[ -f ${POLICY_HOME}/etc/monitor/monitor.cfg ]]; then
/bin/sed -i.bak \
-e "s/^${COMPONENT}=.*/${COMPONENT}=${STATUS}/g" \
${POLICY_HOME}/etc/monitor/monitor.cfg
fi
}
# unmonitored stop, does not change monitor status (immutable)
function um_stop() {
pid=$(pgrep -f "${BRMSGW_BASE}" 2> /dev/null)
kill -9 "${pid}"
RETVAL=$?
}
function stop() {
um_stop
if [[ ${RETVAL} != 0 ]]; then
update_monitor ${COMPONENT} on
else
update_monitor ${COMPONENT} off
fi
}
# unmonitored start, does not change monitor status (immutable)
function um_start() {
unset JMX_JAVA_OPTS JVM_SECURITY CMD_JAVA_OPTS
JMX_JAVA_OPTS+=("-Dcom.sun.management.jmxremote")
JMX_JAVA_OPTS+=("-Dcom.sun.management.jmxremote.port=$BRMSGW_JMX_PORT")
JMX_JAVA_OPTS+=("-Dcom.sun.management.jmxremote.ssl=false")
JMX_JAVA_OPTS+=("-Dcom.sun.management.jmxremote.authenticate=false")
JVM_JAVA_OPTS=("-Xms${COMPONENT_X_MS_MB}M" "-Xmx${COMPONENT_X_MX_MB}M")
JVM_SECURITY+=("-Djavax.net.ssl.keyStore=${POLICY_HOME}/etc/ssl/policy-keystore")
JVM_SECURITY+=("-Djavax.net.ssl.keyStorePassword=${KEYSTORE_PASSWD}")
JVM_SECURITY+=("-Djavax.net.ssl.trustStore=${POLICY_HOME}/etc/ssl/policy-truststore")
JVM_SECURITY+=("-Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWD}")
CMD_JAVA_OPTS+=("-DPOLICY_LOGS=${POLICY_LOGS}")
JAVA_OPTS=("${JVM_JAVA_OPTS[@]}" "${JMX_JAVA_OPTS[@]}" "${JVM_SECURITY[@]}" "${CMD_JAVA_OPTS[@]}")
cd $POLICY_HOME/servers/brmsgw
mkdir -p $POLICY_LOGS/policy/brmsgw 2>/dev/null
nohup $JAVA_HOME/bin/java -jar "${JAVA_OPTS[@]}" $POLICY_HOME/servers/brmsgw/BRMSGateway.jar>> $POLICY_LOGS/policy/brmsgw/brmsgw.log 2>&1 &
RETVAL=$?
}
function start() {
um_start
if [[ ${RETVAL} != 0 ]]; then
update_monitor ${COMPONENT} off
else
update_monitor ${COMPONENT} on
fi
}
function status() {
# check status
pid=$(pgrep -f "${BRMSGW_BASE}" 2> /dev/null)
RETVAL=$?
# If the PID was returned means the application is running
if [ ${RETVAL} -eq 0 ]; then
echo "running with pid ${pid}"
else
echo "stopped"
fi
}
# main
COMPONENT=$(basename $0)
CONF_FILE="${POLICY_HOME}/servers/${COMPONENT}/config.properties"
# read properties
shopt -s extglob
configfile="dos_or_unix" # set the actual path name of your (DOS or Unix) config file
while IFS='= ' read lhs rhs
do
if [[ ! $lhs =~ ^\ *# && -n $lhs ]]; then
rhs="${rhs%%\#*}" # Del in line right comments
rhs="${rhs%%*( )}" # Del trailing spaces
rhs="${rhs%\"*}" # Del opening string quotes
rhs="${rhs#\"*}" # Del closing string quotes
if [[ $lhs != *"."* ]]; then
declare $lhs="$rhs"
fi
fi
done < "${CONF_FILE}"
if [ $? -ne 0 ]; then
echo "error: cannot source configuration ${CONF_FILE}"
exit 1
fi
case "$1" in
status)
status
;;
restart)
stop
sleep 2
start
;;
start)
start
;;
umstart)
um_start
;;
stop)
stop
;;
umstop)
um_stop
;;
*)
echo "error: invalid option $@"
RETVAL=1
;;
esac
exit ${RETVAL}
|