check_oracle_health: update to 1.9
[omd.git] / packages / omd / skel / etc / init.d / xinetd
blob370055a9d1243ff2ceb004e4658979f7c327bb85
1 #!/bin/bash
3 # Start only if at least on xinetd based service
4 # is activated
6 test "$(ls -A ###ROOT###/etc/xinetd.d/)" || exit 5
8 PIDFILE=###ROOT###/tmp/run/xinetd.pid
9 DAEMON=/usr/sbin/xinetd
10 OPTS="-pidfile ###ROOT###/tmp/run/xinetd.pid -filelog ###ROOT###/var/log/xinetd.log -f ###ROOT###/etc/xinetd.conf"
12 case "$1" in
13 start)
14 echo -n 'Starting xinetd...'
15 if [ -e "$PIDFILE" ] ; then
16 PID=$(cat $PIDFILE)
17 if [ -n "$PID" ] && ps $PID > /dev/null 2>&1 ; then
18 echo "still running with pid $PID! Aborting!"
19 exit 1
21 echo "removing stale pid file..."
22 rm -f $PIDFILE
25 # Do not use usual system daemon path. Some start script
26 # (e.g. SLES) will think that the system xinetd is already
27 # running and do not start it if the OMD xinetd is running.
28 mkdir -p $OMD_ROOT/var/tmp
29 cp $DAEMON $OMD_ROOT/var/tmp/xinetd
30 $OMD_ROOT/var/tmp/xinetd $OPTS
31 echo OK
33 stop)
34 echo -n 'Stopping xinetd...'
35 PID=$(cat $PIDFILE 2>/dev/null)
36 if [ -z "$PID" ] ; then
37 echo "not running."
38 elif kill "$PID" ; then
39 echo "OK"
40 else
41 echo "Failed"
43 rm -f $OMD_ROOT/var/tmp/xinetd
45 restart)
46 $0 stop
47 $0 start
49 reload)
50 echo -n 'Reloading xinetd...'
51 if [ -e "$PIDFILE" ] ; then
52 PID=$(cat $PIDFILE)
53 if kill -HUP $PID
54 then
55 echo OK
56 else
57 echo ERROR
58 exit 1
60 else
61 echo "not running"
62 exit 1
65 status)
66 echo -n 'Checking status of xinetd...'
67 if [ -e "$PIDFILE" ] ; then
68 PID=$(cat $PIDFILE)
69 if [ -n "$PID" ] && ps $PID > /dev/null 2>&1 ; then
70 echo "running"
71 exit 0
74 echo "stopped"
75 exit 1
78 echo "Usage: $0 {start|stop|restart|reload|status}"
80 esac