summaryrefslogtreecommitdiffstats
path: root/abs/core/mdadm/mdadm
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2012-08-07 17:36:10 (GMT)
committerJames Meyer <james.meyer@operamail.com>2012-08-07 17:36:10 (GMT)
commit9bf6461124e215b2cbff57dd0f514dac5dfc0174 (patch)
tree214ec9084a8122b167d316c49f34072d25c3a008 /abs/core/mdadm/mdadm
parentd959d709bde5168e9d8bbfba7affd622ced1e6b4 (diff)
downloadlinhes_pkgbuild-9bf6461124e215b2cbff57dd0f514dac5dfc0174.zip
linhes_pkgbuild-9bf6461124e215b2cbff57dd0f514dac5dfc0174.tar.gz
linhes_pkgbuild-9bf6461124e215b2cbff57dd0f514dac5dfc0174.tar.bz2
mdadm 3.2.5
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