This repository was archived by the owner on Nov 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstartup.sh
More file actions
executable file
·60 lines (52 loc) · 1.45 KB
/
startup.sh
File metadata and controls
executable file
·60 lines (52 loc) · 1.45 KB
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/bash
cd $(dirname $0)
source settings.sh
if [ -n "$PID_FILE" -a -e "$PID_FILE" ]; then
echo "Zabbix Java Gateway is already running"
exit 1
fi
JAVA=${JAVA:-java}
JAVA_OPTIONS="-server"
if [ -z "$PID_FILE" ]; then
JAVA_OPTIONS="$JAVA_OPTIONS -Dlogback.configurationFile=logback-console.xml"
fi
CLASSPATH="lib:bin"
for jar in {lib,bin}/*.jar; do
if [[ $jar != *junit* ]]; then
CLASSPATH="$CLASSPATH:$jar"
fi
done
ZABBIX_OPTIONS=""
if [ -n "$API_USER" ]; then
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.apiUser=$API_USER"
fi
if [ -n "$API_PASSWORD" ]; then
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.apiPassword=$API_PASSWORD"
fi
if [ -n "$ZABBIX_URL" ]; then
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.zabbixUrl=$ZABBIX_URL"
fi
if [ -n "$PID_FILE" ]; then
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.pidFile=$PID_FILE"
fi
if [ -n "$LISTEN_IP" ]; then
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.listenIP=$LISTEN_IP"
fi
if [ -n "$LISTEN_PORT" ]; then
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.listenPort=$LISTEN_PORT"
fi
if [ -n "$START_POLLERS" ]; then
ZABBIX_OPTIONS="$ZABBIX_OPTIONS -Dzabbix.startPollers=$START_POLLERS"
fi
COMMAND_LINE="$JAVA $JAVA_OPTIONS -classpath $CLASSPATH $ZABBIX_OPTIONS com.zabbix.gateway.JavaGateway"
if [ -n "$PID_FILE" ]; then
PID=$(/bin/bash -c "$COMMAND_LINE > /dev/null 2>&1 & echo \$!")
if ps -p $PID > /dev/null 2>&1; then
echo $PID > $PID_FILE
else
echo "Zabbix Java Gateway did not start"
exit 1
fi
else
exec $COMMAND_LINE
fi