CyberPower PowerPanel configuration set to gracefully attempt to dismount drives before signalling shutdown in event of UPS low battery
This file contains 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 | |
echo "Warning: The UPS's battery power is not enough, system will be shutdown soon!" | wall | |
export RECEIPT_NAME | |
export RECEIPT_ADDRESS | |
export SENDER_ADDRESS | |
# | |
# If you want to receive event notification by e-mail, you must change 'ENABLE_EMAIL' item to 'yes'. | |
# Note: After change 'ENABLE_EMAIL' item, you must asign 'RECEIPT_NAME', 'RECEIPT_ADDRESS', and | |
# 'SENDER_ADDRESS' three items as below for the correct information. | |
# | |
# Enable to send e-mail | |
ENABLE_EMAIL=yes | |
# Change your name at this itme. | |
RECEIPT_NAME="You" | |
# Change mail receiver address at this itme. | |
RECEIPT_ADDRESS=your.email@gmail.com | |
# Change mail sender address at this itme. | |
SENDER_ADDRESS=powerpanel@localhost | |
# Execute the 'pwrstatd-email.sh' shell script | |
if [ $ENABLE_EMAIL = yes ]; then | |
/etc/powerpanel/pwrstatd-email.sh | |
fi | |
########### | |
# shutdown | |
function killproc () { | |
proc=$1 | |
pkill -15 $proc | |
sleep 2 | |
if [ `pgrep $proc | wc -l` -gt 0 ] ; then | |
pkill -9 $proc | |
fi | |
} | |
# kill processes that could be using RAID arrays | |
procs=('firefox' 'Discord' 'ssh' 'slack' 'spotify' 'clementine' 'chromium' 'bomi' 'bash') | |
for p in "${procs[@]}" ; do | |
killproc $p | |
done | |
# shutdown via systemctl | |
systemctl poweroff |
This file contains 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 | |
echo "Warning: Utility power failure has occurred for a while, system will be shutdown soon!" | wall | |
export RECEIPT_NAME | |
export RECEIPT_ADDRESS | |
export SENDER_ADDRESS | |
# | |
# If you want to receive event notification by e-mail, you must change 'ENABLE_EMAIL' item to 'yes'. | |
# Note: After change 'ENABLE_EMAIL' item, you must asign 'RECEIPT_NAME', 'RECEIPT_ADDRESS', and | |
# 'SENDER_ADDRESS' three items as below for the correct information. | |
# | |
# Enable to send e-mail | |
ENABLE_EMAIL=yes | |
# Change your name at this itme. | |
RECEIPT_NAME="You" | |
# Change mail receiver address at this itme. | |
RECEIPT_ADDRESS=your.email@gmail.com | |
# Change mail sender address at this itme. | |
SENDER_ADDRESS=powerpanel@localhost | |
# Execute the 'pwrstatd-email.sh' shell script | |
if [ $ENABLE_EMAIL = yes ]; then | |
/etc/powerpanel/pwrstatd-email.sh | |
fi |
This file contains 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
# | |
# pwrstatd configuration file | |
# | |
# You must restart pwrstatd after changing this file in order for changes to take effect. | |
# Ex:/etc/powerpanel/init.d/pwrstatd restart | |
# | |
# Action setting for event of Power Failure | |
# | |
# A delay time in seconds since event of Power Failure occur then to run shell | |
# script and shutdown system. Allowed range is 0 ~ 3600. Default is 60 sec. | |
powerfail-delay = 60 | |
# Enable to run shell script when the event of Power Failure occur. | |
# The allowed options are yes and no. Default is yes. | |
powerfail-active = yes | |
# Assign a path of script file for event of Power Failure. | |
# The default is /etc/powerpanel/pwrstatd-powerfail.sh | |
powerfail-cmd-path = /etc/powerpanel/pwrstatd-powerfail.sh | |
# How much time in seconds to take script running for event of Power Failure. | |
# The allowed range is 0 ~ 3600. Default is 0 sec. | |
powerfail-duration = 0 | |
# Allow Daemon to shutdown system for event of Power Failure. | |
# The allowed options are yes and no. Default is yes. | |
powerfail-shutdown = no | |
# | |
# Action setting for event of Battery Low | |
# | |
## A threshold of Battery Capacity, If the battery capacity is lower than this | |
## value and a event of Battery Low will be identified. The unit is percentage. | |
## The allowed range is 0 ~ 90. Default is 35 %. | |
# 35% of 14 minutes is ~5 minutes | |
lowbatt-threshold = 35 | |
## A threshold of Remaining Runtime, If the Remaining Runtime is lower than this | |
## value and a event of Battery Low will be identified. The unit is second. | |
## The allowed range is 0 ~ 3600. Default is 300 sec. | |
## Note: When meet this condition the below 'shutdown-sustain' property | |
## will be ignored. | |
# 7 minutes remaining capacity | |
runtime-threshold = 420 | |
## Turn UPS alarm on or off. | |
## The allowed options are yes and no. Default is yes. | |
enable-alarm = yes | |
## Enable to run shell script when the event of Battery Low occur. | |
## The allowed options are yes and no. Default is yes. | |
lowbatt-active = yes | |
## Assign a path of script file for event of Battery Low. | |
## The default is /etc/powerpanel/pwrstatd-lowbatt.sh | |
lowbatt-cmd-path = /etc/powerpanel/pwrstatd-lowbatt.sh | |
## Allow Daemon to shutdown system for event of Battery Low. | |
## The allowed options are yes and no. Default is yes. | |
lowbatt-shutdown = no | |
## How much time in seconds to take script running for event of Battery Low. | |
## The allowed range is 0 ~ 60. Default is 0 sec. | |
# after this amount of time elapses after script execution begins, | |
# shut down the system if lowbatt-shutdown is enabled | |
lowbatt-duration = 60 | |
## The necessary time in seconds for system shutdown. | |
## The UPS will turn power off when this time is expired. | |
## The allowed range is 0 ~ 3600. Default is 600 sec.(10 min.) | |
## If the computer shutdown is cause by low runtime condition, the UPS will | |
## turn power off when the time is expired that time is assigned on | |
## 'runtime-threshold' property and it is no longer to refer the | |
## 'shutdown-sustain' property. | |
# after the system is shut down (see lowbatt-duration and lowbatt-shutdown) | |
# this starts ticking. when it expires, or runtime-threshold is violated, | |
# the UPS is turned off | |
shutdown-sustain = 60 | |
## Daemon will turn UPS power off once it ask system shutdown cause by a power | |
## event. Allowed options are yes and no. Default is yes. | |
turn-ups-off = no | |
# The period of polling UPS in seconds. | |
# The allowed range is 1 ~ 60. Default is 3 sec. | |
ups-polling-rate = 3 | |
# the period of re-try to find available UPS in seconds since find nothing at | |
# last time. The allowed range is 1 ~ 300. Default is 10 sec. | |
ups-retry-rate = 10 | |
# Prohibiting daemon to provide communication mechanism for client, such as | |
# pwrstat command. normally, it should be 'no'. It can be 'yes' if any security | |
# consideration. Allowed options are yes and no. Default is no. | |
prohibit-client-access = no | |
# The pwrstatd accepts four types of device node which includes the 'ttyS', | |
# 'ttyUSB', 'hiddev', and 'libusb' for communication with UPS. The pwrstatd | |
# defaults to enumerate all acceptable device nodes and pick up to use an | |
# available device node automatically. But this may cause a disturbance to the | |
# device node which is occupied by other software. Therefore, you can restrict | |
# this enumerate behave by using allowed-device-nodes option. You can assign | |
# the single device node path or multiple device node paths divided by a | |
# semicolon at this option. All groups of 'ttyS', 'ttyUSB', 'hiddev', or | |
# 'libusb' device node are enumerated without a suffix number assignment. | |
# Note, the 'libusb' does not support suffix number only. | |
# | |
# For example: restrict to use ttyS1, ttyS2 and hiddev1 device nodes at /dev | |
# path only. | |
# allowed-device-nodes = /dev/ttyS1;/dev/ttyS2;/dev/hiddev1 | |
# | |
# For example: restrict to use ttyS and ttyUSB two groups of device node at | |
# /dev,/dev/usb, and /dev/usb/hid paths(includes ttyS0 to ttySN and ttyUSB0 to | |
# ttyUSBN, N is number). | |
# allowed-device-nodes = ttyS;ttyUSB | |
# | |
# For example: restrict to use hiddev group of device node at /dev,/dev/usb, | |
# and /dev/usb/hid paths(includes hiddev0 to hiddevN, N is number). | |
# allowed-device-nodes = hiddev | |
# | |
# For example: restrict to use libusb device. | |
# allowed-device-nodes = libusb | |
allowed-device-nodes = | |
# Daemon will hibernate system to instead of system shutdown when power | |
# event occur. Allowed options are yes and no. Default is no. | |
hibernate = no |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment