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
This commit is contained in:
		@@ -8,37 +8,31 @@ esac
 | 
			
		||||
 | 
			
		||||
source /root/telegram.env
 | 
			
		||||
 | 
			
		||||
alias updl="apt update -q && apt full-upgrade --download-only -y -qq && apt autoremove -y -qq"
 | 
			
		||||
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 up {
 | 
			
		||||
	read -p "where to? " whereto
 | 
			
		||||
	if ! ~/jc/migrate_running.sh "$HOSTNAME" "$whereto"; then
 | 
			
		||||
		tgmsg tgmsg 'ERROR: up: migrate'
 | 
			
		||||
		return 1
 | 
			
		||||
	fi
 | 
			
		||||
	echo restic…
 | 
			
		||||
	if ! rup; then
 | 
			
		||||
		tgmsg 'ERROR: up: restic'
 | 
			
		||||
		return 1
 | 
			
		||||
	fi
 | 
			
		||||
	if ! updl; then
 | 
			
		||||
		tgmsg 'ERROR: up: download'
 | 
			
		||||
		return 1
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
function upg {
 | 
			
		||||
	if ! ~/jc/confirm_norunning.sh; then
 | 
			
		||||
		tgmsg 'ERROR: upg: migratables present'
 | 
			
		||||
		return 1
 | 
			
		||||
function waitNoRunning {
 | 
			
		||||
echo '- - - - - - - - Waiting VMs to migrate or shutdown 200s - - - - - - - -'
 | 
			
		||||
while true; do
 | 
			
		||||
	if "$(basedir "$0")"/confirm_norunning.sh "$@" >/dev/null; then
 | 
			
		||||
		return
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	if ! ~/jc/shutdown_nomigrates.sh; then
 | 
			
		||||
	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; then
 | 
			
		||||
 | 
			
		||||
	if ! timeout 200 bash -c waitNomigrateShutdown 0; then
 | 
			
		||||
		tgmsg 'ERROR: upg: running VMs before upgrade'
 | 
			
		||||
		return 1
 | 
			
		||||
	fi
 | 
			
		||||
@@ -49,25 +43,13 @@ function upg {
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function waitNomigrateShutdown {
 | 
			
		||||
echo '- - - - - - - - Waiting nomigrate to shutdown 200s - - - - - - - -'
 | 
			
		||||
while true; do
 | 
			
		||||
	if ~/jc/confirm_norunning.sh 1 >/dev/null; then
 | 
			
		||||
		return
 | 
			
		||||
	fi
 | 
			
		||||
 | 
			
		||||
	sleep 3
 | 
			
		||||
	printf .
 | 
			
		||||
done
 | 
			
		||||
}
 | 
			
		||||
export -f waitNomigrateShutdown
 | 
			
		||||
 | 
			
		||||
function upgr {
 | 
			
		||||
	up || return $?
 | 
			
		||||
	# shellcheck disable=SC2119
 | 
			
		||||
	off || return $?
 | 
			
		||||
	upg || return $?
 | 
			
		||||
 | 
			
		||||
	# double confirmation
 | 
			
		||||
	if ! timeout 200 bash -c waitNomigrateShutdown; then
 | 
			
		||||
	if ! timeout 200 bash -c waitNomigrateShutdown 1; then
 | 
			
		||||
		tgmsg 'ERROR: upgr: running VMs before reboot'
 | 
			
		||||
		return 1
 | 
			
		||||
	fi
 | 
			
		||||
@@ -75,13 +57,24 @@ function upgr {
 | 
			
		||||
	reboot
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function toh {
 | 
			
		||||
~/jc/return_migrate.sh ~/jc/desired.yaml "$@"
 | 
			
		||||
tgmsg "return_migrate finished: $?"
 | 
			
		||||
function _off {
 | 
			
		||||
	ha-manager crm-command node-maintenance enable "$1" && \
 | 
			
		||||
	echo "$1": maintenance mode
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
alias des="vim ~/jc/desired.yaml"
 | 
			
		||||
alias h="echo 'avail cmds: up upg upgr | toh des | localprogress'"
 | 
			
		||||
# 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"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user