refactor files to edit

This commit is contained in:
Tobias Powalowski 2012-07-24 14:01:22 +02:00
parent a77ef7118c
commit 48ab288c0c

View file

@ -4939,56 +4939,44 @@ configure_system() {
else
DEFAULT=""
fi
if [[ "${SYSTEMD}" = "1" ]]; then
DIALOG ${DEFAULT} --menu "Configuration" 23 80 18 \
"/etc/hostname" "System Hostname" \
"/etc/vconsole.conf" "Virtual Console" \
"/etc/locale.conf" "Locale Setting" \
"/etc/timezone" "Timezone Setting" \
"/etc/fstab" "Filesystem Mountpoints" \
"/etc/mkinitcpio.conf" "Initramfs Config" \
"/etc/modprobe.d/modprobe.conf" "Kernel Modules" \
"/etc/resolv.conf" "DNS Servers" \
"/etc/hosts" "Network Hosts" \
"/etc/locale.gen" "Glibc Locales" \
"/etc/pacman.d/mirrorlist" "Pacman Mirror List" \
"/etc/pacman.conf" "Pacman Config File" \
"Root-Password" "Set the root password" \
"Return" "Return to Main Menu" 2>${ANSWER} || break
else
DIALOG ${DEFAULT} --menu "Configuration" 24 80 19 \
"/etc/rc.conf" "System Config" \
"/etc/hostname" "System Hostname" \
"/etc/vconsole.conf" "Virtual Console" \
"/etc/locale.conf" "Locale Setting" \
"/etc/timezone" "Timezone Setting" \
"/etc/fstab" "Filesystem Mountpoints" \
"/etc/mkinitcpio.conf" "Initramfs Config" \
"/etc/modprobe.d/modprobe.conf" "Kernel Modules" \
"/etc/resolv.conf" "DNS Servers" \
"/etc/hosts" "Network Hosts" \
"/etc/locale.gen" "Glibc Locales" \
"/etc/pacman.d/mirrorlist" "Pacman Mirror List" \
"/etc/pacman.conf" "Pacman Config File" \
"Root-Password" "Set the root password" \
"Return" "Return to Main Menu" 2>${ANSWER} || break
fi
DIALOG ${DEFAULT} --menu "Configuration" 21 80 16 \
"/etc/rc.conf" "System Config" \
"/etc/hostname" "System Hostname" \
"/etc/vconsole.conf" "Virtual Console" \
"/etc/locale.conf" "Locale Setting" \
"/etc/timezone" "Timezone Setting" \
"/etc/fstab" "Filesystem Mountpoints" \
"/etc/mkinitcpio.conf" "Initramfs Config" \
"/etc/modprobe.d/modprobe.conf" "Kernel Modules" \
"/etc/resolv.conf" "DNS Servers" \
"/etc/hosts" "Network Hosts" \
"/etc/locale.gen" "Glibc Locales" \
"/etc/pacman.d/mirrorlist" "Pacman Mirror List" \
"/etc/pacman.conf" "Pacman Config File" \
"Root-Password" "Set the root password" \
"Return" "Return to Main Menu" 2>${ANSWER} || break
FILE="$(cat ${ANSWER})"
if [[ "${FILE}" = "Return" || -z "${FILE}" ]]; then # exit
S_CONFIG=1
break
elif [[ "${FILE}" = "/etc/rc.conf" || "${FILE}" = "/etc/hostname" ]]; 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...
elif [[ "${FILE}" = "/etc/rc.conf" ]]; then # non-file
if [[ "${SYSTEMD}" = "1" ]]; then
DIALOG --msgbox "You use systemd. This file has no function on systemd systems." 18 70
else
${EDITOR} ${DESTDIR}${FILE}
HOSTNAME=$(cat ${DESTDIR}${FILE})
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
fi
elif [[ "${FILE}" = "/etc/hostname" ]]; then # non-file
# if user edited /etc/hostname, 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...
${EDITOR} ${DESTDIR}${FILE}
HOSTNAME=$(cat ${DESTDIR}${FILE})
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
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
HOOK_ERROR=""