You've already forked al-installer
Add menu function to simplify things
This commit is contained in:
@ -9,12 +9,12 @@
|
||||
|
||||
# set -n
|
||||
|
||||
# shellcheck disable=2154,2034
|
||||
# shellcheck disable=2154,2034,2153
|
||||
|
||||
# globals {
|
||||
|
||||
# immutable values
|
||||
readonly VER="1.7.15" # Installer version
|
||||
readonly VER="1.7.17" # Installer version
|
||||
readonly DIST="ArchLabs" # Linux distributor
|
||||
readonly MNT="/mnt/install" # Install mountpoint
|
||||
readonly ERR="/tmp/errlog" # Built-in error log
|
||||
@ -53,8 +53,8 @@ declare -g MKINIT_HOOKS="shutdown"
|
||||
select_language() {
|
||||
tput civis
|
||||
local lang
|
||||
lang=$(dialog --cr-wrap --stdout --backtitle "$BT" --title " Select Language " --menu \
|
||||
"\nLanguage - sprache - taal - språk - lingua - idioma - nyelv - língua\n" 0 0 0 \
|
||||
local title="\nLanguage - sprache - taal - språk - lingua - idioma - nyelv - língua\n"
|
||||
lang=$(menubox "Select Language" "$title" 0 0 0 \
|
||||
"1" "English (en_**)" "2" "Español (es_ES)" \
|
||||
"3" "Português [Brasil] (pt_BR)" "4" "Português (pt_PT)" \
|
||||
"5" "Français (fr_FR)" "6" "Russkiy (ru_RU)" \
|
||||
@ -62,7 +62,6 @@ select_language() {
|
||||
"9" "Magyar (hu_HU)" "10" "Chinese (zh_CN)")
|
||||
|
||||
local srcdir="/usr/share/archlabs/installer/lang"
|
||||
|
||||
src $srcdir/english.trans
|
||||
FONT="ter-i16n"
|
||||
|
||||
@ -81,7 +80,6 @@ select_language() {
|
||||
esac
|
||||
|
||||
sed -i "s/#en_US.UTF-8/en_US.UTF-8/" /etc/locale.gen
|
||||
|
||||
if [[ $LOC != "en_US.UTF-8" ]]; then
|
||||
sed -i "s/#${LOC}/${LOC}/" /etc/locale.gen
|
||||
locale-gen >/dev/null 2>&1
|
||||
@ -159,8 +157,7 @@ user="$(openssl enc -pbkdf2 -a -d -salt -pass pass:$SALT <<< "$values" |
|
||||
|
||||
select_keymap() {
|
||||
tput civis
|
||||
if ! KEYMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_PrepLayout " --menu "$_XMapBody" 20 70 12 \
|
||||
if ! KEYMAP="$(menubox "$_PrepLayout" "$_XMapBody" 20 70 12 \
|
||||
'us' 'English' 'cm' 'English' 'gb' 'English' 'au' 'English' 'gh' 'English' \
|
||||
'za' 'English' 'ng' 'English' 'ca' 'French' 'cd' 'French' 'gn' 'French' \
|
||||
'tg' 'French' 'fr' 'French' 'de' 'German' 'at' 'German' 'ch' 'German' \
|
||||
@ -185,11 +182,10 @@ select_keymap() {
|
||||
fi
|
||||
|
||||
# when a matching console map is not available open a selection dialog
|
||||
# shellcheck disable=SC2153
|
||||
if [[ $CMAPS == *"$KEYMAP"* ]]; then
|
||||
CMAP="$KEYMAP"
|
||||
else
|
||||
if ! CMAP="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $_CMapTitle " --menu "$_CMapBody" 20 70 12 $CMAPS)"; then
|
||||
if ! CMAP="$(menubox "$_CMapTitle" "$_CMapBody" 20 70 12 $CMAPS)"; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
@ -211,15 +207,13 @@ select_timezone() {
|
||||
done
|
||||
|
||||
tput civis
|
||||
if ! ZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_TimeZTitle " --menu "$_TimeZBody" 20 70 10 \
|
||||
if ! ZONE="$(menubox "$_TimeZTitle" "$_TimeZBody" 20 70 10 \
|
||||
'America' '-' 'Australia' '-' 'Asia' '-' 'Atlantic' '-' 'Africa' '-' \
|
||||
'Europe' '-' 'Indian' '-' 'Pacific' '-' 'Arctic' '-' 'Antarctica' '-')"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! SUBZONE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_TimeZTitle " --menu "$_TimeSubZBody" 20 70 12 ${SUBZONES[$ZONE]})"; then
|
||||
if ! SUBZONE="$(menubox "$_TimeZTitle" "$_TimeSubZBody" 20 70 12 ${SUBZONES[$ZONE]})"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -272,8 +266,7 @@ select_wm_or_de() {
|
||||
if [[ $WM_NUM -eq 1 ]]; then
|
||||
LOGIN_WM="$INSTALL_WMS"
|
||||
else
|
||||
if ! LOGIN_WM="$(dialog --cr-wrap --stdout --no-cancel --backtitle "$BT" \
|
||||
--title " $_WMLogin " --menu "$_WMLoginBody" 0 0 0 $LOGIN_CHOICES)"; then
|
||||
if ! LOGIN_WM="$(menubox "$_WMLogin" "$_WMLoginBody" 0 0 0 $LOGIN_CHOICES)"; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
@ -298,8 +291,7 @@ select_wm_or_de() {
|
||||
}
|
||||
|
||||
select_login_method() {
|
||||
if ! LOGIN_TYPE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_WMLogin " --menu "$_LoginTypeBody" 0 0 0 \
|
||||
if ! LOGIN_TYPE="$(menubox "$_WMLogin" "$_LoginTypeBody" 0 0 0 \
|
||||
"xinit" "Console login without a display manager" \
|
||||
"lightdm" "Lightweight display manager with a gtk greeter")"; then
|
||||
return 1
|
||||
@ -505,24 +497,21 @@ configure_system_settings() {
|
||||
fi
|
||||
|
||||
tput civis
|
||||
# shellcheck disable=SC2153
|
||||
if ! LOCALE="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_ConfLocale " --menu "$_LocaleBody" 25 70 20 $LOCALES)"; then
|
||||
if ! LOCALE="$(menubox "$_ConfLocale" "$_LocaleBody" 25 70 20 $LOCALES)"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
select_timezone || return 1
|
||||
user_creation || return 1
|
||||
|
||||
if ! MYSHELL="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_ShellTitle " --menu "$_ShellBody" 0 0 0 '/bin/zsh' '-' '/bin/bash' '-')"; then
|
||||
tput civis
|
||||
if ! MYSHELL="$(menubox "$_ShellTitle" "$_ShellBody" 0 0 0 '/bin/zsh' '-' '/bin/bash' '-')"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
tput civis
|
||||
if [[ $HAS_NETWORK == true ]]; then
|
||||
if ! KERNEL="$(dialog --cr-wrap --stdout --backtitle "$BT" \
|
||||
--title " $_KernelTitle " --menu "$_KernelBody" 0 0 0 'linux' '-' 'linux-lts' '-')"; then
|
||||
if ! KERNEL="$(menubox "$_KernelTitle" "$_KernelBody" 0 0 0 'linux' '-' 'linux-lts' '-')"; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -606,8 +595,8 @@ main() {
|
||||
# if trying to install the system, make sure the partitions are mounted
|
||||
# and that the needed config variables and user variables have been set up
|
||||
if [[ $SELECTED ]]; then
|
||||
if [[ $SELECTED -eq 8 ]]; then
|
||||
icheck || return 1
|
||||
if [[ $SELECTED -eq 8 || $SELECTED -eq 6 ]]; then
|
||||
{ [[ $SELECTED -eq 8 ]] && icheck 1 || icheck; } || return 1
|
||||
elif [[ ($SELECTED -eq 2 || $SELECTED -eq 5) && $WARN != true ]]; then
|
||||
msgbox "$_PrepTitle" "$_WarnMount" && WARN=true
|
||||
fi
|
||||
|
Reference in New Issue
Block a user