Browse Source

new: [0km] allow ``vps-setup`` to bypass domain type check and force domain name change

Print an additional warning message to clarify why domain name is not
changed and how to force the change.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
rc1
Valentin Lab 3 years ago
parent
commit
ffa0edeec3
  1. 19
      bin/0km

19
bin/0km

@ -867,6 +867,10 @@ cmdline.spec::cmd:vps-setup:run() {
: :posarg: HOST 'Target host to check/fix ssh-access' : :posarg: HOST 'Target host to check/fix ssh-access'
: :optfla: --force,-f "Will force domain name change, even if
current hostname was not recognized as
an ovh domain name. "
depends sshpass shyaml depends sshpass shyaml
KEY_PATH="ssh-access.public-keys" KEY_PATH="ssh-access.public-keys"
@ -968,19 +972,22 @@ cmdline.spec::cmd:vps-setup:run() {
if ! is_ovh_domain_name "$HOST" && ! str_is_ipv4 "$HOST"; then if ! is_ovh_domain_name "$HOST" && ! str_is_ipv4 "$HOST"; then
Section Checking hostname Section Checking hostname
Elt "Checking /etc/hostname..." Elt "Checking /etc/hostname..."
if [ "$old" != "$HOST" ]; then
old="$(ssh:run "$host" -- $sudo_if_necessary cat /etc/hostname)"
Elt "Hostname is '$old'"
if is_ovh_hostname "$old"; then
Elt "Hostname '$old' --> '$HOST'"
old_etc_hostname="$(ssh:run "$host" -- $sudo_if_necessary cat /etc/hostname)"
if [ "$old_etc_hostname" != "$HOST" ]; then
Elt "/etc/hostname is '$old_etc_hostname'"
if is_ovh_hostname "$old_etc_hostname" || [ -n "$opt_force" ]; then
Elt "Hostname '$old_etc_hostname' --> '$HOST'"
print_info "creating" print_info "creating"
echo "$HOST" | ssh:run "$host" -- $sudo_if_necessary tee /etc/hostname >/dev/null && echo "$HOST" | ssh:run "$host" -- $sudo_if_necessary tee /etc/hostname >/dev/null &&
ssh:run "$host" -- $sudo_if_necessary hostname "$HOST" ssh:run "$host" -- $sudo_if_necessary hostname "$HOST"
Feedback || return 1 Feedback || return 1
else else
print_info "not changing"
Elt "Hostname '$old_etc_hostname' isn't an ovh domain"
print_info "no change"
print_status noop print_status noop
Feed Feed
warn "Domain name was not changed because it was already set"
echo " (use \`-f\` or \`--force\`) to force domain name change to $HOST." >&2
fi fi
else else

Loading…
Cancel
Save