From 4dc4ffcc1e25c56cb54ee80baf7a20743af6d3ca Mon Sep 17 00:00:00 2001 From: BassT23 Date: Fri, 3 Jan 2025 19:19:34 +0100 Subject: [PATCH] fix compatibility for "old" ssh connection --- VMs/example | 4 +++- update.conf | 2 +- update.sh | 30 ++++++++++++++++++++---------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/VMs/example b/VMs/example index b2c4e9a..e007a13 100644 --- a/VMs/example +++ b/VMs/example @@ -6,4 +6,6 @@ IP="111.111.111.111" USER="root" -SSH_VM_PORT="22" \ No newline at end of file +SSH_VM_PORT="22" +# Time in secounds +SSH_START_DELAY_TIME="45" \ No newline at end of file diff --git a/update.conf b/update.conf index d6e45f1..4c9c977 100644 --- a/update.conf +++ b/update.conf @@ -68,7 +68,7 @@ FSTRIM_WITH_MOUNTPOINT="true" INCLUDE_KERNEL="true" # not included for now INCLUDE_KERNEL_CLEAN="true" # true only in develop -VM_START_DELAY="45" # in secounds +VM_START_DELAY="45" # in secounds - for QEMU - not SSH ┌──────────────────────────────────────────────┐ │ Only/Exclude LXC and/or VM │ diff --git a/update.sh b/update.sh index db28664..598ad7b 100644 --- a/update.sh +++ b/update.sh @@ -10,7 +10,7 @@ # shellcheck disable=SC2317 # shellcheck disable=SC2320 -VERSION="4.2.6" +VERSION="4.2.7" # Variable / Function LOCAL_FILES="/etc/ultimate-updater" @@ -689,7 +689,6 @@ VM_UPDATE_START () { echo -e "${BL}[Info]${GN} Shutting down VM${BL} $VM ${CL}\n\n" qm stop "$VM" & WILL_STOP="false" - START_WAITING="false" else echo -e "${BL}[Info] Skipped VM $VM because, QEMU or SSH hasn't initialized${CL}\n\n" fi @@ -715,25 +714,30 @@ UPDATE_VM () { echo -e "${BL}[Info]${OR} Start Snapshot and/or Backup${CL}" VM_BACKUP echo - if [[ "$START_WAITING" == true ]]; then - echo -e "${BL}[Info]${OR} Wait for bootup${CL}" - echo -e "${BL}[Info]${OR} Sleep $VM_START_DELAY secounds - time could be set in config file${CL}\n" - sleep "$VM_START_DELAY" - fi # Run Update - Tryout SSH first - echo -e "${BL}[Info]${GN} Try to connect via SSH first${CL}\n" if [[ -f $LOCAL_FILES/VMs/"$VM" ]]; then IP=$(awk -F'"' '/^IP=/ {print $2}' $LOCAL_FILES/VMs/"$VM") USER=$(awk -F'"' '/^USER=/ {print $2}' $LOCAL_FILES/VMs/"$VM") + if [[ -z "$USER" ]]; then USER="root"; fi SSH_VM_PORT=$(awk -F'"' '/^SSH_VM_PORT=/ {print $2}' $LOCAL_FILES/VMs/"$VM") + if [[ -z "$SSH_VM_PORT" ]]; then SSH_VM_PORT="22"; fi + SSH_START_DELAY_TIME=$(awk -F'"' '/^SSH_START_DELAY_TIME=/ {print $2}' $LOCAL_FILES/VMs/"$VM") + if [[ -z "$SSH_START_DELAY_TIME" ]]; then SSH_START_DELAY_TIME="45"; fi + if [[ "$START_WAITING" == true ]]; then + echo -e "${BL}[Info]${OR} Wait for bootup${CL}" + echo -e "${BL}[Info]${OR} Sleep $SSH_START_DELAY_TIME secounds - time could be set in SSH-VM config file${CL}\n" + sleep "$SSH_START_DELAY_TIME" + START_WAITING="false" + fi if ! (ssh -q -p "$SSH_VM_PORT" "$USER"@"$IP" exit >/dev/null 2>&1); then echo -e "${RD} File for ssh connection found, but not correctly set?\n\ - Please configure SSH Key-Based Authentication${CL}\n\ + ${OR}Or need more start delay time.\n\ + ${BL}Please check SSH Key-Based Authentication${CL}\n\ Infos can be found here: Try to use QEMU insead\n" UPDATE_VM_QEMU else - SSH_CONNECTION=true + SSH_CONNECTION="true" OS_BASE=$(qm config "$VM" | grep ostype) if (qm config "$VM" | grep template); then echo -e "${OR}$VM is a template - skipping the update${CL}\n" @@ -805,6 +809,12 @@ UPDATE_VM_QEMU () { if qm guest exec "$VM" test >/dev/null 2>&1; then echo -e "${OR} QEMU found. SSH connection is also available - with better output.${CL}\n\ Please look here: \n" + if [[ "$START_WAITING" == true ]]; then + echo -e "${BL}[Info]${OR} Wait for bootup${CL}" + echo -e "${BL}[Info]${OR} Sleep $VM_START_DELAY secounds - time could be set in update.conf file${CL}\n" + sleep "$VM_START_DELAY" + START_WAITING="false" + fi # Run Update KERNEL=$(qm guest cmd "$VM" get-osinfo | grep kernel-version) if [[ "$KERNEL" =~ FreeBSD ]]; then