Skip to content

Commit 2db367d

Browse files
author
ckl
committed
[added] start/stop script for non-systemd environments
1 parent 5313904 commit 2db367d

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,13 @@ bzw. wenn mehrere Broker genutzt werden sollen:
150150
<!-- ... -->
151151
</monitordconfig>
152152

153+
## Start
154+
Das Script *monitord-start-stop* muss nach /etc/init.d/monitord kopiert werden. Standardmäßig läuft monitord unter der Benutzer *monitord*. Dieser muss vorher erstellt worden sein.
155+
Die Datei /etc/init.d/monitord muss angepasst werden, so dass die korrekten Pfade zur ausführbaren Datei von monitord und zur monitord.xml eingetragen worden sind.
153156

157+
158+
Über
159+
160+
/etc/init.d/monitord start
161+
162+
lässt sich monitord starten.

create-dist.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fi
1717
mkdir $TARGET_DIR
1818
cp monitord/monitord $TARGET_DIR
1919
cp monitord/plugins/.libs/libmplugin_activemq.* $TARGET_DIR
20+
cp monitord/scripts/* $TARGET_DIR
2021

2122
# find libactivemq
2223
LIBACTIVEMQ=`ldconfig -p | grep "activemq" | cut -d\> -f2`

scripts/monitord-start-stop

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/sh
2+
#
3+
# monitord This is the init script for starting monitord (ZVEI/POCSAG receiver)
4+
#
5+
# chkconfig: - 66 19
6+
# description: monitord
7+
# processname: monitord
8+
# pidfile: /var/run/monitord.pid
9+
#
10+
# basically taken from /etc/init.d/postgresql for CentOS 6.2
11+
12+
# load functions
13+
. /etc/rc.d/init.d/functions
14+
15+
NAME=`basename $0`
16+
17+
if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
18+
then
19+
NAME=${NAME:3}
20+
fi
21+
22+
# SELinux
23+
if [ -x /sbin/runuser ]
24+
then
25+
SU=runuser
26+
else
27+
SU=su
28+
fi
29+
30+
MONITORD=/opt/monitord/monitord
31+
MONITORD_USER=monitord
32+
MONITORD_CONFIG=/opt/monitord/monitord.xml
33+
MONITORD_OPTS=""
34+
MONITORD_STARTUP_LOG=/tmp/monitord-startup.log
35+
36+
if [[ ! -x $MONITORD ]]
37+
then
38+
echo
39+
echo "$MONITORD is missing or not executable"
40+
echo
41+
exit 1
42+
fi
43+
44+
lockfile="/var/lock/subsys/${NAME}"
45+
pidfile="/var/run/monitord.pid"
46+
47+
script_result=0
48+
49+
start() {
50+
if [ -z "$1" ]
51+
then
52+
echo "Waiting 15 seconds for coming up ActiveMQ..."
53+
sleep 15
54+
fi
55+
56+
MONITORD_START="Starting monitord..."
57+
STARTUP_LINE="$MONITORD -c $MONITORD_CONFIG$MONITORD_OPTS"
58+
59+
$SU -c "$STARTUP_LINE &" - $MONITORD_USER >> "$MONITORD_STARTUP_LOG" 2>&1 #< /dev/null
60+
sleep 2
61+
pid=`ps -ef | grep "$STARTUP_LINE" | grep -v "grep" | awk '{ print \$2 }'`
62+
63+
if [ "x$pid" != x ]
64+
then
65+
success "$MONITORD_START"
66+
touch "$lockfile"
67+
echo $pid > "$pidfile"
68+
echo
69+
else
70+
failure "$MONITORD_START"
71+
echo
72+
script_result=1
73+
fi
74+
}
75+
76+
stop() {
77+
echo -n "Stopping monitord service: "
78+
if [ -e "$lockfile" ]
79+
then
80+
kill `cat $pidfile`
81+
ret=$?
82+
83+
if [ $ret -eq 0 ]
84+
then
85+
echo_success
86+
rm -f "$pidfile"
87+
rm -f "$lockfile"
88+
else
89+
echo_failure
90+
script_result=1
91+
fi
92+
else
93+
echo_success
94+
fi
95+
echo
96+
}
97+
98+
restart() {
99+
stop
100+
start
101+
}
102+
103+
case "$1" in
104+
start)
105+
start
106+
;;
107+
start-force)
108+
start now
109+
;;
110+
stop)
111+
stop
112+
;;
113+
restart)
114+
restart
115+
;;
116+
*)
117+
echo $"Usage: $0 (start|stop|restart)"
118+
exit 2
119+
esac
120+
121+
exit $script_result
122+

0 commit comments

Comments
 (0)