#! /bin/sh # # hdapsd HDAPS monitoring service # # chkconfig: - 44 56 # description: Protect HDD from physical shock using accelerometer # processname: hdapsd # pidfile: /var/run/hdapsd.pid # config: /etc/sysconfig/hdapsd # # Do not load RH compatibility interface. WITHOUT_RC_COMPAT=1 # Source function library. . /etc/init.d/functions # Source config. SourceIfNotEmpty /etc/sysconfig/hdapsd HDAPS_DEVICE="sda" HDAPS_SENSITIVITY=15 PIDFILE=/var/run/hdapsd.pid LOCKFILE=/var/lock/subsys/hdapsd RETVAL=0 start () { [ ! -f /sys/devices/platform/hdaps/position ] \ && modprobe hdaps \ && [ ! -f /sys/devices/platform/hdaps/position ] \ && return 1 start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- \ hdapsd -d "$HDAPS_DEVICE" -s "$HDAPS_SENSITIVITY" $HDAPS_OPTIONS -b RETVAL=$? return $RETVAL } stop () { stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- hdapsd RETVAL=$? return $RETVAL } restart () { stop start } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart|reload) restart ;; condstop) if [ -e "$LOCKFILE" ]; then stop fi ;; condrestart|condreload) if [ -e "$LOCKFILE" ]; then restart fi ;; status) status --pidfile "$PIDFILE" --expect-user root -- hdapsd # hdapsd status RETVAL=$? ;; *) msg_usage "${0##*/} {start|stop|restart|condstop|condrestart|status}" RETVAL=1 esac exit $RETVAL