From 92ce79bc7ae669aa6a95ad333bc1e45368a47c9a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Tue, 31 Jan 2023 23:37:58 +0100 Subject: [PATCH] board/common: add simple 'hostnm' script to change system hostname Signed-off-by: Joachim Wiberg --- board/common/rootfs/bin/hostnm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 board/common/rootfs/bin/hostnm diff --git a/board/common/rootfs/bin/hostnm b/board/common/rootfs/bin/hostnm new file mode 100755 index 00000000..0875be2a --- /dev/null +++ b/board/common/rootfs/bin/hostnm @@ -0,0 +1,16 @@ +#!/bin/sh +# Changes hostname in /etc/hostname and /etc/hosts + +current=$(cat /etc/hostname) +newname=$1 + +[ -n "$newname" ] || exit 1 + +sed -i "s/$current/$newname/" /etc/hosts +sed -i "s/$current/$newname/" /etc/hostname + +hostname $newname + +initctl touch sysklogd +initctl touch dnsmasq +initctl reload