Stefal / build

Armbian Linux build framework
https://www.armbian.com
GNU General Public License v2.0
1 stars 0 forks source link

hostname is wrong in /etc/hosts #2

Closed Stefal closed 11 months ago

Stefal commented 2 years ago

the script write the new hostname in /etc/hostname but doesn't change /etc/hosts

Stefal commented 2 years ago

See https://github.com/armbian/config/blob/909277b2aeaf33d317bd3b17633df9ecabaabef8/debian-config-jobs#L861-L874

    "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
    ;;