Create ssh key only if necessary

This commit is contained in:
Manuel Thalmann 2024-12-05 09:47:32 +01:00
parent 751fdc3561
commit 8096e627ff

View file

@ -37,12 +37,6 @@ function initBackupConfig -V dir -d "Fetches the configuration by prompting the
"Please specify the path to the directory to load the backup from: " \
"Please specify the path to the backup directory: "
if [ -z "$$keyVar" ]
set -gx "$keyVar" "$keyPath"
sudo mkdir -p (dirname "$keyPath")
sudo ssh-keygen -f "$$keyVar" -N ""
end
if $confirm $ssh[$index] n
read -gxP $server[$index] VALHALLA_BACKUP_SERVER
read -gxP $port[$index] VALHALLA_BACKUP_SERVER_PORT
@ -52,6 +46,12 @@ function initBackupConfig -V dir -d "Fetches the configuration by prompting the
if [ -n "$VALHALLA_BACKUP_SERVER" ]
set -l sshArgs
if [ -z "$$keyVar" ]
set -gx "$keyVar" "$keyPath"
sudo mkdir -p (dirname "$keyPath")
sudo ssh-keygen -f "$$keyVar" -N ""
end
if [ -n "$VALHALLA_BACKUP_SERVER_PORT" ]
set -a sshArgs -p "$VALHALLA_BACKUP_SERVER_PORT"
end