Created
July 7, 2012 19:55
-
-
Save cdwilson/3067906 to your computer and use it in GitHub Desktop.
Setup APC USB UPS on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://help.ubuntu.com/community/apcupsd | |
# don't actually run this | |
exit 0 | |
# install apcupsd | |
sudo apt-get -y install apache2 apcupsd apcupsd-cgi | |
# set up config | |
sudo cp /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.orig | |
sudo emacs /etc/apcupsd/apcupsd.conf | |
# change the following | |
# UPSCABLE usb | |
# UPSTYPE usb | |
# DEVICE | |
sudo cp /etc/default/apcupsd /etc/default/apcupsd.orig | |
sudo emacs /etc/default/apcupsd | |
# change ISCONFIGURED=no to ISCONFIGURED=yes | |
# add custom doshutdown file so that the server halts waiting for the APC to | |
# cut the power, instead of powering off before the APC grace period times out | |
# see http://www.apcupsd.org/manual/manual.html#shutdown-sequence | |
# if you don't halt, the machine powers off ('-h' by default), and as a result | |
# when power is restored, the machine doesn't turn back on. | |
# if you halt instead, the power is cut by the APC, and when power is restored | |
# the machine starts up again (as long as the option is enabled in the BIOS) | |
sudo emacs /etc/apcupsd/doshutdown | |
# add the following: | |
#!/bin/sh | |
SHUTDOWN=/sbin/shutdown | |
WALL=wall | |
echo "UPS ${2} initiated Shutdown Sequence" | ${WALL} | |
${SHUTDOWN} -H now "apcupsd UPS ${2} initiated shutdown" | |
exit 99 | |
sudo chmod +x /etc/apcupsd/doshutdown | |
# enable mounting of / read only | |
sudo emacs /etc/apcupsd/killpower | |
# add the following lines for ext4 fs: | |
mount | awk '/ext4/ { print $3 }' | while read line; do | |
mount -n -o ro,remount $line | |
done | |
# edit the file /etc/default/apcupsd and change the no of the ISCONFIGURED with a yes | |
# start apcupsd | |
sudo service apcupsd start | |
# add apcups to apache conf.d | |
sudo emacs /etc/apache2/conf.d/apcups | |
# add the following: | |
Alias /apcups /usr/lib/cgi-bin/apcupsd | |
<Directory /usr/lib/cgi-bin/apcupsd> | |
Options FollowSymLinks ExecCGI | |
AddHandler cgi-script .cgi | |
DirectoryIndex multimon.cgi | |
</Directory> | |
# reload apache | |
sudo service apache2 reload | |
# http://your.server/apcups | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello, I previously have installed pi-hole, and I seem to be unable to access the UPS via # http://your.server/apcups
I think pi-hole is taking precedence on the apcupsd service.
Is there a way to move the apcupsd to another port?