From dc4c9510d0ed2ee57236a07eddf307430826d149 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Mon, 30 Oct 2023 14:32:59 +0100 Subject: [PATCH] fix: [0km] make ``vps-install`` catch key in more scenario and error message more clear The new way doesn't overwrite ``$out`` which helps displaying a meaningful message. The change allows also stdout and stderr mixing, that would not guarantee that the key appears as the last command. --- bin/0km | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/0km b/bin/0km index c9d19ff..e1171e6 100755 --- a/bin/0km +++ b/bin/0km @@ -768,10 +768,17 @@ vps_install_backup() { return 1 fi - out="${out%$'\n'}" - out="${out#*$'\n'}" - key="${out%\'*}" - key="${key##*\'}" + ## Format of output: + ## + ## II Entry for service rsync-backup is already present in '/opt/apps/myc-deploy/compose.yml'. + ## II You can run this following command from an host having admin access to core-07.0k.io: + ## (Or send it to a backup admin of core-07.0k.io) + ## ssh -p 10023 myadmin@core-07.0k.io ssh-key add 'ssh-rsa AAAAAAAD...QCJ\ + ## 8HH6pVgEpu1twyxpr9xTt7eh..WaJdgPoxmiEwGfjMMNGxs39ggOTKUuSFSmOv8TiA1fzY\ + ## s85hF...dKP1qByJU1k= compose@odoo.sikle.fr' + + key="ssh-rsa ${out##*\'ssh-rsa }" ## remove everything before last "'ssh-rsa" + key="${key%\'*}" ## remove everything after last ' if ! [[ "$key" =~ ^"ssh-rsa "[a-zA-Z0-9/+=]+" "[a-zA-Z0-9._-]+"@"[a-zA-Z0-9._-]+$ ]]; then err "Unexpected output from 'vps install backup $server'. Can't find key."