added automatic hostname to hosts after rc.conf edit

This commit is contained in:
Tobias Powalowski 2010-05-24 15:00:57 +02:00
parent c63266f2c6
commit ab1b1bbe52

View file

@ -3463,6 +3463,18 @@ configure_system()
if [ "$FILE" = "Return" -o -z "$FILE" ]; then # exit if [ "$FILE" = "Return" -o -z "$FILE" ]; then # exit
S_CONFIG=1 S_CONFIG=1
break break
elif [ "$FILE" = "/etc/rc.conf" ]; then # non-file
# if user edited /etc/rc.conf, add the hostname to /etc/hosts if it's not already there.
# note that if the user edits rc.conf several times to change the hostname more then once,
# we will add them all to /etc/hosts. this is not perfect, but to avoid this, too much code would be required
# (feel free to prove me wrong :))
# we could maybe do this just once after the user is really done here, but then he doesn't get
# to see the updated file while being in this menu...
HOSTNAME=$(sed -n '/^HOSTNAME/s/HOSTNAME=//p' ${DESTDIR}${FILE} | sed 's/"//g')
if ! [ "$(grep '127\.0\.0\.1' ${DESTDIR}/etc/hosts | grep -q "$HOSTNAME")" ]; then
sed -i "s/127\.0\.0\.1.*/& $HOSTNAME/" ${DESTDIR}/etc/hosts
fi
$EDITOR ${DESTDIR}${FILE}
elif [ "$FILE" = "/etc/mkinitcpio.conf" ]; then # non-file elif [ "$FILE" = "/etc/mkinitcpio.conf" ]; then # non-file
DIALOG --msgbox "The mkinitcpio.conf file controls which modules will be placed into the initramfs for your system's kernel.\n\n- Non US keymap users should add 'keymap' to HOOKS= array\n- USB keyboard users should add 'usbinput' to HOOKS= array\n- If you install under VMWARE add 'BusLogic' to MODULES= array\n- raid, lvm2, encrypt are not enabled by default\n- 2 or more disk controllers, please specify the correct module\n loading order in MODULES= array \n\nMost of you will not need to change anything in this file." 18 70 DIALOG --msgbox "The mkinitcpio.conf file controls which modules will be placed into the initramfs for your system's kernel.\n\n- Non US keymap users should add 'keymap' to HOOKS= array\n- USB keyboard users should add 'usbinput' to HOOKS= array\n- If you install under VMWARE add 'BusLogic' to MODULES= array\n- raid, lvm2, encrypt are not enabled by default\n- 2 or more disk controllers, please specify the correct module\n loading order in MODULES= array \n\nMost of you will not need to change anything in this file." 18 70
HOOK_ERROR="" HOOK_ERROR=""