Skip to content

Commit

Permalink
fix: edit hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
NichArchA82 authored Jun 23, 2024
1 parent 7dc0a49 commit cd0092f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion i-prox-deb-1-of-3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
reboot now

0 comments on commit cd0092f

Please sign in to comment.