From e19ad5163ba2d495d9e9b7ffc640081bd70661d3 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Fri, 18 Mar 2022 11:59:11 +0100 Subject: [PATCH] new: [0km] add consistency check to ``vps-setup`` for content of ``/etc/hostname`` and output of ``hostname`` Signed-off-by: Valentin Lab --- bin/0km | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/0km b/bin/0km index c5d0eb4..7f92c29 100755 --- a/bin/0km +++ b/bin/0km @@ -988,6 +988,18 @@ cmdline.spec::cmd:vps-setup:run() { print_status noop Feed fi + Elt "Checking consistency between /etc/hostname and \`hostname\`..." + etc_hostname="$(ssh:run "$host" -- $sudo_if_necessary cat /etc/hostname)" + transient_hostname="$(ssh:run "$host" -- $sudo_if_necessary hostname)" + if [ "$etc_hostname" != "$transient_hostname" ]; then + print_info "change" + ssh:run "$host" -- $sudo_if_necessary hostname "$etc_hostname" + Feedback || return 1 + else + print_info "consistent" + print_status noop + Feed + fi else info "Not changing domain as '$HOST' doesn't seem to be final domain." fi