Closed Stefal closed 11 months ago
"Hostname" )
hostname_current=$(cat /etc/hostname)
hostname_new=$(\
dialog --no-cancel --title " Change hostname " --backtitle "$BACKTITLE" --inputbox "\nType new hostname\n " 10 50 $hostname_current \
3>&1 1>&2 2>&3 3>&- \
)
if [[ $? = 0 && -n $hostname_new ]]; then
sed -i "s/$hostname_current/$hostname_new/g" /etc/hosts
sed -i "s/$hostname_current/$hostname_new/g" /etc/hostname
hostname $hostname_new
systemctl restart systemd-logind.service
dialog --title " Info " --backtitle "$BACKTITLE" --no-collapse --msgbox "\nYou need to logout to make the changes effective." 7 53
fi
;;
the script write the new hostname in /etc/hostname but doesn't change /etc/hosts