Browse Source

#263 APC UPS setup USB cable

v1.3
Christian Rotzoll 5 years ago
parent
commit
a0540ea1b9
  1. 10
      FAQ.md
  2. 84
      home.admin/config.scripts/blitz.ups.sh

10
FAQ.md

@ -777,3 +777,13 @@ The `[CONTENT-OF-RASPIBLITZ-ROOT-SSH-PUBKEY]` you get when running the `internet
To check if a tunnel is running on on server check: `netstat -tulpn`
To check for any errors on RaspiBlitz after restart check logs: `sudo journalctl -f -u autossh-tunnel.service`
## How to connect a UPS to the RaspiBlitz?
A UPS (Uninterruptible Power Supply) is used to protect the RaspiBlitz against power outages. Normally you put it just between your normal power outlet and your RaspiBlitz and you are good. But some UPS offer a way to communicate with devices. This can be very useful for example if on a longer power outage the battery of the UPS runs low the RaspiBlitz could detect this and power down in a clean way - instead of just the power goes out and risking data loss or corruption.
There is an experimental script to connect the RaspiBlitz to a UPS over USB cable build by APC - the Model tested with was [APC Back-UPS BX - BX700U-GR](https://www.amazon.de/APC-Back-UPS-Unterbrechungsfreie-Stromversorgung-BX700U-GR/dp/B00T7BYRCK) but it should work with every APC model offering a USB port.
To turn it on run from terminal: `/home/admin/config.scripts/blitz.ups.sh on apcusb`
If you have other UPS models or ways to connect ... feel free to extend this script.

84
home.admin/config.scripts/blitz.ups.sh

@ -0,0 +1,84 @@
#!/bin/bash
source /home/admin/raspiblitz.info
source /mnt/hdd/raspiblitz.conf
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "Configure a UPS (Uninterruptible Power Supply)"
echo "blitz.ups.sh on apcusb"
echo "blitz.ups.sh off"
exit 1
fi
###################
# SWITCH ON
###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
echo "Turn ON: UPS"
# check if already activated
if [ ${#ups} -gt 0 ]; then
echo "FAIL: UPS is already on - switch off with: ./blitz.ups.sh off"
exit 1
fi
if [ "$2" = "apcusb" ]; then
# MODEL: APC with USB connection
# see video: https://www.youtube.com/watch?v=6UrknowJ12o
# installs apcupsd.service
sudo apt-get install -f apcupsd
# edit config: /etc/apcupsd/apcupsd.conf
sudo systemctl stop apcupsd
sudo sed -i "s/^UPSCABLE.*/UPSCABLE usb/g" /etc/apcupsd/apcupsd.conf
sudo sed -i "s/^UPSTYPE.*/UPSTYPE usb/g" /etc/apcupsd/apcupsd.conf
sudo sed -i "s/^DEVICE.*/DEVICE/g" /etc/apcupsd/apcupsd.conf
sudo sed -i "s/^MINUTES.*/MINUTES 10/g" /etc/apcupsd/apcupsd.conf
sudo systemctl start apcupsd
# add default 'ups' raspiblitz.conf if needed
if [ ${#ups} -eq 0 ]; then
echo "ups=" >> /mnt/hdd/raspiblitz.conf
fi
# set ups config value (in case of update)
sudo sed -i "s/^ups=.*/ups='apcusb'/g" /mnt/hdd/raspiblitz.conf
echo "OK - UPS is now connected"
echo "Check status/connection with command: apcaccess"
else
echo "FAIL: unknown or missing second parameter 'UPSTYPE'"
exit 1
fi
fi
###################
# SWITCH OFF
###################
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
echo "Turn OFF: UPS"
# check if already activated
if [ ${#ups} -eq 0 ]; then
echo "FAIL: UPS is already off."
exit 1
fi
if [ "${ups}" = "apcusb" ]; then
sudo systemctl stop apcupsd
sudo systemctl disable apcupsd
sudo apt-get remove -f apcupsd
else
echo "FAIL: unknown UPSTYPE: ${ups}"
exit 1
fi
fi
Loading…
Cancel
Save