Skip to content

Commit

Permalink
[added] start/stop script for non-systemd environments
Browse files Browse the repository at this point in the history
  • Loading branch information
ckl committed Sep 18, 2015
1 parent 5313904 commit 2db367d
Show file tree
Hide file tree
Showing 3 changed files with 132 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,13 @@ bzw. wenn mehrere Broker genutzt werden sollen:
<!-- ... -->
</monitordconfig>

## Start
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.
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.


Über

/etc/init.d/monitord start

lässt sich monitord starten.
1 change: 1 addition & 0 deletions create-dist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fi
mkdir $TARGET_DIR
cp monitord/monitord $TARGET_DIR
cp monitord/plugins/.libs/libmplugin_activemq.* $TARGET_DIR
cp monitord/scripts/* $TARGET_DIR

# find libactivemq
LIBACTIVEMQ=`ldconfig -p | grep "activemq" | cut -d\> -f2`
Expand Down
122 changes: 122 additions & 0 deletions scripts/monitord-start-stop
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/bin/sh
#
# monitord This is the init script for starting monitord (ZVEI/POCSAG receiver)
#
# chkconfig: - 66 19
# description: monitord
# processname: monitord
# pidfile: /var/run/monitord.pid
#
# basically taken from /etc/init.d/postgresql for CentOS 6.2

# load functions
. /etc/rc.d/init.d/functions

NAME=`basename $0`

if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
then
NAME=${NAME:3}
fi

# SELinux
if [ -x /sbin/runuser ]
then
SU=runuser
else
SU=su
fi

MONITORD=/opt/monitord/monitord
MONITORD_USER=monitord
MONITORD_CONFIG=/opt/monitord/monitord.xml
MONITORD_OPTS=""
MONITORD_STARTUP_LOG=/tmp/monitord-startup.log

if [[ ! -x $MONITORD ]]
then
echo
echo "$MONITORD is missing or not executable"
echo
exit 1
fi

lockfile="/var/lock/subsys/${NAME}"
pidfile="/var/run/monitord.pid"

script_result=0

start() {
if [ -z "$1" ]
then
echo "Waiting 15 seconds for coming up ActiveMQ..."
sleep 15
fi

MONITORD_START="Starting monitord..."
STARTUP_LINE="$MONITORD -c $MONITORD_CONFIG$MONITORD_OPTS"

$SU -c "$STARTUP_LINE &" - $MONITORD_USER >> "$MONITORD_STARTUP_LOG" 2>&1 #< /dev/null
sleep 2
pid=`ps -ef | grep "$STARTUP_LINE" | grep -v "grep" | awk '{ print \$2 }'`

if [ "x$pid" != x ]
then
success "$MONITORD_START"
touch "$lockfile"
echo $pid > "$pidfile"
echo
else
failure "$MONITORD_START"
echo
script_result=1
fi
}

stop() {
echo -n "Stopping monitord service: "
if [ -e "$lockfile" ]
then
kill `cat $pidfile`
ret=$?

if [ $ret -eq 0 ]
then
echo_success
rm -f "$pidfile"
rm -f "$lockfile"
else
echo_failure
script_result=1
fi
else
echo_success
fi
echo
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
start-force)
start now
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 (start|stop|restart)"
exit 2
esac

exit $script_result

0 comments on commit 2db367d

Please sign in to comment.