2022-03-21 15:55:33 +01:00
#!/bin/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-03-21 22:25:15 +01:00
set_keyboard( ) {
if [ [ -e /usr/bin/km ] ] ; then
km --setup && NEXTITEM = "1"
elif [ [ -e /usr/bin/archboot-km.sh ] ] ; then
archboot-km.sh --setup && NEXTITEM = "1"
2012-04-10 09:24:26 +02:00
else
2022-03-21 22:25:15 +01:00
DIALOG --msgbox "Error:\nkm script not found, aborting keyboard and console setting" 0 0
2011-02-02 20:31:49 +01:00
fi
2011-01-08 22:04:41 +01:00
}
2012-01-09 13:54:09 +01:00
select_source( ) {
2021-09-26 15:28:45 +02:00
NEXTITEM = "2"
2022-03-19 17:04:30 +01:00
set_title
2022-03-18 14:51:50 +01:00
if [ [ -e " ${ LOCAL_DB } " ] ] ; then
2022-03-18 14:50:21 +01:00
getsource || return 1
else
if [ [ ${ S_NET } -eq 0 ] ] ; then
2022-01-23 10:43:53 +01:00
check_nework || return 1
2022-03-18 14:50:21 +01:00
fi
[ [ " ${ RUNNING_ARCH } " = = "x86_64" ] ] && dotesting
getsource || return 1
2009-02-11 11:00:29 +01:00
fi
2022-01-23 10:25:52 +01:00
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
2021-09-26 15:28:45 +02:00
tz --setup && NEXTITEM = "4"
2022-02-07 11:06:41 +01:00
elif [ [ -e /usr/bin/archboot-tz.sh ] ] ; then
archboot-tz.sh --setup && NEXTITEM = "4"
2009-02-11 11:00:29 +01:00
else
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( ) {
2009-02-11 11:00:29 +01:00
S_MKFSAUTO = 0
S_MKFS = 0
DONE = 0
NEXTITEM = ""
2021-10-16 09:06:06 +02:00
detect_
2011-02-04 14:34:11 +01:00
while [ [ " ${ DONE } " = "0" ] ] ; do
if [ [ -n " ${ NEXTITEM } " ] ] ; then
DEFAULT = " --default-item ${ NEXTITEM } "
2009-02-11 11:00:29 +01:00
else
DEFAULT = ""
fi
CANCEL = ""
2022-01-26 12:30:03 +01:00
#shellcheck disable=SC2086
2012-10-08 09:14:16 +02:00
dialog ${ DEFAULT } --backtitle " ${ TITLE } " --menu "Prepare Storage Drive" 12 60 5 \
"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" \
2009-02-11 11:00:29 +01:00
"4" "Set Filesystem Mountpoints" \
2011-02-04 14:34:11 +01:00
"5" "Return to Main Menu" 2>${ ANSWER } || CANCEL = "1"
NEXTITEM = " $( cat ${ ANSWER } ) "
[ [ " ${ S_MKFSAUTO } " = "1" ] ] && DONE = 1
case $( cat ${ ANSWER } ) in
2009-02-11 11:00:29 +01:00
"1" )
2009-02-11 12:03:41 +01:00
autoprepare
2011-02-04 14:34:11 +01:00
[ [ " ${ S_MKFSAUTO } " = "1" ] ] && DONE = 1
2009-02-11 11:00:29 +01:00
; ;
"2" )
partition ; ;
"3" )
create_special ; ;
"4" )
2009-02-11 22:31:52 +01:00
PARTFINISH = ""
2010-03-15 22:53:21 +01:00
ASK_MOUNTPOINTS = "1"
2009-02-11 11:00:29 +01:00
mountpoints ; ;
*)
DONE = 1 ; ;
esac
done
2011-02-04 14:34:11 +01:00
if [ [ " ${ CANCEL } " = "1" ] ] ; then
2012-07-31 16:38:20 +02:00
NEXTITEM = "4"
2021-09-26 15:28:45 +02:00
else
NEXTITEM = "5"
2009-02-11 11:00:29 +01:00
fi
}
2012-01-09 13:54:09 +01:00
configure_system( ) {
2011-06-10 16:57:49 +02:00
destdir_mounts || return 1
2009-02-11 11:00:29 +01:00
## PREPROCESSING ##
# only done on first invocation of configure_system and redone on canceled configure system
2011-02-04 14:34:11 +01:00
if [ [ ${ S_CONFIG } -eq 0 ] ] ; then
2013-07-12 12:10:40 +02:00
auto_pacman_mirror
2009-02-11 11:00:29 +01:00
auto_network
auto_parameters
2012-07-24 12:52:17 +02:00
auto_system_files
2009-02-11 11:00:29 +01:00
auto_hwdetect
fi
## END PREPROCESS ##
2010-07-12 21:18:47 +02:00
geteditor || return 1
2009-02-11 11:00:29 +01:00
FILE = ""
# main menu loop
while true; do
S_CONFIG = 0
2011-02-04 14:34:11 +01:00
if [ [ -n " ${ FILE } " ] ] ; then
DEFAULT = " --default-item ${ FILE } "
2009-02-11 11:00:29 +01:00
else
DEFAULT = ""
fi
2022-01-26 12:30:03 +01:00
#shellcheck disable=SC2086
2022-04-04 11:14:09 +02: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" \
"Return" "Return to Main Menu" 2>${ ANSWER } || break
2011-02-04 14:34:11 +01:00
FILE = " $( cat ${ ANSWER } ) "
if [ [ " ${ FILE } " = "Return" || -z " ${ FILE } " ] ] ; then # exit
2009-02-11 11:00:29 +01:00
S_CONFIG = 1
2013-02-01 19:38:49 +01:00
break
2011-02-04 14:34:11 +01:00
elif [ [ " ${ FILE } " = "/etc/mkinitcpio.conf" ] ] ; then # non-file
2022-03-21 22:25:15 +01:00
set_mkinitcpio
2011-02-04 14:34:11 +01:00
elif [ [ " ${ FILE } " = "/etc/locale.gen" ] ] ; then # non-file
2022-03-21 22:25:15 +01:00
set_locale
2011-02-04 14:34:11 +01:00
elif [ [ " ${ FILE } " = "Root-Password" ] ] ; then # non-file
2022-03-21 22:25:15 +01:00
set_password
2009-02-11 11:00:29 +01:00
else #regular file
2022-01-22 19:33:03 +01:00
${ EDITOR } " ${ DESTDIR } " " ${ FILE } "
2009-02-11 12:03:41 +01:00
fi
2009-02-11 11:00:29 +01:00
done
2011-02-04 14:34:11 +01:00
if [ [ ${ S_CONFIG } -eq 1 ] ] ; then
2009-02-11 11:00:29 +01:00
# only done on normal exit of configure menu
## POSTPROCESSING ##
# adjust time
auto_timesetting
# /etc/initcpio.conf
run_mkinitcpio
2022-04-04 09:23:30 +02:00
DIALOG --infobox "Rebuilding glibc locales ..." 3 40
2022-03-21 15:55:33 +01:00
locale_gen
2009-02-11 11:00:29 +01:00
## END POSTPROCESSING ##
2021-09-12 16:50:37 +02:00
NEXTITEM = "7"
2009-02-11 11:00:29 +01:00
fi
2008-10-20 22:39:25 +02:00
}
2012-08-06 22:34:05 +02:00
install_bootloader_menu( ) {
2022-01-05 14:45:36 +01:00
if [ [ " ${ RUNNING_ARCH } " = = "aarch64" ] ] ; then
ANSWER = "UEFI"
else
DIALOG --menu "What is your boot system type?" 10 40 2 \
"UEFI" "UEFI" \
"BIOS" "BIOS" 2>${ ANSWER } || CANCEL = 1
case $( cat ${ ANSWER } ) in
"UEFI" ) install_bootloader_uefi ; ;
"BIOS" ) install_bootloader_bios ; ;
esac
fi
2012-02-20 08:20:18 +01:00
2011-02-04 14:34:11 +01:00
if [ [ " ${ CANCEL } " = "1" ] ] ; then
2021-09-12 16:50:37 +02:00
NEXTITEM = "7"
2012-07-26 14:33:41 +02:00
else
2021-09-12 16:50:37 +02:00
NEXTITEM = "8"
2011-02-02 20:31:49 +01:00
fi
2008-10-20 22:39:25 +02:00
}
mainmenu( ) {
2011-02-04 14:34:11 +01:00
if [ [ -n " ${ NEXTITEM } " ] ] ; then
DEFAULT = " --default-item ${ NEXTITEM } "
2009-02-11 11:00:29 +01:00
else
DEFAULT = ""
fi
2022-01-26 12:30:03 +01:00
#shellcheck disable=SC2086
2011-02-04 14:34:11 +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 \
2009-02-11 11:00:29 +01:00
"0" "Set Keyboard And Console Font" \
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" \
2021-09-12 16:51:50 +02:00
"5" "Install Packages" \
"6" "Configure System" \
"7" "Install Bootloader" \
"8" "Exit Install" 2>${ ANSWER }
2011-02-04 14:34:11 +01:00
NEXTITEM = " $( cat ${ ANSWER } ) "
case $( cat ${ ANSWER } ) in
2009-02-11 11:00:29 +01:00
"0" )
set_keyboard ; ;
"1" )
2012-07-26 14:33:41 +02:00
donetwork ; ;
2009-02-11 11:00:29 +01:00
"2" )
2022-04-03 21:28:01 +02:00
select_source || return 1
2022-01-23 10:25:52 +01:00
update_environment ; ;
2009-02-11 11:00:29 +01:00
"3" )
2021-09-26 15:28:45 +02:00
set_clock ; ;
2009-02-11 11:00:29 +01:00
"4" )
2021-09-26 15:28:45 +02:00
prepare_storagedrive ; ;
2009-02-11 11:00:29 +01:00
"5" )
2012-07-26 14:33:41 +02:00
install_packages ; ;
2021-09-12 16:50:37 +02:00
"6" )
2012-07-26 14:33:41 +02:00
configure_system ; ;
2021-09-12 16:50:37 +02:00
"7" )
2012-07-26 14:33:41 +02:00
install_bootloader ; ;
2021-09-12 16:50:37 +02:00
"8" )
2022-03-21 09:31:28 +01:00
[ [ -e /tmp/.setup-running ] ] && rm /tmp/.setup-running
2009-02-11 11:00:29 +01:00
clear
echo ""
echo "If the install finished successfully, you can now type 'reboot'"
echo "to restart the system."
echo ""
exit 0 ; ;
*)
2022-03-21 09:31:28 +01:00
DIALOG --yesno "Abort Installation?" 6 40 && [ [ -e /tmp/.setup-running ] ] && rm /tmp/.setup-running && clear && exit 0
2009-02-11 11:00:29 +01:00
; ;
esac
2008-10-20 22:39:25 +02:00
}
#####################
## begin execution ##
2022-03-21 09:31:28 +01:00
if [ [ -e /tmp/.setup-running ] ] ; then
2009-02-11 11:00:29 +01:00
echo "HINT:"
2022-03-21 09:31:28 +01:00
echo "setup already runs on a different console!"
echo "Please remove /tmp/.setup-running first to launch setup!"
2009-02-11 11:00:29 +01:00
exit 1
2009-02-11 12:03:41 +01:00
fi
2022-03-21 09:31:28 +01:00
: >/tmp/.setup-running
2008-10-20 22:39:25 +02:00
: >/tmp/.setup
2022-03-19 17:04:30 +01:00
set_title
2022-04-05 07:24:52 +02:00
DIALOG --msgbox " Welcome to the 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
2008-12-14 22:05:52 +01:00
while true; do
2009-02-11 11:00:29 +01:00
mainmenu
2008-10-20 22:39:25 +02:00
done
clear
exit 0
2009-02-11 11:00:29 +01:00
2009-07-30 18:42:45 +02:00
# vim: set ts=4 sw=4 et: