FANDOM


Although not in the default OTRW, sd-idle is in kongs mod of dd-wrt. This is a management script for it.

Source

I built a quick script to manage sd-idle, you could probably just have a simple startup script, but I thought I would make something a little more elegant.

Requirements - Optware the Right Way

Note the line " sd-idle -d b -i 600" under start) - you need to alter this to suit your needs. I have added info to the usage, so you can see how to setup to your requirements.

Save as S50sdidle in opt/etc/init.d/ and you can manage via fraters service control tool in shell.

#!/bin/sh
NAME=sd-idle

if [ -z "$1" ] ; then
case `echo "$0" | sed 's:^.*/\(.*\):\1:g'` in
S??*) rc="start" ;;
K??*) rc="stop"
esac
else
rc="$1"
fi

case "$rc" in
start)
if pidof $NAME 2>&1 >/dev/null ; then
echo "$NAME is already running"
else
optlog "$NAME" "Staring sd-idle"
sd-idle -d b -i 600
optlog "$NAME" "Successfully started $NAME, managing spin up and spin down of attached device(s)"
fi
;;
stop)
if pidof $NAME 2>&1 >/dev/null ; then
optlog "$NAME" "Terminating sd-idle"
killall $NAME 2>&1 >/dev/null
optlog "$NAME" "sd-idle stopped"
fi
;;
restart)
"$0" stop
sleep 1
"$0" start
;;
info)
echo "Info: $NAME"
echo ""
echo "Usage: ( runs as a daemon )"
echo "sd-idle [ -d devices ] [ -i idletime ] [ -c checktime ] [ -h --help ] [ -v --version ]"
echo "-d [a-z]+ include where a => /dev/sda, b => /dev/sdb (default is all disks)"
echo "![a-z]+ exclude"
echo "-i n n seconds a disk must be idle to spin it down (default 900, min 300)"
echo "-c n n seconds to sleep between idle checks (default 30, min 5)"
echo "-h --help usage"
echo "-v --version version"
echo ""
echo "for example:"
echo "sd-idle will manage all disks with default times"
echo "sd-idle -d bc will manage /dev/sdb, /dev/sdc with default times"
echo "sd-idle -d !bc will manage all disks except /dev/sdb, /dev/sdc with default times"
echo "sd-idle -i 600 will manage all disks spinning down after 600 seconds or 10 minutes"
;;
*)
echo "Usage: $0 (start|stop|restart|usage|info)"
;;
esac
exit 0
Community content is available under CC-BY-SA unless otherwise noted.