summaryrefslogtreecommitdiffstats
path: root/abs/core/mdadm/mdadm
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/mdadm/mdadm')
-rwxr-xr-xabs/core/mdadm/mdadm31
1 files changed, 18 insertions, 13 deletions
diff --git a/abs/core/mdadm/mdadm b/abs/core/mdadm/mdadm
index e196f36..9bf468e 100755
--- a/abs/core/mdadm/mdadm
+++ b/abs/core/mdadm/mdadm
@@ -3,28 +3,33 @@
. /etc/rc.conf
. /etc/rc.d/functions
-PID=`pidof -o %PPID /sbin/mdadm`
-case "$1" in
+pidfile=/run/mdadm.pid
+if [[ -r $pidfile ]]; then
+ read -r PID <"$pidfile"
+ if [[ $PID && ! -d /proc/$PID ]]; then
+ # stale pidfile
+ unset PID
+ rm -f "$pidfile"
+ fi
+fi
+
+case $1 in
start)
stat_busy "Starting mdadm RAID Monitor"
- if [ -z "$PID" ]; then
- /sbin/mdadm --monitor --scan -i /var/run/mdadm.pid -f
- fi
- if [ ! -z "$PID" -o $? -gt 0 ]; then
- stat_fail
- else
+ if [[ -z $PID ]] && mdadm --monitor --scan -i "$pidfile" -f; then
add_daemon mdadm
stat_done
+ else
+ stat_fail
fi
;;
stop)
stat_busy "Stopping mdadm RAID Monitor"
- [ ! -z "$PID" ] && kill $PID &>/dev/null
- if [ $? -gt 0 ]; then
- stat_fail
- else
+ if [[ $PID ]] && kill "$PID" &>/dev/null; then
rm_daemon mdadm
stat_done
+ else
+ stat_fail
fi
;;
restart)
@@ -33,5 +38,5 @@ case "$1" in
$0 start
;;
*)
- echo "usage: $0 {start|stop|restart}"
+ echo "usage: $0 {start|stop|restart}"
esac