}
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
}
. ./_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}"
. ./_misc.sh
abort_if_not_user root
+abort_if_offline
# Mount secrets device and copy over its content.
abort_if_exists "${PATH_SECRETS}"
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"
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}"