| 1 | #!/sbin/openrc-run |
| 2 | |
| 3 | description="hd-idle" |
| 4 | |
| 5 | pidfile="/run/$RC_SVCNAME.pid" |
| 6 | command="/usr/sbin/hd-idle" |
| 7 | command_args="-l $LOGFILE -i 0" |
| 8 | [ -n "$DISK_TYPE" ] && command_args="$command_args -c $DISK_TYPE" |
| 9 | command_background=yes |
| 10 | |
| 11 | depend() { |
| 12 | need localmount |
| 13 | after modules |
| 14 | } |
| 15 | |
| 16 | config_error() { |
| 17 | ebegin "Starting $description" |
| 18 | eend 1 "$1" |
| 19 | } |
| 20 | |
| 21 | start_pre() { |
| 22 | if [ -n "$DISK" ]; then |
| 23 | case "$IDLE_TIME" in |
| 24 | *[!0123456789]* ) config_error "IDLE_TIME value is invalid" ;; |
| 25 | "" ) config_error "IDLE_TIME is not set" ;; |
| 26 | "0" ) config_error "IDLE_TIME cannot be 0" ;; |
| 27 | * ) command_args="$command_args -a $DISK -i $IDLE_TIME" |
| 28 | esac |
| 29 | fi |
| 30 | } |