From b4e5e00147a539023aa3c4433fb225876fe5cc70 Mon Sep 17 00:00:00 2001 From: natemaia Date: Sat, 12 Jan 2019 16:30:43 -0800 Subject: [PATCH] Cleanup some dialogs, improve text, and offer more output during install --- lang/english.trans | 14 +-- src/archlabs-installer | 213 +++++++++++++++++++++-------------------- 2 files changed, 115 insertions(+), 112 deletions(-) diff --git a/lang/english.trans b/lang/english.trans index 921dcd3..278bb2c 100644 --- a/lang/english.trans +++ b/lang/english.trans @@ -25,7 +25,7 @@ _NoNetwork="\nThis installer needs to be run with an active internet connection # Preparation Menu _PrepTitle="Prepare System for Install" -_PrepBody="\nFollow the below steps in order.\n\nTo begin the install, a root (/) partition must first be mounted and the system settings must be configured (UEFI systems also require a boot partition to be mounted).\n\nIf you have already created a partition table and partition(s) you can begin mounting and skip over the editing step." +_PrepBody="\nThis is the menu in which you will prepare your system for the install.\n\nTo begin the install you must first have:\n\n - A root (/) partition mounted (UEFI systems also require a seperate boot partition)\n - System settings must be configured\n - A new user must be created and the passwords set.\n\nIf you have already created your partition(s) there is no need to use the edit partition step, simply move on to mounting." _PrepLayout="Select keyboard layout" _PrepShowDev="Show device tree (optional)" _PrepParts="Edit partitions (optional)" @@ -72,29 +72,29 @@ _WMChoice="Select WMs or DEs" _WMChoiceBody="\nUse [Space] to toggle the selection of your desired window manager(s) or desktop environment(s).\n\nDepending on your choice additional packages may be installed to improve the experience." _Packages="Install Packages" -_PackageMenu="\nSelect a package category to choose packages from that category.\n\nWhen finished select '$_Done' to finalize choices and continue.\n\nAdditional packages can be added by simply re-visiting the menu, however removing choices will require starting from the beginning of the configure menu." -_PackageBody="\nUse [Space] to (de)select packages(s) to install from the list below.\n\nNOTE: Some packages may already be installed by your DE (if any) or added automatically depending on your choice of WM. Additionally, extra packages may be installed to improve the experience for another choice eg. when installing qutebrowser qt5ct (the Qt5 theme tool) will also be installed." +_PackageMenu="\nSelect a package category to choose packages from, when finished select '$_Done' to finalize choices and continue." +_PackageBody="\nUse [Space] to toggle the selection of packages(s) and press [Enter] to accept the selection.\n\nNOTE: Some packages may already be installed by your desktop environment (if any). Extra packages may also be installed for the chosen packages eg. install qutebrowser and qt5ct (the Qt5 theme tool) will also be installed." # login setup _WMLogin="Setup Login Managment" _LoginTypeBody="\nSelect which login managment to use." _AutoLoginBody="\nDo you want auto login+startx enabled?" -_WMLoginBody="\nSelect which to use as your primary login session.\n\nThis can be changed by editing your ~/.xinitrc" +_WMLoginBody="\nSelect which to use as your primary login session.\n\nThis can be changed by editing your ~/.xinitrc." # Set keymap, hwclock, local and timezone _CMapTitle="Virtual Console Keymap" _CMapBody="\nSelect virtual console keymap.\n\nVirtual console is the shell prompt before reaching a graphical environment (Xorg).\n\nIts keymap is seperate from the one used by Xorg.\n\nDefault: us" _XMapBody="\nSelect the system wide keymap, this is the keyboard layout used once a graphical environment (Xorg) is running.\n\nIf a matching virtual console keymap exists it will be used, otherwise you will be asked to pick one.\n\nDefault: us" -_LocaleBody="\nLocale determines the date, time, currency, and language.\n\nThe format is language_COUNTRY\n\neg. en_US: english United States\n en_GB: english Great Britain" +_LocaleBody="\nLocale determines the system language and currency formats.\n\nThe format for locale name structure is languagecode_COUNTRYCODE\n\neg. en_US is: english United States\n en_GB is: english Great Britain" # Configure _ConfLocale="System Language and Locale" _ConfHost="System Hostname" -_HostNameBody="\nEnter the hostname for the new system.\n\nA hostname is used to identify systems on the network.\n\nIt's restricted to alphanumeric characters (a-z, A-Z, 0-9).\nIt can contain hyphens (-) BUT NOT at the beggining or end." +_HostNameBody="\nEnter a hostname for the new system.\n\nA hostname is used to identify systems on the network.\n\nIt's restricted to alphanumeric characters (a-z, A-Z, 0-9).\nIt can contain hyphens (-) BUT NOT at the beggining or end." # Create new user and set password _UserTitle="Create New User" -_UserBody="\nEnter the name and password for your new user account.\n\nThe name must not use capital letters, contain any periods (.), end with a hyphen (-), or include any colons (:)\n\nNOTE: Use the arrow keys to switch between input fields, [Tab] to toggle between input fields and the buttons, or just press [Enter] to accept." +_UserBody="\nEnter a name and password for the new user account.\n\nThe name must not use capital letters, contain any periods (.), end with a hyphen (-), or include any colons (:)\n\nNOTE: Use the arrow keys to switch between input fields, [Tab] to toggle between input fields and the buttons, or just press [Enter] to accept." _UserSetBody="\nCreating user and setting groups..\n" _Username="Username:" _Password="Password:" diff --git a/src/archlabs-installer b/src/archlabs-installer index 8500685..96a421a 100755 --- a/src/archlabs-installer +++ b/src/archlabs-installer @@ -8,7 +8,7 @@ # Some ideas and code has been taken from other installers # AIF, Cnichi, Calamares, The Arch Wiki.. Credit where credit is due -VER="1.8.15" # version +VER="1.8.16" # version DIST="ArchLabs" # distributor MNT="/mnt" # mountpoint @@ -28,7 +28,7 @@ main() tput civis SELECTED=$(dialog --cr-wrap --stdout --backtitle "$BT" \ --title " $_PrepTitle " --default-item $SELECTED \ - --cancel-label 'Exit' --menu "$_PrepBody" 0 0 14 \ + --cancel-label 'Exit' --menu "$_PrepBody" 0 0 0 \ "1" "$_PrepShowDev" \ "2" "$_PrepParts" \ "3" "$_PrepLUKS" \ @@ -134,7 +134,8 @@ cfg_menu() fi tput civis - if ! LOCALE="$(menubox "$_ConfLocale" "$_LocaleBody" $LOCALES)"; then + if ! LOCALE="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ + --title " $_ConfLocale " --menu "$_LocaleBody" 0 0 $((LINES - 10)) $LOCALES)"; then return 1 fi @@ -156,7 +157,7 @@ mkuser() local values if ! values="$(dialog --stdout --no-cancel --separator '~' \ --ok-label "Submit" --backtitle "$BT" --title " $_UserTitle " \ - --insecure --mixedform "$_UserBody" 0 0 14 \ + --insecure --mixedform "$_UserBody" 0 0 0 \ "$_Username" 1 1 "" 1 $((${#_Username} + 2)) $COLUMNS 0 0 \ "$_Password" 2 1 "" 2 $((${#_Password} + 2)) $COLUMNS 0 1 \ "$_Password2" 3 1 "" 3 $((${#_Password2} + 2)) $COLUMNS 0 1 \ @@ -200,7 +201,8 @@ mkuser() select_keymap() { tput civis - if ! KEYMAP="$(menubox "$_PrepLayout" "$_XMapBody" \ + if ! KEYMAP="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ + --title " $_PrepLayout " --menu "$_XMapBody" 0 0 $((LINES - 10)) \ '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' \ @@ -257,7 +259,8 @@ select_timezone() return 1 fi - if ! SUBZONE="$(menubox "$_TimeZTitle" "$_TimeSubZBody" ${SUBZONES[$ZONE]})"; then + if ! SUBZONE="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ + --title " $_TimeZTitle " --menu "$_TimeSubZBody" 0 0 $((LINES - 10)) ${SUBZONES[$ZONE]})"; then return 1 fi @@ -344,7 +347,7 @@ select_packages() tput civis SELECTED=$(dialog --cr-wrap --no-cancel --stdout \ --backtitle "$BT" --title " $_Packages " \ - --default-item $SELECTED --menu "$_PackageMenu" 0 0 14 \ + --default-item $SELECTED --menu "$_PackageMenu" 0 0 0 \ 1 "Browsers" \ 2 "Editors" \ 3 "Terminals" \ @@ -388,11 +391,11 @@ select_mirrorcmd() local key="5f29642060ab983b31fdf4c2935d8c56" if hash reflector >/dev/null 2>&1; then - MIRROR_CMD="reflector --score 100 -l 50 -f 10 --sort rate --verbose" + MIRROR_CMD="reflector --score 100 -l 50 -f 5 --sort rate --verbose" yesno "$_MirrorTitle" "$_MirrorSetup" "Automatic" "Custom" && return 0 c="$(json 'country_name' "$(json 'ip' "check&?access_key=${key}&fields=ip")?access_key=${key}&fields=country_name")" - MIRROR_CMD="reflector --country $c --score 80 --latest 40 --fastest 10 --sort rate --verbose" + MIRROR_CMD="reflector --country $c --fastest 5 --sort rate --verbose" tput cnorm MIRROR_CMD="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ @@ -412,13 +415,12 @@ select_mirrorcmd() local w="https://www.archlinux.org/mirrorlist" if [[ $c ]]; then if [[ $c =~ (CA|US) ]]; then - MIRROR_CMD="curl -s '$w/?country=US&country=CA&protocol=https&use_mirror_status=on'" + MIRROR_CMD="curl -s '$w/?country=US&country=CA&use_mirror_status=on'" else - MIRROR_CMD="curl -s '$w/?country=${c}&protocol=https&use_mirror_status=on'" + MIRROR_CMD="curl -s '$w/?country=${c}&use_mirror_status=on'" fi else - local countries="country=US&country=CA&country=NZ&country=GB&country=AU" - MIRROR_CMD="curl -s '$w/?$countries&protocol=https&use_mirror_status=on'" + MIRROR_CMD="curl -s '$w/?country=US&country=CA&country=NZ&country=GB&country=AU&use_mirror_status=on'" fi fi return 0 @@ -431,7 +433,7 @@ edit_configs() tput civis local choice choice=$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ - --title " $_EditTitle " --menu "$_EditBody" 0 0 14 "$str" "-" \ + --title " $_EditTitle " --menu "$_EditBody" 0 0 0 "$str" "-" \ "keyboard" "${EDIT_FILES[keyboard]}" \ "console" "${EDIT_FILES[console]}" \ "locale" "${EDIT_FILES[locale]}" \ @@ -730,14 +732,10 @@ confirm_mount() local part="$1" local mount="$2" - if [[ $mount == "$MNT" ]]; then - local msg="Partition: $part\nMountpoint: / (root)" - else - local msg="Partition: $part\nMountpoint: ${mount#$MNT}" - fi + [[ $mount == "$MNT" ]] && local m="/ (root)" || local m="${mount#$MNT}" if [[ $(mount) == *"$mount"* ]]; then - infobox "$_MntTitle" "$_MntSucc\n$msg\n" 1 + infobox "$_MntTitle" "$_MntSucc\nPartition: $part\nMountpoint: $m\n" 1 decr_count "$part" else infobox "$_MntTitle" "$_MntFail\n$msg\n" 1 @@ -758,7 +756,6 @@ check_cryptlvm() if [[ $(lsblk -lno TYPE "$part") =~ 'crypt' ]]; then LUKS='encrypted' LUKS_NAME="${part#/dev/mapper/}" - for dev in $(awk '/lvm/ && /crypto_LUKS/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do if grep -q "$LUKS_NAME" <<< "$(lsblk -lno NAME "$dev")"; then LUKS_DEV="$LUKS_DEV cryptdevice=$dev:$LUKS_NAME" @@ -773,11 +770,9 @@ check_cryptlvm() break fi done - elif [[ $(lsblk -lno TYPE "$part") =~ 'lvm' ]]; then LVM='logical volume' VOLUME_NAME="${part#/dev/mapper/}" - for dev in $(awk '/crypt/ && /lvm2_member/ {print "/dev/mapper/"$1}' <<< "$devs" | uniq); do if grep -q "$VOLUME_NAME" <<< "$(lsblk -lno NAME "$dev")"; then LUKS_NAME="$(sed 's~/dev/mapper/~~g' <<< "$dev")" @@ -975,11 +970,7 @@ select_swap() { # Ask user to select partition or create swapfile tput civis - if ! SWAP_PART="$(menubox "$_SelSwpSetup" "$_SelSwpBody" \ - "$_SelSwpNone" "-" \ - "$_SelSwpFile" "$SYS_MEM" \ - $PARTS)" || - [[ $SWAP_PART == "$_SelSwpNone" ]] + if ! SWAP_PART="$(menubox "$_SelSwpSetup" "$_SelSwpBody" "$_SelSwpNone" "-" "$_SelSwpFile" "$SYS_MEM" $PARTS)" || [[ $SWAP_PART == "$_SelSwpNone" ]] then SWAP_PART="" return 0 @@ -1034,8 +1025,8 @@ select_mount_opts() ssd "$part" >/dev/null 2>&1 && opts=$(sed 's/discard - off/discard - on/' <<< "$opts") tput civis - if ! MNT_OPTS="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" --title " $title " \ - --checklist "$_MntBody" 0 0 0 $opts)" || [[ $MNT_OPTS == "" ]]; then + if ! MNT_OPTS="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" --title " $title " --checklist "$_MntBody" 0 0 0 $opts)" || [[ $MNT_OPTS == "" ]] + then return 1 fi @@ -1067,6 +1058,7 @@ select_filesystem() "nilfs2" "${FS_CMDS[nilfs2]}" \ "reiserfs" "${FS_CMDS[reiserfs]}" \ "xfs" "${FS_CMDS[xfs]}")" + [[ $fs == "$_Skip" ]] && return 0 else fs="$(menubox "$_FSTitle: $part" "${msg}${part}$_FSBody" \ "ext4" "${FS_CMDS[ext4]}" \ @@ -1080,12 +1072,7 @@ select_filesystem() "reiserfs" "${FS_CMDS[reiserfs]}" \ "xfs" "${FS_CMDS[xfs]}")" fi - - if ! [[ $fs ]]; then - return 1 - elif [[ $fs == "$_Skip" ]]; then - return 0 - fi + [[ $fs ]] || return 1 if yesno "$_FSTitle" "\nFormat $part as $fs?\n" "Format" "Go Back"; then format $part $fs @@ -1186,6 +1173,7 @@ install() clear tput cnorm install_base + printf "\nGenerating system /etc/fstab\n\n" genfstab -U $MNT >$MNT/etc/fstab 2>$ERR echeck "genfstab -U $MNT >$MNT/etc/fstab" [[ -f $MNT/swapfile ]] && sed -i "s~${MNT}~~" $MNT/etc/fstab @@ -1203,21 +1191,24 @@ install() install_base() { if [[ -e /run/archiso/sfs/airootfs/etc/skel ]]; then - rsync -ahv /run/archiso/sfs/airootfs/ $MNT/ 2>/dev/null + rsync -ahv /run/archiso/sfs/airootfs/ $MNT/ 2>$ERR + echeck "rsync -ahv /run/archiso/sfs/airootfs/ $MNT/" else mirrorlist_sort - local packages pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt) + echeck "pacstrap $MNT base $KERNEL $UCODE $(grep -hv '^#' /usr/share/archlabs/installer/packages.txt)" fi - printf "\n" + printf "\nRemoving archiso remains\n\n" rm -rf $MNT/etc/mkinitcpio-archiso.conf find $MNT/usr/lib/initcpio -name 'archiso*' -type f -exec rm -rf '{}' \; sed -i 's/volatile/auto/g' $MNT/etc/systemd/journald.conf if [[ $VM ]]; then + printf "\nRemoving xorg configs in /etc/X11/xorg.conf.d/ to avoid conflict in VMs\n\n" rm -rfv $MNT/etc/X11/xorg.conf.d/*?.conf elif [[ $(lspci | grep ' VGA ' | grep 'Intel') != "" ]]; then + printf "\nCreating intel GPU 'TearFree' config in /etc/X11/xorg.conf.d/20-intel.conf\n\n" cat > $MNT/etc/X11/xorg.conf.d/20-intel.conf < $MNT/etc/locale.conf << EOF LANG=$LOCALE EOF @@ -1246,14 +1239,16 @@ LANG=$LOCALE EOF sed -i "s/#en_US.UTF-8/en_US.UTF-8/g; s/#${LOCALE}/${LOCALE}/g" $MNT/etc/locale.gen chrun "echo && locale-gen" 2>/dev/null - printf "\n" + printf "\nSetting timezone: $ZONE/$SUBZONE\n\n" chrun "ln -svf /usr/share/zoneinfo/$ZONE/$SUBZONE /etc/localtime" 2>/dev/null if [[ $BROADCOM_WL == true ]]; then + printf "\nBlacklisting modules for broadcom wireless: bmca\n\n" echo 'blacklist bcma' >> $MNT/etc/modprobe.d/blacklist.conf rm -f $MNT/etc/modprobe/ fi + printf "\nCreating keyboard configurations for keymap: $KEYMAP\n\n" cat > $MNT/etc/X11/xorg.conf.d/00-keyboard.conf < $MNT/etc/hostname << EOF $HOSTNAME EOF @@ -1290,8 +1286,11 @@ EOF create_user() { - # set root password and shell if needed + printf "\nCreating user $NEWUSER, setting passwords, and setting shell\n\n" + + # set root password, shell if needed chrun "chpasswd <<< 'root:$ROOT_PASS'" + cp -rf /etc/skel/. $MNT/root/ if [[ $MYSHELL != *zsh ]]; then chrun "usermod -s $MYSHELL root" if [[ $MYSHELL == "/usr/bin/mksh" ]]; then @@ -1403,15 +1402,23 @@ EOF login_manager() { + printf "\nSetting up $LOGIN_TYPE\n\n" SERVICE="$MNT/etc/systemd/system/getty@tty1.service.d" # remove welcome message sed -i '/printf/d' $MNT/root/.zshrc + # remove unneeded shell files from installation case $MYSHELL in - "/bin/bash") rm -rf $MNT/home/$NEWUSER/.{zsh,mksh}* ;; - "/usr/bin/mksh") rm -rf $MNT/home/$NEWUSER/.{zsh,bash}* $MNT/home/$NEWUSER/.inputrc ;; - "/usr/bin/zsh") rm -rf $MNT/home/$NEWUSER/.{bash,mksh}* $MNT/home/$NEWUSER/.inputrc ;; + "/bin/bash") + rm -rf $MNT/home/$NEWUSER/.{zsh,mksh}* $MNT/root/.{zsh,mksh}* + ;; + "/usr/bin/mksh") + rm -rf $MNT/home/$NEWUSER/.{zsh,bash}* $MNT/home/$NEWUSER/.inputrc $MNT/root/.{zsh,bash}* $MNT/root/.inputrc + ;; + "/usr/bin/zsh") + rm -rf $MNT/home/$NEWUSER/.{bash,mksh}* $MNT/home/$NEWUSER/.inputrc $MNT/root/.{bash,mksh}* $MNT/root/.inputrc + ;; esac if [[ $LOGIN_TYPE == 'lightdm' ]]; then @@ -1440,7 +1447,7 @@ mirrorlist_sort() reflector --score 100 -l 50 -f 10 --sort rate --verbose --save $MNT/etc/pacman.d/mirrorlist else { eval $MIRROR_CMD || curl -s 'https://www.archlinux.org/mirrorlist/all/'; } | - sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 10 - > $MNT/etc/pacman.d/mirrorlist + sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -v -t -n 10 - > $MNT/etc/pacman.d/mirrorlist fi } @@ -1867,7 +1874,7 @@ lvm_extra_lvs() lvm_volume_count() { if ! VOL_COUNT=$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" --title " $_LvmCreateVG " \ - --radiolist "$_LvmLvNumBody1 $VOLUME_GROUP\n$_LvmLvNumBody2" 0 0 14 \ + --radiolist "$_LvmLvNumBody1 $VOLUME_GROUP\n$_LvmLvNumBody2" 0 0 0 \ "1" "-" off "2" "-" off "3" "-" off "4" "-" off "5" "-" off \ "6" "-" off "7" "-" off "8" "-" off "9" "-" off); then return 1 @@ -2147,49 +2154,6 @@ luks_keyfile() ############################################################################### # helper functions -select_language() -{ - tput civis - local lang - lang=$(menubox "Select Language" "\nLanguage - sprache - taal - språk - lingua - idioma - nyelv - língua\n" \ - "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)" \ - "7" "Italiano (it_IT)" \ - "8" "Nederlands (nl_NL)" \ - "9" "Magyar (hu_HU)" \ - "10" "Chinese (zh_CN)") - - src $LNG/english.trans - FONT="ter-i16n" - case $lang in - 1) LOC="en_US.UTF-8" ;; - 2) src $LNG/spanish.trans && LOC="es_ES.UTF-8" ;; - 3) src $LNG/p_brasil.trans && LOC="pt_BR.UTF-8" ;; - 4) src $LNG/portuguese.trans && LOC="pt_PT.UTF-8" ;; - 5) src $LNG/french.trans && LOC="fr_FR.UTF-8" ;; - 6) src $LNG/russian.trans && LOC="ru_RU.UTF-8" FONT="LatKaCyrHeb-16" ;; - 7) src $LNG/italian.trans && LOC="it_IT.UTF-8" ;; - 8) src $LNG/dutch.trans && LOC="nl_NL.UTF-8" ;; - 9) src $LNG/hungarian.trans && LOC="hu_HU.UTF-8" FONT="lat2-16" ;; - 10) src $LNG/chinese.trans && LOC="zh_CN.UTF-8" ;; - *) die - 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 - fi - [[ $TERM == 'linux' ]] && setfont $FONT >/dev/null 2>&1 - export LANG="$LOC" - - return 0 -} - chrun() { arch-chroot $MNT /bin/bash -c "$1" @@ -2409,7 +2373,7 @@ errshow() local err err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")" - if [[ $err != "" ]]; then + if [[ $err ]]; then msgbox "$_ErrTitle" "\nERROR: $err" else msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the no error message.\n" @@ -2424,13 +2388,13 @@ echeck() local err err="$(sed 's/[^[:print:]]//g; s/\[[0-9\;:]*\?m//g; s/==> //g; s/] ERROR:/]\nERROR:/g' "$ERR")" - if [[ $err != "" ]]; then + if [[ $err ]]; then msgbox "$_ErrTitle" "\nERROR: $err" else msgbox "$_ErrTitle" "\nThe command exited abnormally: $1\n\nWith the no error message.\n" fi - [[ -e $DBG && $TERM == 'linux' ]] && more $DBG + [[ -e $DBG && $TERM == 'linux' ]] && less $DBG die 1 } @@ -2462,8 +2426,8 @@ menubox() local body="$2" shift 2 local response - if ! response="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ - --title " $title " --menu "$body" 0 0 0 "$@")"; then + if ! response="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" --title " $title " --menu "$body" 0 0 0 "$@")" + then return 1 fi printf "%s" "$response" @@ -2475,8 +2439,8 @@ checkbox() local body="$2" shift 2 local response - if ! response="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" \ - --title " $title " --checklist "$body" 0 0 0 "$@")"; then + if ! response="$(dialog --cr-wrap --no-cancel --stdout --backtitle "$BT" --title " $title " --checklist "$body" 0 0 0 "$@")" + then return 1 fi printf "%s" "$response" @@ -2486,11 +2450,9 @@ getinput() { local answer if [[ $# -eq 4 && $4 == 'nolimit' ]]; then - answer="$(dialog --cr-wrap --stdout --backtitle "$BT" \ - --title " $1 " --inputbox "$2" 0 0 "$3")" + answer="$(dialog --cr-wrap --stdout --backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")" else - answer="$(dialog --cr-wrap --max-input 63 --stdout --backtitle "$BT" \ - --title " $1 " --inputbox "$2" 0 0 "$3")" + answer="$(dialog --cr-wrap --max-input 63 --stdout --backtitle "$BT" --title " $1 " --inputbox "$2" 0 0 "$3")" fi local e=$? @@ -2510,16 +2472,57 @@ yesno() { tput civis if [[ $# -eq 5 && $5 == "no" ]]; then - dialog --cr-wrap --backtitle "$BT" --defaultno --title " $1 " \ - --yes-label "$3" --no-label "$4" --yesno "$2\n" 0 0 + dialog --cr-wrap --backtitle "$BT" --defaultno --title " $1 " --yes-label "$3" --no-label "$4" --yesno "$2\n" 0 0 elif [[ $# -eq 4 ]]; then - dialog --cr-wrap --backtitle "$BT" --title " $1 " --yes-label "$3" \ - --no-label "$4" --yesno "$2\n" 0 0 + dialog --cr-wrap --backtitle "$BT" --title " $1 " --yes-label "$3" --no-label "$4" --yesno "$2\n" 0 0 else dialog --cr-wrap --backtitle "$BT" --title " $1 " --yesno "$2\n" 0 0 fi } +select_language() +{ + tput civis + local lang + lang=$(menubox "Select Language" "\nLanguage - sprache - taal - språk - lingua - idioma - nyelv - língua\n" \ + "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)" \ + "7" "Italiano (it_IT)" \ + "8" "Nederlands (nl_NL)" \ + "9" "Magyar (hu_HU)" \ + "10" "Chinese (zh_CN)") + + src $LNG/english.trans + FONT="ter-i16n" + case $lang in + 1) LOC="en_US.UTF-8" ;; + 2) src $LNG/spanish.trans && LOC="es_ES.UTF-8" ;; + 3) src $LNG/p_brasil.trans && LOC="pt_BR.UTF-8" ;; + 4) src $LNG/portuguese.trans && LOC="pt_PT.UTF-8" ;; + 5) src $LNG/french.trans && LOC="fr_FR.UTF-8" ;; + 6) src $LNG/russian.trans && LOC="ru_RU.UTF-8" FONT="LatKaCyrHeb-16" ;; + 7) src $LNG/italian.trans && LOC="it_IT.UTF-8" ;; + 8) src $LNG/dutch.trans && LOC="nl_NL.UTF-8" ;; + 9) src $LNG/hungarian.trans && LOC="hu_HU.UTF-8" FONT="lat2-16" ;; + 10) src $LNG/chinese.trans && LOC="zh_CN.UTF-8" ;; + *) die + 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 + fi + [[ $TERM == 'linux' ]] && setfont $FONT >/dev/null 2>&1 + export LANG="$LOC" + + return 0 +} + ############################################################################### # entry point