Files
ansible/proxmox/admin_scripts/bashrc
rasmus 651b59408b pve: rm old scripts
migrate_running, return_migrate replaced by HA maintenance mode
stalk_updates was very hacky and broken now..
there's not a good way to get number of sec updates on debian systems tbh
2025-08-02 21:02:36 +03:00

82 lines
1.8 KiB
Bash

#!/bin/bash
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
source /root/telegram.env
alias updl="rup && apt update -q && apt full-upgrade --download-only -y -qq && apt autoremove -y -qq"
#TODO: reinstate restic
alias rup="restic -q -r local:/root/jc/restic/"$HOSTNAME" -p /root/jc/restic/passwd backup /etc ~/.bash_history && restic -q -r local:/root/jc/restic/"$HOSTNAME" -p /root/jc/restic/passwd forget --prune --keep-last 14 --keep-within 3m --keep-weekly 520"
#TODO: restic -p ~/jc/restic/passwd -r local:"??no more nas??/restic/$HOSTNAME" init
function waitNoRunning {
echo '- - - - - - - - Waiting VMs to migrate or shutdown 200s - - - - - - - -'
while true; do
if "$(basedir "$0")"/confirm_norunning.sh "$@" >/dev/null; then
return
fi
sleep 3
printf .
done
}
export -f waitNoRunning
function upg {
if ! "$(basedir "$0")"/shutdown_nomigrates.sh; then
tgmsg 'ERROR: upg: signaling nomigrate shutdowns'
return 1
fi
if ! timeout 200 bash -c waitNomigrateShutdown 0; then
tgmsg 'ERROR: upg: running VMs before upgrade'
return 1
fi
if ! apt full-upgrade -y; then
tgmsg 'ERROR: upg: upgrade'
return 1
fi
}
function upgr {
# shellcheck disable=SC2119
off || return $?
upg || return $?
# double confirmation
if ! timeout 200 bash -c waitNomigrateShutdown 1; then
tgmsg 'ERROR: upgr: running VMs before reboot'
return 1
fi
reboot
}
function _off {
ha-manager crm-command node-maintenance enable "$1" && \
echo "$1": maintenance mode
}
# shellcheck disable=SC2120
function off {
if [[ "$#" -gt 0 ]]; then
_off "$@"
return "$?"
else
_off "$HOSTNAME"
fi
updl
}
alias h="echo 'avail cmds: updl upg upgr | localprogress'"
function localprogress () {
watch ls -lh "/var/lib/vz/images/$1"
}