From cd0092fae6135398bd94edb32739887cc8ebb6de Mon Sep 17 00:00:00 2001 From: NichArchA82 <64152648+NichArchA82@users.noreply.github.com> Date: Sat, 22 Jun 2024 20:36:49 -0600 Subject: [PATCH] fix: edit hostname --- i-prox-deb-1-of-3.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/i-prox-deb-1-of-3.sh b/i-prox-deb-1-of-3.sh index 988bf9f..43ce457 100755 --- a/i-prox-deb-1-of-3.sh +++ b/i-prox-deb-1-of-3.sh @@ -11,6 +11,9 @@ GATEWAY=$(ip route | grep default | awk '{print $3}') IP_ADDRESS=$(echo "$IP_CIDR" | cut -d'/' -f1) CIDR=$(echo "$IP_CIDR" | cut -d'/' -f2) +read -p "Enter the new host name: " NEW_HOSTNAME +CURRENT_HOSTNAME=$(hostname) + #Configure the network /ect/network/interfaces and create backup of old one cat > ~/interfaces << EOF auto lo @@ -30,6 +33,15 @@ source /etc/network/interfaces.d/* EOF +# Update /etc/hostname +echo "$NEW_HOSTNAME" > /etc/hostname + +# Update /etc/hosts +sed -i "s/\b$CURRENT_HOSTNAME\b/$NEW_HOSTNAME/g" /etc/hosts + +# Set the hostname immediately without requiring a reboot +hostnamectl set-hostname "$NEW_HOSTNAME" + #Add Repository echo "deb [arch=amd64] http://download.proxmox.com/debian/pve bookworm pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list @@ -42,4 +54,4 @@ apt update && apt full-upgrade -y #Install Proxmox kernel and reboot apt install proxmox-default-kernel -y sysctl -w kernel.panic=10 -reboot now \ No newline at end of file +reboot now