1 |
slords |
1.1 |
#!/bin/bash |
2 |
|
|
# |
3 |
|
|
# mdmdp This starts, stops, and reloads the mdmpd-based |
4 |
|
|
# multipath device monitoring and management facility |
5 |
|
|
# |
6 |
|
|
# chkconfig: - 15 85 |
7 |
|
|
# description: multipath device monitoring and management |
8 |
|
|
# |
9 |
slords |
1.2 |
# Copyright 2002 Red Hat, Inc. |
10 |
|
|
# |
11 |
|
|
### BEGIN INIT INFO |
12 |
|
|
# Default-Start: |
13 |
|
|
# Default-Stop: 0 1 2 3 4 5 6 |
14 |
|
|
# Short-Description: Start and stop the MD multipath monitor |
15 |
|
|
# Description: The mdmpd service checks the status of all MD based multipath |
16 |
|
|
# devices on the system. If a path to a device goes down, it removes |
17 |
|
|
# that path from the md multipath array. It also periodically attempts |
18 |
|
|
# to contact the device via the down path. When it succeeds repeatedly, |
19 |
|
|
# it re-adds the downed path to the multipath array. There is a roughly |
20 |
|
|
# 60 second delay between when a path becomes live again and when mdmpd |
21 |
|
|
# adds it back into service. |
22 |
|
|
### END INIT INFO |
23 |
slords |
1.1 |
|
24 |
|
|
|
25 |
|
|
PATH=/sbin:/usr/sbin:$PATH |
26 |
|
|
RETVAL=0 |
27 |
|
|
|
28 |
|
|
prog=mdmpd |
29 |
|
|
|
30 |
|
|
# Source function library. |
31 |
|
|
. /etc/rc.d/init.d/functions |
32 |
|
|
|
33 |
|
|
# Make sure configuration file exists and has information we can use |
34 |
|
|
# MAILADDR or PROGRAM or both must be set in order to run mdadm --monitor |
35 |
|
|
#[ -f /etc/mdadm.conf ] || exit 0 |
36 |
|
|
#grep '^\(MAILADDR\|PROGRAM\) .' /etc/mdadm.conf >/dev/null 2>&1 || exit 0 |
37 |
|
|
|
38 |
|
|
|
39 |
|
|
usage () |
40 |
|
|
{ |
41 |
|
|
echo "Usage: service $prog {start|stop|status|restart|condrestart}" |
42 |
|
|
RETVAL=1 |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
|
46 |
|
|
start () |
47 |
|
|
{ |
48 |
slords |
1.2 |
[ `id -u` -eq 0 ] || return 4 |
49 |
|
|
[ -x /sbin/mdmpd ] || return 1 |
50 |
|
|
[ -f /var/lock/subsys/$prog ] && return 0 |
51 |
slords |
1.1 |
ulimit -S -c 0 >/dev/null 2>&1 |
52 |
|
|
# clean up in case we went down unexpectedly |
53 |
|
|
rm -f /var/run/$prog/* |
54 |
|
|
echo -n $"Starting $prog: " |
55 |
|
|
daemon mdmpd |
56 |
|
|
# hack: wait for mdadm to die, assume success if it doesn't die quickly |
57 |
|
|
usleep 100000 |
58 |
|
|
pid=`pidof -o $$ -o $PPID -o %PPID -x $prog` |
59 |
|
|
if [ -n "$pid" ] ; then |
60 |
slords |
1.2 |
echo_success |
61 |
slords |
1.1 |
touch /var/lock/subsys/$prog |
62 |
|
|
echo "$pid" > /var/run/$prog.pid |
63 |
|
|
RETVAL=0 |
64 |
|
|
else |
65 |
slords |
1.2 |
echo_failure |
66 |
slords |
1.1 |
RETVAL=1 |
67 |
|
|
fi |
68 |
|
|
echo |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
stop () |
72 |
|
|
{ |
73 |
slords |
1.2 |
[ `id -u` -eq 0 ] || return 4 |
74 |
|
|
[ ! -f /var/lock/subsys/$prog ] && return 0 |
75 |
slords |
1.1 |
echo -n $"Stopping $prog: " |
76 |
|
|
killproc $prog |
77 |
|
|
echo |
78 |
|
|
rm -f /var/run/$prog.pid |
79 |
|
|
rm -f /var/lock/subsys/$prog |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
restart () |
83 |
|
|
{ |
84 |
|
|
stop |
85 |
|
|
start |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
condrestart () |
89 |
|
|
{ |
90 |
slords |
1.2 |
[ -e /var/lock/subsys/$prog ] && restart || return 0 |
91 |
slords |
1.1 |
} |
92 |
|
|
|
93 |
|
|
|
94 |
|
|
case "$1" in |
95 |
slords |
1.2 |
start) start; RETVAL=$? ;; |
96 |
|
|
stop) stop; RETVAL=$? ;; |
97 |
|
|
status) status $prog; RETVAL=$? ;; |
98 |
|
|
restart|force-reload) restart; RETVAL=$? ;; |
99 |
|
|
condrestart|try-restart|reload) condrestart; RETVAL=$? ;; |
100 |
|
|
*) usage; RETVAL=2 ;; |
101 |
slords |
1.1 |
esac |
102 |
|
|
|
103 |
|
|
exit $RETVAL |