From a6414a60a29d2116a4fbec9974263a64a27d7adf Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 23 Nov 2024 17:26:12 +0100 Subject: [PATCH] Skip backup questions if specified --- scripts/Common/OS/backup.fish | 44 ++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/scripts/Common/OS/backup.fish b/scripts/Common/OS/backup.fish index fdc80540..d0760dfa 100644 --- a/scripts/Common/OS/backup.fish +++ b/scripts/Common/OS/backup.fish @@ -14,31 +14,33 @@ function backupAction -V dir set -l deployScript (getDeploymentScript) - if fish "$dir/../../../lib/modules/partition/confirm.fish" "Do you wish to store the backup on an SSH server?" n - read -xP "Please specify the host name of the SSH server: " VALHALLA_BACKUP_SERVER - read -xP "Please specify the port of the SSH server (default 22): " VALHALLA_BACKUP_SERVER_PORT - read -xP "Please specify the name of the user to log in to the SSH server: " VALHALLA_BACKUP_SERVER_USER - - if [ -z "$VALHALLA_BACKUP_SERVER_PORT" ] - set -x VALHALLA_BACKUP_SERVER_PORT 22 + if [ -z "$VALHALLA_BACKUP_DIR" ] + if fish "$dir/../../../lib/modules/partition/confirm.fish" "Do you wish to store the backup on an SSH server?" n + read -xP "Please specify the host name of the SSH server: " VALHALLA_BACKUP_SERVER + read -xP "Please specify the port of the SSH server (default 22): " VALHALLA_BACKUP_SERVER_PORT + read -xP "Please specify the name of the user to log in to the SSH server: " VALHALLA_BACKUP_SERVER_USER + + if [ -z "$VALHALLA_BACKUP_SERVER_PORT" ] + set -x VALHALLA_BACKUP_SERVER_PORT 22 + end + + if [ -n "$VALHALLA_BACKUP_SERVER_USER" ] + set -x VALHALLA_BACKUP_SERVER "$VALHALLA_BACKUP_SERVER_USER@$VALHALLA_BACKUP_SERVER" + end + + echo + echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)" + echo "For a seamless experience, please make sure that you are able to establish an unattended ssh connection using key authentication." + echo + echo "$(tput bold)This command should succeed without user interaction:$(tput sgr0)" + echo "ssh -o PasswordAuthentication=no -p $VALHALLA_BACKUP_SERVER_PORT $VALHALLA_BACKUP_SERVER true" + read -P "Press enter once you're done: " + echo end - if [ -n "$VALHALLA_BACKUP_SERVER_USER" ] - set -x VALHALLA_BACKUP_SERVER "$VALHALLA_BACKUP_SERVER_USER@$VALHALLA_BACKUP_SERVER" - end - - echo - echo "$(tput setaf 3)==== WARNING ====$(tput sgr0)" - echo "For a seamless experience, please make sure that you are able to establish an unattended ssh connection using key authentication." - echo - echo "$(tput bold)This command should succeed without user interaction:$(tput sgr0)" - echo "ssh -o PasswordAuthentication=no -p $VALHALLA_BACKUP_SERVER_PORT $VALHALLA_BACKUP_SERVER true" - read -P "Press enter once you're done: " - echo + read -xP "Please specify the path to the directory to save the backup to: " VALHALLA_BACKUP_DIR end - read -xP "Please specify the path to the directory to save the backup to: " VALHALLA_BACKUP_DIR - runHook backupSoftware || begin echo "Backing up software..."