From 1eddb12cb12cd8eb082798f9f7cb3b5f24183909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Kn=C3=B6ppler?= <6317548+theCalcaholic@users.noreply.github.com> Date: Sun, 21 Apr 2024 21:06:58 +0200 Subject: [PATCH] vm-tests.yml: Fix distupgrade script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com> --- .github/workflows/vm-tests.yml | 17 ++++++++++++++--- bin/ncp-dist-upgrade.d/debian-11.sh | 18 ++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.github/workflows/vm-tests.yml b/.github/workflows/vm-tests.yml index f3a903c42..ab5e61bec 100644 --- a/.github/workflows/vm-tests.yml +++ b/.github/workflows/vm-tests.yml @@ -271,13 +271,22 @@ jobs: - name: NCP distupgrade id: distupgrade + working-directory: /ncp-test-automation/bin run: | - ssh "${SSH_OPTIONS[@]}" "root@${SERVER_ADDRESS}" cat /etc/os-release | grep VERSION_ID=11 || { - echo "Skipping dist-upgrade - can't upgrade from Debian $(lxc exec ncp -- cat /etc/os-release | grep VERSION_ID=)" + set -e + + echo "Setup ssh" + eval "$(ssh-agent)" + ssh-add /github/workspace/.ssh/automation_ssh_key + + source ./library.sh + + ssh "${SSH_OPTIONS[@]}" "root@${SERVER_ADDRESS}" cat /etc/os-release | grep 'VERSION_ID="11"' || { + echo "Skipping dist-upgrade - can't upgrade from Debian $(ssh "${SSH_OPTIONS[@]}" "root@${SERVER_ADDRESS}" grep 'VERSION_ID=' /etc/os-release)" echo "skipped=yes" | tee -a $GITHUB_OUTPUT exit 0 } - ssh "${SSH_OPTIONS[@]}" "root@${SERVER_ADDRESS}" bash -c 'ncp-dist-upgrade' + ssh "${SSH_OPTIONS[@]}" "root@${SERVER_ADDRESS}" DEBIAN_FRONTEND=noninteractive ncp-dist-upgrade echo "skipped=no" | tee -a $GITHUB_OUTPUT - name: Run integration tests @@ -307,6 +316,8 @@ jobs: echo "===========================================" ssh "${SSH_OPTIONS[@]}" "root@${SERVER_ADDRESS}" tail /var/log/ncp.log; echo "===========================================" + echo "and nextcloud.log:" + ssh "${SSH_OPTIONS[@]}" "root@${SERVER_ADDRESS}" tail /opt/ncdata/data/nextcloud.log; exit 1 } diff --git a/bin/ncp-dist-upgrade.d/debian-11.sh b/bin/ncp-dist-upgrade.d/debian-11.sh index 2e22c4061..1462f796b 100644 --- a/bin/ncp-dist-upgrade.d/debian-11.sh +++ b/bin/ncp-dist-upgrade.d/debian-11.sh @@ -1,13 +1,11 @@ #!/bin/bash -set -eu -o pipefail +set -eux -o pipefail new_cfg=/usr/local/etc/ncp-recommended.cfg [[ -f "${new_cfg}" ]] || { echo "Already on the lastest recommended distribution. Abort." >&2; exit 1; } -export DEBIAN_FRONTEND=noninteractive - echo " >>> ATTENTION <<< This is a dangerous process that is only guaranteed to work properly if you @@ -19,8 +17,16 @@ The current distribution will keep receiving updates for some time. Do you want to continue? [y/N]" -read -n1 -r key -[[ "${key,,}" == y ]] || exit 0 +if [[ "$DEBIAN_FRONTEND" == "noninteractive" ]] +then + echo "Noninteractive environment detected. Automatically proceeding in 30 seconds..." + sleep 30 +else + read -n1 -r key + [[ "${key,,}" == y ]] || exit 0 +fi + +export DEBIAN_FRONTEND=noninteractive source /usr/local/etc/library.sh save_maintenance_mode @@ -40,7 +46,7 @@ do done apt-get update && apt-get upgrade -y --without-new-pkgs # Required to avoid breakage of /etc/resolv.conf -apt-get install -y --no-install-recommends systemd-resolved && systemctl enable --now systemd-resolved +#apt-get install -y --no-install-recommends systemd-resolved && systemctl enable --now systemd-resolved apt-get full-upgrade -y restore_maintenance_mode