diff --git a/spindown b/spindown
index 952f854..654e35e 100755
--- a/spindown
+++ b/spindown
@@ -1,147 +1,146 @@
-#!/bin/bash
-
-DAEMON="/sbin/spindownd"
-CONFPATH="/etc/spindown.conf"
-VARDIR="/var/run/spindown"
-FIFOPATH=$VARDIR"/spindownd.fifo"
-PIDFILE=$VARDIR"/spindownd.pid"
-
-. /lib/lsb/init-functions
-
-if ! type log_end_msg &> /dev/null; then
-    log_end_msg()
-    {
-        if [ $1 -eq 0 ]; then
-            echo .
-        else
-            echo " failed."
-        fi
-    }
-fi
-
-if ! type log_daemon_msg &> /dev/null; then
-    log_daemon_msg()
-    {
-        echo -n $1: $2
-    }
-fi
-
-if ! type killproc &> /dev/null; then
-    killproc()
-    {
-        if [ `echo $@ | grep -i PIPE | wc -l` -ne 0 ]; then
-            kill -pipe `cat $PIDFILE`
-
-        else if [ `echo $@ | grep -i HUP | wc -l` -ne 0 ]; then
-            kill -hup `cat $PIDFILE`
-
-        else
-            kill `cat $PIDFILE`
-
-        fi fi
-
-        return 0;
-    }
-fi
-
-if ! type status_of_proc &> /dev/null; then
-    status_of_proc()
-    {
-        if [ -a $PIDFILE ]; then
-            echo spindown is running.
-            return 0
-
-        else
-            echo spindown is not running.
-            return 1
-
-        fi
-    }
-fi
-
-if ! type start_daemon &> /dev/null; then
-    start_daemon()
-    {
-        if [ -a $PIDFILE ]; then
-            return 1
-
-        else
-            $DAEMON -d -f $FIFOPATH  -c $CONFPATH -p $PIDFILE
-            return 0
-
-        fi
-
-    }
-fi
-
-#prints table with status about the disks
-status()
+#!/bin/sh
+#
+# spindown      Start/Stop the spindown clock daemon.
+#
+# chkconfig:   - 90 60
+# description: Daemon that can spindown idle disks
+
+### BEGIN INIT INFO
+# Provides: 
+# Required-Start: 
+# Required-Stop: 
+# Should-Start: 
+# Should-Stop: 
+# Default-Start: 
+# Default-Stop: 
+# Short-Description: 
+# Description:      
+### END INIT INFO
+
+[ -f /etc/sysconfig/crond ] || { 
+    [ "$1" = "status" ] && exit 4 || exit 6 
+}
+
+RETVAL=0
+prog="spindown"
+exec="/usr/sbin/spindownd"
+lockfile="/var/lock/subsys/spindown"
+config="/etc/spindown.conf"
+statuspipe="/tmp/spindown.status"
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+start() {
+    echo -n $"Starting $prog: "
+    if [ $UID -ne 0 ] ; then
+        failure
+        echo -e "\nUser has insufficient privilege."
+        exit 4
+    fi
+    if [ ! -x $exec ]; then
+        failure
+        echo -e "\nDaemon binary not executable."
+        exit 5
+    fi
+    if [ ! -f $config ]; then
+        failure
+        echo -e "\nConfig file missing."
+        exit 6
+    fi
+    $exec -d -f $statuspipe -c $config -p /var/run/spindownd.pid; 
+    retval=$?
+    [ "$retval" -eq 0 ] && success || failure
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+}
+
+stop() {
+    if [ $UID -ne 0 ] ; then
+        echo "User has insufficient privilege."
+        exit 4
+    fi
+    echo -n $"Stopping $prog: "
+	if [ -n "`pidfileofproc $exec`" ]; then
+		killproc $exec
+		RETVAL=3
+	else
+		failure $"Stopping $prog"
+	fi
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+}
+
+printstatus()
 {
-    #print the header of the table
     printf "%-5s %10s %10s %15s %20s\n" name watched active idle-time spindown-time
-
     while read line; do
-
             printf "%-5s %10s %10s %15s %20s\n" $line
-
-    done < $FIFOPATH
-
+    done < $statuspipe
     exit 0
 }
 
-case "$1" in
-    "start")
-        log_daemon_msg "Starting disk spindown daemon" "spindownd"
-        mkdir $VARDIR &> /dev/null
-        start_daemon -p $PIDFILE $DAEMON -d -f $FIFOPATH  -c $CONFPATH -p $PIDFILE
-        log_end_msg $?
+restart() {
+    stop
+    start
+}
 
-        exit $?
-        ;;
+reload() {
+    restart
+}
 
-    "stop")
-        log_daemon_msg "Stopping disk spindown daemon" "spindownd"
-        killproc -p $PIDFILE $DAEMON
-        rmdir $VARDIR &> /dev/null
-        log_end_msg $?
+force_reload() {
+    restart
+}
 
-        exit $?
-        ;;
+rh_status() {
+    if [ -p $statuspipe ]; then
+            printstatus &
+            sleep 0.5
+            kill -pipe `cat /var/run/spindownd.pid`
+            wait $!
+    fi
+    status -p /var/run/spindownd.pid $prog
+}
 
-    "status")
-        if status_of_proc -p $PIDFILE $DAEMON spindown; then
-            echo -n
-        else
-            exit 1
-        fi
+rh_status_q() {
+    rh_status >/dev/null 2>&1
+}
 
-        # First open the fifo and then send the signal
-        status &
-        sleep 0.1
-        killproc -p $PIDFILE $DAEMON -PIPE
-        wait $!
 
-        exit 0
+case "$1" in
+    start)
+        
+        rh_status_q && exit 0
+        $1
         ;;
-
-    "restart"|"condrestart")
-        $0 stop
-        $0 start
-
-        exit $?
+    stop)
+        rh_status_q || exit 0
+        $1
         ;;
-
-    "reload")
-        log_daemon_msg "Reloading disk spindown daemon" "spindownd"
-        killproc -p $PIDFILE $DAEMON -HUP
-        log_end_msg $?
-
-        exit $?
+    restart)
+        $1
+        ;;
+    reload)
+        rh_status_q || exit 7
+        $1
+        ;;
+    force-reload)
+        force_reload
+        ;;
+    status)
+        rh_status
+        ;;
+    condrestart|try-restart)
+        rh_status_q || exit 0
+        restart
         ;;
-
     *)
-        echo "Usage: $0 {start|stop|restart|reload|status}"
-        exit 1
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
+        exit 2
 esac
+exit $?
 
-exit 0
