archboot/usr/bin/archboot-setup.sh

224 lines
7.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2022-03-22 11:33:22 +01:00
# source base and common first, contains basic parameters
2022-03-22 08:26:51 +01:00
. /usr/lib/archboot/installer/base.sh
2022-03-22 11:33:22 +01:00
. /usr/lib/archboot/installer/common.sh
2022-03-22 08:26:51 +01:00
# source all other functions
2022-03-22 07:32:37 +01:00
. /usr/lib/archboot/installer/autoconfiguration.sh
. /usr/lib/archboot/installer/autoprepare.sh
. /usr/lib/archboot/installer/blockdevices.sh
. /usr/lib/archboot/installer/bootloader.sh
. /usr/lib/archboot/installer/btrfs.sh
. /usr/lib/archboot/installer/configuration.sh
. /usr/lib/archboot/installer/mountpoints.sh
. /usr/lib/archboot/installer/network.sh
. /usr/lib/archboot/installer/pacman.sh
. /usr/lib/archboot/installer/partition.sh
. /usr/lib/archboot/installer/storage.sh
2022-11-28 08:49:35 +01:00
set_vconsole() {
2022-03-21 22:25:15 +01:00
if [[ -e /usr/bin/km ]]; then
2023-01-07 21:57:50 +01:00
km --setup && _NEXTITEM="1"
2022-03-21 22:25:15 +01:00
elif [[ -e /usr/bin/archboot-km.sh ]]; then
2023-01-07 21:57:50 +01:00
archboot-km.sh --setup && _NEXTITEM="1"
else
2023-01-08 22:03:15 +01:00
_dialog --msgbox "Error:\nkm script not found, aborting console and keyboard setting." 0 0
fi
}
2012-01-09 13:54:09 +01:00
select_source() {
2021-09-26 15:28:45 +02:00
NEXTITEM="2"
2023-01-08 22:03:15 +01:00
_set_title
2023-01-07 21:57:50 +01:00
if [[ -e "${_LOCAL_DB}" ]]; then
2022-03-18 14:50:21 +01:00
getsource || return 1
else
2023-01-07 21:57:50 +01:00
if [[ ${_S_NET} -eq 0 ]]; then
check_nework || return 1
2022-03-18 14:50:21 +01:00
fi
2023-01-07 21:57:50 +01:00
[[ "${_RUNNING_ARCH}" == "x86_64" ]] && dotesting
2022-03-18 14:50:21 +01:00
getsource || return 1
fi
NEXTITEM="3"
}
2012-01-09 13:54:09 +01:00
set_clock() {
2011-02-03 21:54:43 +01:00
if [[ -e /usr/bin/tz ]]; then
2023-01-07 21:57:50 +01:00
tz --setup && _NEXTITEM="4"
2022-02-07 11:06:41 +01:00
elif [[ -e /usr/bin/archboot-tz.sh ]]; then
2023-01-07 21:57:50 +01:00
archboot-tz.sh --setup && _NEXTITEM="4"
else
2023-01-08 22:03:15 +01:00
_dialog --msgbox "Error:\ntz script not found, aborting clock setting" 0 0
fi
2008-10-20 22:39:25 +02:00
}
2012-10-08 09:14:16 +02:00
prepare_storagedrive() {
2023-01-07 21:57:50 +01:00
_S_MKFSAUTO=0
_S_MKFS=0
_DONE=0
_NEXTITEM=""
while [[ "${_DONE}" = "0" ]]; do
if [[ -n "${_NEXTITEM}" ]]; then
_DEFAULT="--default-item ${_NEXTITEM}"
else
2023-01-07 21:57:50 +01:00
_DEFAULT=""
fi
2023-01-07 21:57:50 +01:00
_CANCEL=""
2022-01-26 12:30:03 +01:00
#shellcheck disable=SC2086
2023-01-07 21:57:50 +01:00
dialog ${_DEFAULT} --backtitle "${_TITLE}" --menu "Prepare Storage Drive" 12 60 5 \
2012-10-08 09:14:16 +02:00
"1" "Auto-Prepare (erases the ENTIRE storage drive)" \
"2" "Partition Storage Drives" \
2022-01-27 08:27:19 +01:00
"3" "Manage Software Raid, Lvm2 and Luks encryption" \
"4" "Set Filesystem Mountpoints" \
2023-01-07 21:57:50 +01:00
"5" "Return to Main Menu" 2>${_ANSWER} || _CANCEL="1"
_NEXTITEM="$(cat ${_ANSWER})"
[[ "${_S_MKFSAUTO}" = "1" ]] && _DONE=1
case $(cat ${_ANSWER}) in
"1")
2023-01-08 21:56:01 +01:00
_autoprepare
2023-01-07 21:57:50 +01:00
[[ "${_S_MKFSAUTO}" = "1" ]] && _DONE=1
;;
"2")
partition ;;
"3")
create_special ;;
"4")
2023-01-07 21:57:50 +01:00
_PARTFINISH=""
_ASK_MOUNTPOINTS="1"
mountpoints ;;
*)
2023-01-07 21:57:50 +01:00
_DONE=1 ;;
esac
done
2023-01-07 21:57:50 +01:00
if [[ "${_CANCEL}" = "1" ]]; then
_NEXTITEM="4"
2021-09-26 15:28:45 +02:00
else
2023-01-07 21:57:50 +01:00
_NEXTITEM="5"
fi
}
2012-01-09 13:54:09 +01:00
configure_system() {
2011-06-10 16:57:49 +02:00
destdir_mounts || return 1
2022-11-29 10:20:00 +01:00
check_root_password || return 1
2023-01-08 22:03:15 +01:00
_geteditor || return 1
## PREPROCESSING ##
2022-11-29 10:20:00 +01:00
set_locale || return 1
2023-01-08 21:56:01 +01:00
_auto_mkinitcpio
## END PREPROCESS ##
2023-01-07 21:57:50 +01:00
_FILE=""
_S_CONFIG=""
# main menu loop
while true; do
2023-01-07 21:57:50 +01:00
if [[ -n "${_FILE}" ]]; then
DEFAULT="--default-item ${_FILE}"
else
DEFAULT=""
fi
2022-01-26 12:30:03 +01:00
#shellcheck disable=SC2086
2023-01-08 22:03:15 +01:00
_dialog ${_DEFAULT} --menu "Configuration" 20 60 16 \
2012-07-24 14:01:22 +02:00
"/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" \
2023-01-07 21:57:50 +01:00
"Return" "Return to Main Menu" 2>${_ANSWER} || break
_FILE="$(cat ${_ANSWER})"
if [[ "${_FILE}" = "Return" || -z "${_FILE}" ]]; then # exit
_S_CONFIG=1
break
2023-01-07 21:57:50 +01:00
elif [[ "${_FILE}" = "/etc/mkinitcpio.conf" ]]; then # non-file
2022-03-21 22:25:15 +01:00
set_mkinitcpio
2023-01-07 21:57:50 +01:00
elif [[ "${_FILE}" = "/etc/locale.gen" ]]; then # non-file
2022-11-29 11:00:06 +01:00
_auto_set_locale
2023-01-07 21:57:50 +01:00
${_EDITOR} "${_DESTDIR}""${_FILE}"
2022-11-29 10:53:16 +01:00
run_locale_gen
2023-01-07 21:57:50 +01:00
elif [[ "${_FILE}" = "Root-Password" ]]; then # non-file
2022-03-21 22:25:15 +01:00
set_password
else #regular file
2023-01-07 21:57:50 +01:00
${_EDITOR} "${_DESTDIR}""${_FILE}"
2009-02-11 12:03:41 +01:00
fi
done
2023-01-07 21:57:50 +01:00
if [[ ${_S_CONFIG} -eq 1 ]]; then
_NEXTITEM="7"
fi
2008-10-20 22:39:25 +02:00
}
mainmenu() {
2023-01-07 21:57:50 +01:00
if [[ -n "${_NEXTITEM}" ]]; then
_DEFAULT="--default-item ${_NEXTITEM}"
else
2023-01-07 21:57:50 +01:00
_DEFAULT=""
fi
2022-01-26 12:30:03 +01:00
#shellcheck disable=SC2086
2023-01-07 21:57:50 +01:00
dialog ${_DEFAULT} --backtitle "${_TITLE}" --title " MAIN MENU " \
2022-04-04 08:33:22 +02:00
--menu "Use the UP and DOWN arrows to navigate menus.\nUse TAB to switch between buttons and ENTER to select." 17 58 14 \
2022-11-28 08:49:35 +01:00
"0" "Set Console Font And Keymap" \
2012-07-26 14:33:41 +02:00
"1" "Set up Network" \
2021-09-26 15:28:45 +02:00
"2" "Select Source" \
"3" "Set Time And Date" \
"4" "Prepare Storage Drive" \
"5" "Install Packages" \
"6" "Configure System" \
"7" "Install Bootloader" \
2023-01-07 21:57:50 +01:00
"8" "Exit Install" 2>${_ANSWER}
_NEXTITEM="$(cat ${_ANSWER})"
case $(cat ${_ANSWER}) in
"0")
2022-11-28 08:49:35 +01:00
set_vconsole ;;
"1")
2012-07-26 14:33:41 +02:00
donetwork ;;
"2")
2022-04-03 21:28:01 +02:00
select_source || return 1
update_environment ;;
"3")
2021-09-26 15:28:45 +02:00
set_clock ;;
"4")
2021-09-26 15:28:45 +02:00
prepare_storagedrive ;;
"5")
2012-07-26 14:33:41 +02:00
install_packages ;;
"6")
2012-07-26 14:33:41 +02:00
configure_system ;;
"7")
2012-07-26 14:33:41 +02:00
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 ;;
*)
2023-01-08 22:03:15 +01:00
_dialog --yesno "Abort Installation?" 6 40 && [[ -e /tmp/.setup-running ]] && rm /tmp/.setup-running && clear && exit 0
;;
esac
2008-10-20 22:39:25 +02:00
}
#####################
## begin execution ##
if [[ -e /tmp/.setup-running ]]; then
2023-01-08 22:03:15 +01:00
_dialog --msgbox "Attention:\n\nSetup already runs on a different console!\nPlease remove /tmp/.setup-running first to launch setup!" 8 60
exit 1
2009-02-11 12:03:41 +01:00
fi
: >/tmp/.setup-running
2008-10-20 22:39:25 +02:00
: >/tmp/.setup
2023-01-08 22:03:15 +01:00
_set_title
_set_uefi_parameters
2022-03-19 17:04:30 +01:00
2023-01-08 22:03:15 +01:00
_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
2008-10-20 22:39:25 +02:00
while true; do
mainmenu
2008-10-20 22:39:25 +02:00
done
clear
exit 0
2009-07-30 18:42:45 +02:00
# vim: set ts=4 sw=4 et: