#!/bin/sh # # hddtemp init script DRIVES="" getdrives() { for dir in $( /usr/bin/ls /sys/block ) do HDD=$( echo $dir | /usr/bin/grep "^[sh]d[abcdefgh]" ) if [ ! -z "$HDD" ]; then cd /sys/block/$dir REM=$( /usr/bin/cat removable ) if [ "$REM" == "0" ]; then DRIVES="$DRIVES /dev/$HDD" fi fi done } start() { echo -n "Starting hddtemp: " getdrives if [ -z "$DRIVES" ]; then echo "no hard disks found" exit 0 fi /usr/sbin/hddtemp -d $DRIVES echo "/usr/sbin/hddtemp -d $DRIVES" } stop() { echo -n "Stopping hddtemp: " /bin/kill $( pidof /usr/sbin/hddtemp ) echo } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 1 start ;; *) echo "Usage: $0 {start|stop|restart}" esac