#!/bin/sh DAEMON=hd-idle . /etc/init.d/modlibrc config() { ## hd-idle needs sysfs to do what it should [ -n "$(grep sysfs /proc/mounts | head -n 1 | awk '{print $2}')" ] && return echo -n "Trying to mount sysfs ... " mkdir -p /var/sys mount sysfs /var/sys -t sysfs if [ "$?" -eq 0 ]; then echo 'done.' else [ ! -d /sys ] && echo "failed (backup mountpoint not available)." && exit 1 mount sysfs /sys -t sysfs exitval=$? if [ "$exitval" -eq 0 ]; then echo 'done.' else echo 'failed.' exit $exitval fi fi } start() { modlib_startdaemon $DAEMON $HD_IDLE_DEVICE -l $HD_IDLE_IDLETIME & } stop() { echo -n " (" for I in $(pidof hd-idle); do kill $I > /dev/null 2>&1 if [ "$?" -eq 0 ]; then echo -n 'v' else echo -n 'x' fi done echo ") " } case $1 in ""|load) modreg cgi 'hd-idle' 'HD-Idle' modreg daemon $DAEMON modlib_start $HD_IDLE_ENABLED ;; unload) modunreg daemon $DAEMON modunreg cgi 'hd-idle' modlib_stop ;; start) modlib_start ;; stop) modlib_stop ;; restart) modlib_restart ;; status) modlib_status ;; *) echo "Usage: $0 [load|unload|start|stop|restart|status]" 1>&2 exit 1 ;; esac exit 0