Browse Source

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.
master
Valentin Lab 7 months ago
parent
commit
dc4c9510d0
  1. 15
      bin/0km

15
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."

Loading…
Cancel
Save