From cb9bfa026a2009adc33221ae8451d9e6913fab8a Mon Sep 17 00:00:00 2001 From: Stonie Date: Fri, 26 Apr 2013 18:43:03 +1000 Subject: [PATCH] Adds the ability to set the hostname --- raspi-config | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/raspi-config b/raspi-config index 1175c4f..d1b9e32 100755 --- a/raspi-config +++ b/raspi-config @@ -155,6 +155,24 @@ do_change_timezone() { dpkg-reconfigure tzdata } +do_change_hostname() { + whiptail --msgbox "\ +Please note: RFCs mandate that a hostname's labels \ +may contain only the ASCII letters 'a' through 'z' (case-insensitive), +the digits '0' through '9', and the hyphen. +Hostname labels cannot begin or end with a hyphen. +No other symbols, punctuation characters, or blank spaces are permitted.\ +" 20 70 1 + + CURRENT_HOSTNAME=`cat /etc/hostname | tr -d " \t\n\r"` + NEW_HOSTNAME=$(whiptail --inputbox "Please enter a hostname" 20 60 "$CURRENT_HOSTNAME" 3>&1 1>&2 2>&3) + if [ $? -eq 0 ]; then + echo $NEW_HOSTNAME > /etc/hostname + sed -i "s/127.0.1.1.*$CURRENT_HOSTNAME/127.0.1.1\t$NEW_HOSTNAME/g" /etc/hosts + ASK_TO_REBOOT=1 + fi +} + do_memory_split() { if [ -e /boot/start_cd.elf ]; then # New-style memory split setting @@ -415,6 +433,7 @@ while true; do "change_pass" "Change password for 'pi' user" \ "change_locale" "Set locale" \ "change_timezone" "Set timezone" \ + "change_hostname" "Set hostname" \ "memory_split" "Change memory split" \ "overclock" "Configure overclocking" \ "ssh" "Enable or disable ssh server" \