From: Christian Heller Date: Tue, 11 Mar 2025 15:23:32 +0000 (+0100) Subject: Add online tests. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%22https:/validator.w3.org/blog?a=commitdiff_plain;h=5fcb1dc43970246cec4748ee491f89548f9f8f3b;p=config Add online tests. --- diff --git a/testing/scripts/_misc.sh b/testing/scripts/_misc.sh index 7520e9d..760dda7 100644 --- a/testing/scripts/_misc.sh +++ b/testing/scripts/_misc.sh @@ -39,8 +39,15 @@ abort_if_exists() { } abort_if_not_user() { -if [ `whoami` != "$1" ]; then - echo "Must be run as $1." - exit 1 -fi + if [ `whoami` != "$1" ]; then + echo "Must be run as $1." + exit 1 + fi +} + +abort_if_offline() { + if ! ping -c1 -W2 1.1.1.1 > /dev/null 2>&1; then + echo "Must be run online." + exit 1 + fi } diff --git a/testing/scripts/setup_desktop.sh b/testing/scripts/setup_desktop.sh index d5b5b14..f954302 100755 --- a/testing/scripts/setup_desktop.sh +++ b/testing/scripts/setup_desktop.sh @@ -4,6 +4,7 @@ set -x . ./_misc.sh expect_min_n_args 1 "(system name)" "$@" +abort_if_offline get_system_name_arg "$1" MIN_MODULES="all ${system_class_name} ${system_name}" diff --git a/testing/scripts/setup_secrets_root.sh b/testing/scripts/setup_secrets_root.sh index 413eb0e..2a8f8f2 100755 --- a/testing/scripts/setup_secrets_root.sh +++ b/testing/scripts/setup_secrets_root.sh @@ -3,6 +3,7 @@ set -e . ./_misc.sh abort_if_not_user root +abort_if_offline # Mount secrets device and copy over its content. abort_if_exists "${PATH_SECRETS}" diff --git a/testing/scripts/setup_secrets_user.sh b/testing/scripts/setup_secrets_user.sh index cf09477..40ee16e 100755 --- a/testing/scripts/setup_secrets_user.sh +++ b/testing/scripts/setup_secrets_user.sh @@ -2,9 +2,6 @@ set -e . ./_misc.sh -# to remind user to go online if not yet done -# TODO: replace by actual test -nmtui BORG_PASSPHRASE="$1" PATH_REPOS="${HOME}/repos" @@ -14,6 +11,7 @@ REMOTE_PATH_REPOS=/var/repos NAME_BORGAPP=borgplom abort_if_not_user "${USERNAME}" +abort_if_offline abort_if_exists "${PATH_USER_SSH}" abort_if_exists "${PATH_REPOS}" abort_if_exists "${PATH_BORGKEYS}"