#!/bin/bash # # Init file for rhnmd daemon # # chkconfig: 2345 99 1 # description: rhnmd server daemon # # processname: rhnmd ### BEGIN INIT INFO # Provides: rhnmd # Required-Start: $local_fs $network $remote_fs # Required-Stop: $local_fs $network $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: rhnmd server daemon # Description: Provides wrapper around sshd # so NOCpulse monitoring can connect to your machine # and run probes, which requires local account. ### END INIT INFO # source function library . /etc/rc.d/init.d/functions RETVAL=0 prog="rhnmd" # Some functions to make the below more readable SU="/sbin/runuser -s /bin/bash - nocpulse -c" SSHD="/usr/sbin/rhnmd" do_restart_sanity_check() { $SU "$SSHD -t -f /etc/nocpulse/rhnmd_config" RETVAL=$? if [ ! "$RETVAL" = 0 ]; then failure $"Configuration file or keys are invalid" echo fi } start() { echo -n $"Starting $prog:" daemon --user nocpulse $SSHD -f /etc/nocpulse/rhnmd_config && success || failure RETVAL=$? [ "$RETVAL" = 0 ] && touch /var/lock/subsys/rhnmd echo } stop() { echo -n $"Stopping $prog:" killproc rhnmd -TERM RETVAL=$? [ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/rhnmd echo } reload() { echo -n $"Reloading $prog:" killproc rhnmd -HUP RETVAL=$? echo } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; reload) reload ;; condrestart) if [ -f /var/lock/subsys/rhnmd ] ; then do_restart_sanity_check if [ "$RETVAL" = 0 ] ; then stop # avoid race sleep 3 start fi fi ;; status) status rhnmd RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" RETVAL=1 esac exit $RETVAL