rename functions

This commit is contained in:
Tobias Powalowski 2023-01-09 06:50:20 +01:00
parent dc55c260d3
commit 2b0b7104f8
5 changed files with 189 additions and 198 deletions

View file

@ -15,210 +15,16 @@
. /usr/lib/archboot/installer/pacman.sh
. /usr/lib/archboot/installer/partition.sh
. /usr/lib/archboot/installer/storage.sh
_set_vconsole() {
if [[ -e /usr/bin/km ]]; then
km --setup && _NEXTITEM="1"
elif [[ -e /usr/bin/archboot-km.sh ]]; then
archboot-km.sh --setup && _NEXTITEM="1"
else
_dialog --msgbox "Error:\nkm script not found, aborting console and keyboard setting." 0 0
fi
}
select_source() {
NEXTITEM="2"
_set_title
if [[ -e "${_LOCAL_DB}" ]]; then
getsource || return 1
else
if [[ ${_S_NET} -eq 0 ]]; then
check_nework || return 1
fi
[[ "${_RUNNING_ARCH}" == "x86_64" ]] && dotesting
getsource || return 1
fi
NEXTITEM="3"
}
set_clock() {
if [[ -e /usr/bin/tz ]]; then
tz --setup && _NEXTITEM="4"
elif [[ -e /usr/bin/archboot-tz.sh ]]; then
archboot-tz.sh --setup && _NEXTITEM="4"
else
_dialog --msgbox "Error:\ntz script not found, aborting clock setting" 0 0
fi
}
prepare_storagedrive() {
_S_MKFSAUTO=0
_S_MKFS=0
_DONE=0
_NEXTITEM=""
while [[ "${_DONE}" = "0" ]]; do
if [[ -n "${_NEXTITEM}" ]]; then
_DEFAULT="--default-item ${_NEXTITEM}"
else
_DEFAULT=""
fi
_CANCEL=""
#shellcheck disable=SC2086
dialog ${_DEFAULT} --backtitle "${_TITLE}" --menu "Prepare Storage Drive" 12 60 5 \
"1" "Auto-Prepare (erases the ENTIRE storage drive)" \
"2" "Partition Storage Drives" \
"3" "Manage Software Raid, Lvm2 and Luks encryption" \
"4" "Set Filesystem Mountpoints" \
"5" "Return to Main Menu" 2>${_ANSWER} || _CANCEL="1"
_NEXTITEM="$(cat ${_ANSWER})"
[[ "${_S_MKFSAUTO}" = "1" ]] && _DONE=1
case $(cat ${_ANSWER}) in
"1")
_autoprepare
[[ "${_S_MKFSAUTO}" = "1" ]] && _DONE=1
;;
"2")
partition ;;
"3")
create_special ;;
"4")
_PARTFINISH=""
_ASK_MOUNTPOINTS="1"
mountpoints ;;
*)
_DONE=1 ;;
esac
done
if [[ "${_CANCEL}" = "1" ]]; then
_NEXTITEM="4"
else
_NEXTITEM="5"
fi
}
configure_system() {
destdir_mounts || return 1
check_root_password || return 1
_geteditor || return 1
## PREPROCESSING ##
set_locale || return 1
_auto_mkinitcpio
## END PREPROCESS ##
_FILE=""
_S_CONFIG=""
# main menu loop
while true; do
if [[ -n "${_FILE}" ]]; then
DEFAULT="--default-item ${_FILE}"
else
DEFAULT=""
fi
#shellcheck disable=SC2086
_dialog ${_DEFAULT} --menu "Configuration" 20 60 16 \
"/etc/hostname" "System Hostname" \
"/etc/vconsole.conf" "Virtual Console" \
"/etc/locale.conf" "Locale 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/mkinitcpio.conf" ]]; then # non-file
set_mkinitcpio
elif [[ "${_FILE}" = "/etc/locale.gen" ]]; then # non-file
_auto_set_locale
${_EDITOR} "${_DESTDIR}""${_FILE}"
run_locale_gen
elif [[ "${_FILE}" = "Root-Password" ]]; then # non-file
set_password
else #regular file
${_EDITOR} "${_DESTDIR}""${_FILE}"
fi
done
if [[ ${_S_CONFIG} -eq 1 ]]; then
_NEXTITEM="7"
fi
}
mainmenu() {
if [[ -n "${_NEXTITEM}" ]]; then
_DEFAULT="--default-item ${_NEXTITEM}"
else
_DEFAULT=""
fi
#shellcheck disable=SC2086
dialog ${_DEFAULT} --backtitle "${_TITLE}" --title " MAIN MENU " \
--menu "Use the UP and DOWN arrows to navigate menus.\nUse TAB to switch between buttons and ENTER to select." 17 58 14 \
"0" "Set Console Font And Keymap" \
"1" "Set up Network" \
"2" "Select Source" \
"3" "Set Time And Date" \
"4" "Prepare Storage Drive" \
"5" "Install Packages" \
"6" "Configure System" \
"7" "Install Bootloader" \
"8" "Exit Install" 2>${_ANSWER}
_NEXTITEM="$(cat ${_ANSWER})"
case $(cat ${_ANSWER}) in
"0")
_set_vconsole ;;
"1")
donetwork ;;
"2")
select_source || return 1
update_environment ;;
"3")
set_clock ;;
"4")
prepare_storagedrive ;;
"5")
install_packages ;;
"6")
configure_system ;;
"7")
install_bootloader ;;
"8")
[[ -e /tmp/.setup-running ]] && rm /tmp/.setup-running
clear
echo ""
echo "If the install finished successfully, you can now type 'reboot'"
echo "to restart the system."
echo ""
exit 0 ;;
*)
_dialog --yesno "Abort Installation?" 6 40 && [[ -e /tmp/.setup-running ]] && rm /tmp/.setup-running && clear && exit 0
;;
esac
}
#####################
## begin execution ##
if [[ -e /tmp/.setup-running ]]; then
_dialog --msgbox "Attention:\n\nSetup already runs on a different console!\nPlease remove /tmp/.setup-running first to launch setup!" 8 60
exit 1
fi
: >/tmp/.setup-running
: >/tmp/.setup
_set_title
_set_uefi_parameters
_dialog --msgbox "Welcome to the Archboot Arch Linux Installation program.\n\nThe install process is fairly straightforward, and you should run through the options in the order they are presented.\n\nIf you are unfamiliar with partitioning/making filesystems, you may want to consult some documentation before continuing.\n\nYou can view all output from commands by viewing your ${_VC} console (ALT-F${_VC_NUM}). ALT-F1 will bring you back here." 14 65
while true; do
mainmenu
_mainmenu
done
clear
exit 0
# vim: set ts=4 sw=4 et:

View file

@ -1,6 +1,5 @@
#!/usr/bin/env bash
# created by Tobias Powalowski <tpowa@archlinux.org>
# _auto_fstab()
# preprocess fstab file
# comments out old fields and inserts new ones

View file

@ -25,6 +25,8 @@ _S_MKFSAUTO=0 # auto fs part/formatting
_NEXTITEM=""
# To allow choice in script set EDITOR=""
_EDITOR=""
_set_title
_set_uefi_parameters
_set_title() {
if [[ -e "${_LOCAL_DB}" ]]; then
@ -108,3 +110,187 @@ _set_guid() {
_dialog --yesno "You are running in BIOS/MBR mode.\n\nDo you want to use GUID Partition Table (GPT)?\n\nIt is a standard for the layout of the partition table on a physical storage disk. Although it forms a part of the Unified Extensible Firmware Interface (UEFI) standard, it is also used on some BIOS systems because of the limitations of MBR aka msdos partition tables, which restrict maximum disk size to 2 TiB.\n\nWindows 10 and later versions include the capability to use GPT for non-boot aka data disks (only UEFI systems can boot Windows 10 and later from GPT disks).\n\nAttention:\n- Please check if your other operating systems have GPT support!\n- Use this option for a GRUB(2) setup, which should support LVM, RAID\n etc., which doesn't fit into the usual 30k MS-DOS post-MBR gap.\n- BIOS-GPT boot may not work in some Lenovo systems (irrespective of the\n bootloader used). " 0 0 && _GUIDPARAMETER="1"
fi
}
_set_vconsole() {
if [[ -e /usr/bin/km ]]; then
km --setup && _NEXTITEM="1"
elif [[ -e /usr/bin/archboot-km.sh ]]; then
archboot-km.sh --setup && _NEXTITEM="1"
else
_dialog --msgbox "Error:\nkm script not found, aborting console and keyboard setting." 0 0
fi
}
_select_source() {
NEXTITEM="2"
_set_title
if [[ -e "${_LOCAL_DB}" ]]; then
getsource || return 1
else
if [[ ${_S_NET} -eq 0 ]]; then
check_nework || return 1
fi
[[ "${_RUNNING_ARCH}" == "x86_64" ]] && dotesting
getsource || return 1
fi
NEXTITEM="3"
}
_set_clock() {
if [[ -e /usr/bin/tz ]]; then
tz --setup && _NEXTITEM="4"
elif [[ -e /usr/bin/archboot-tz.sh ]]; then
archboot-tz.sh --setup && _NEXTITEM="4"
else
_dialog --msgbox "Error:\ntz script not found, aborting clock setting" 0 0
fi
}
_prepare_storagedrive() {
_S_MKFSAUTO=0
_S_MKFS=0
_DONE=0
_NEXTITEM=""
while [[ "${_DONE}" = "0" ]]; do
if [[ -n "${_NEXTITEM}" ]]; then
_DEFAULT="--default-item ${_NEXTITEM}"
else
_DEFAULT=""
fi
_CANCEL=""
#shellcheck disable=SC2086
dialog ${_DEFAULT} --backtitle "${_TITLE}" --menu "Prepare Storage Drive" 12 60 5 \
"1" "Auto-Prepare (erases the ENTIRE storage drive)" \
"2" "Partition Storage Drives" \
"3" "Manage Software Raid, Lvm2 and Luks encryption" \
"4" "Set Filesystem Mountpoints" \
"5" "Return to Main Menu" 2>${_ANSWER} || _CANCEL="1"
_NEXTITEM="$(cat ${_ANSWER})"
[[ "${_S_MKFSAUTO}" = "1" ]] && _DONE=1
case $(cat ${_ANSWER}) in
"1")
_autoprepare
[[ "${_S_MKFSAUTO}" = "1" ]] && _DONE=1
;;
"2")
partition ;;
"3")
create_special ;;
"4")
_PARTFINISH=""
_ASK_MOUNTPOINTS="1"
mountpoints ;;
*)
_DONE=1 ;;
esac
done
if [[ "${_CANCEL}" = "1" ]]; then
_NEXTITEM="4"
else
_NEXTITEM="5"
fi
}
_configure_system() {
destdir_mounts || return 1
check_root_password || return 1
_geteditor || return 1
## PREPROCESSING ##
set_locale || return 1
_auto_mkinitcpio
## END PREPROCESS ##
_FILE=""
_S_CONFIG=""
# main menu loop
while true; do
if [[ -n "${_FILE}" ]]; then
DEFAULT="--default-item ${_FILE}"
else
DEFAULT=""
fi
#shellcheck disable=SC2086
_dialog ${_DEFAULT} --menu "Configuration" 20 60 16 \
"/etc/hostname" "System Hostname" \
"/etc/vconsole.conf" "Virtual Console" \
"/etc/locale.conf" "Locale 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/mkinitcpio.conf" ]]; then # non-file
set_mkinitcpio
elif [[ "${_FILE}" = "/etc/locale.gen" ]]; then # non-file
_auto_set_locale
${_EDITOR} "${_DESTDIR}""${_FILE}"
run_locale_gen
elif [[ "${_FILE}" = "Root-Password" ]]; then # non-file
set_password
else #regular file
${_EDITOR} "${_DESTDIR}""${_FILE}"
fi
done
if [[ ${_S_CONFIG} -eq 1 ]]; then
_NEXTITEM="7"
fi
}
_mainmenu() {
if [[ -n "${_NEXTITEM}" ]]; then
_DEFAULT="--default-item ${_NEXTITEM}"
else
_DEFAULT=""
fi
#shellcheck disable=SC2086
dialog ${_DEFAULT} --backtitle "${_TITLE}" --title " MAIN MENU " \
--menu "Use the UP and DOWN arrows to navigate menus.\nUse TAB to switch between buttons and ENTER to select." 17 58 14 \
"0" "Set Console Font And Keymap" \
"1" "Set up Network" \
"2" "Select Source" \
"3" "Set Time And Date" \
"4" "Prepare Storage Drive" \
"5" "Install Packages" \
"6" "Configure System" \
"7" "Install Bootloader" \
"8" "Exit Install" 2>${_ANSWER}
_NEXTITEM="$(cat ${_ANSWER})"
case $(cat ${_ANSWER}) in
"0")
_set_vconsole ;;
"1")
donetwork ;;
"2")
_select_source || return 1
update_environment ;;
"3")
_set_clock ;;
"4")
_prepare_storagedrive ;;
"5")
install_packages ;;
"6")
_configure_system ;;
"7")
install_bootloader ;;
"8")
[[ -e /tmp/.setup-running ]] && rm /tmp/.setup-running
clear
echo ""
echo "If the install finished successfully, you can now type 'reboot'"
echo "to restart the system."
echo ""
exit 0 ;;
*)
_dialog --yesno "Abort Installation?" 6 40 && [[ -e /tmp/.setup-running ]] && rm /tmp/.setup-running && clear && exit 0
;;
esac
}

View file

@ -965,7 +965,7 @@ install_bootloader() {
set_device_name_scheme || return 1
fi
if [[ "${_S_SRC}" == "0" ]]; then
select_source || return 1
_select_source || return 1
fi
prepare_pacman
if [[ "${_UEFI_BOOT}" == "1" ]]; then

View file

@ -176,7 +176,7 @@ run_pacman(){
install_packages() {
destdir_mounts || return 1
if [[ "${_S_SRC}" == "0" ]]; then
select_source || return 1
_select_source || return 1
fi
prepare_pacman || return 1
_PACKAGES=""