Background
I've a home lab running Proxmox and I often forget to shut the host, wasting power even when there's no containers or virtual machines running.
This script is setup on cron to run every 5 mins, it checks, if there are no containers & Virtual machines running then it will shut down the host in 30 mins or 1800 sec.
#! /bin/bash
if [[ $(/usr/sbin/pct list | /usr/bin/grep -i running | /usr/bin/wc -l) == 0 && $(/usr/sbin/qm list | /usr/bin/grep running | /usr/bin/wc -l) == 0 ]]; then
/usr/bin/sleep 1800
if [[ $(/usr/sbin/pct list | /usr/bin/grep -i running | /usr/bin/wc -l) == 0 && $(/usr/sbin/qm list | /usr/bin/grep running | /usr/bin/wc -l) == 0 ]]; then
/usr/bin/init 0
fi
else
/usr/bin/echo "Resources in use"
fi
To setup chron, copy paste the following into your chrontab file.
# Shutdown idle proxmox automatically after 30 mins
*/5 * * * * pidof -x shut && echo "already running" >> /dev/null 2>&1 || /root/shut.sh
If I understood, you want to shut the host proxmox if you have nothing running except your possibly virtual firewall which you are calling as router?