#!/bin/bash # # APCUPSD Initialization Script # # Based on sysklogd script from LFS-3.1 and earlier. # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org # Apcupsd version written by Bryan Mason - bmason@bmason.com # # Filename: /etc/rc.d/init.d/apcupsd # # Author: Bryan Mason # # Edit History: # # Date Author Action # ---------------------------------------------------------------------- # 3 Jan 2003 B. Mason Created # 24 May 2004 B. Mason Modified for apcupsd-3.10.13 source /etc/sysconfig/rc source $rc_functions case "$1" in start) # Comment the following lines if the USB and HID # drivers were built into the kernel # Use "modprobe usb-ohci" instead of "modprobe usb-uhci" # if you have an OHCI compliant USB controller. echo "Installing modules for USB and HID..." modprobe usb-uhci && modprobe hid evaluate_retval echo "Starting APC UPS Daemon (apcupsd)..." rm -f /etc/apcupsd/powerfail rm -f /etc/nologin loadproc /sbin/apcupsd ;; stop) echo "Stopping APC UPS Daemon (apcupsd)..." killproc /sbin/apcupsd # Comment the following lines if the USB and HID # drivers were built into the kernel # Replace "usb-ohci" with "usb-uhci" # if you have an OHCI compliant USB controller. echo "Removing modules for USB and HID..." rmmod usb-uhci hid input usbcore evaluate_retval # Sometimes killproc can't kill apcupsd, which # interrupts the shutdown process. # That isn't good. So lets make sure to always # exit with a status of 0. exit 0 ;; reload) echo "Reloading APC UPS Daemon (apcupsd)..." reloadproc /sbin/apcupsd ;; restart) $0 stop sleep 1 $0 start ;; status) /sbin/apcaccess status statusproc /sbin/apcupsd ;; *) echo "Usage: $0 {start|stop|reload|restart|status}" exit 1 ;; esac