Help scrip to Auto power off when lost electric power

thanhphat

New Member
Mar 23, 2023
4
0
1
Dear all,
I have an ideal about auto turn off pve when cutting off electric power.
1. my home pve running with in usp APC 650. (and UPS will turn off after 15 minutes)
2. other Dump AP running without UPS.
So can we have any script running can do:
1. when Dump AP lost power, PVE sending a small script such as checking DumAP alive or not. If Dump AP did not alive, then PVE auto turn off.
2. or do you have any ideal todo that.

My home pve running on HP mini 600G2, i5 6500T, 16gb, PROXMOX 8 and serving by UPS
Thanks you
 
I found out a scrip from web, but is use to reboot only, is there any command turn off?
Code:
#!/bin/sh
while [ 1 ]; do
#ping 1 packet and wait an answer for 2 seconds
        ping -q -c 1 -W 2 -I wwan0 1.1.1.1 >/dev/null
        RESULT=$?
        if [ $RESULT -ne 0 ]; then
                /etc/init.d/modemmanager stop
                sleep 2
                /etc/init.d/modemmanager start
                sleep 60
                echo "ristarted"
        fi
# wait 10 seconds for the text ping
        sleep 10
done