· 9 years ago · Sep 15, 2017, 03:58 PM
1# !/bin/bash
2#
3# Arch Base Installation Framework (version 2.2.3 - 26-Mar-2016)
4#
5# Written by Carl Duff for PacBang Linux
6#
7# This program is free software, provided under the GNU General Public License
8# as published by the Free Software Foundation. So feel free to copy, distribute,
9# or modify it as you wish.
10#
11
12######################################################################
13## ##
14## Installer Variables ##
15## ##
16######################################################################
17
18# #
19# ISO Specific Variables. READ CAREFULLY FOR YOUR DISTRO #
20# #
21
22# This MUST be the same as listed in /etc/hosts
23ISO_HOST="maroto" # ISO Host Name
24
25# This MUST be the same as the live account
26ISO_USER="liveuser" # Live user account.
27
28# Call this what you like
29VERSION="Maroto Installation Framework 2.2.3" # Installer Name / Version
30
31# This should not need to be changed
32TRANS_SRC="/abif-master" # Dir where translation files are stored
33
34# #
35# Other variables for installer #
36# #
37
38# Create a temporary file to store menu selections
39ANSWER="/tmp/.abif"
40
41# Installation
42BOOTLOADER="n/a" # Which bootloader has been installed?
43KEYMAP="us" # Virtual console keymap. Default is "us"
44XKBMAP="us" # X11 keyboard layout. Default is "us"
45ZONE="" # For time
46SUBZONE="" # For time
47LOCALE="en_US.UTF-8" # System locale. Default is "en_US.UTF-8"
48
49# Architecture
50ARCHI=$(uname -m) # Display whether 32 or 64 bit system
51SYSTEM="Unknown" # Display whether system is BIOS or UEFI. Default is "unknown"
52ROOT_PART="" # ROOT partition
53UEFI_PART="" # UEFI partition
54UEFI_MOUNT="" # UEFI mountpoint
55INST_DEV="" # Device where system has been installed
56HIGHLIGHT=0 # Highlight items for Main Menu
57HIGHLIGHT_SUB=0 # Highlight items for submenus
58SUB_MENU="" # Submenu to be highlighted
59
60# Logical Volume Management
61LVM=0 # Logical Volume Management Detected?
62LVM_SEP_BOOT=0 # 1 = Seperate /boot, 2 = seperate /boot & LVM
63LVM_VG="" # Name of volume group to create or use
64LVM_VG_MB=0 # MB remaining of VG
65LVM_LV_NAME="" # Name of LV to create or use
66LV_SIZE_INVALID=0 # Is LVM LV size entered valid?
67VG_SIZE_TYPE="" # Is VG in Gigabytes or Megabytes?
68
69# LUKS
70LUKS=0 # Luks Detected?
71LUKS_DEV="" # If encrypted, partition
72LUKS_NAME="" # Name given to encrypted partition
73LUKS_UUID="" # UUID used for comparison purposes
74LUKS_OPT="" # Default or user-defined?
75
76# Installation
77MOUNTPOINT="/mnt" # Installation
78AIROOTIMG="" # Root image to install
79BYPASS="$MOUNTPOINT/bypass/" # Root image mountpoint
80BTRFS=0 # BTRFS used? "1" = btrfs alone, "2" = btrfs + subvolume(s)
81MOUNT_OPTS="/tmp/.mnt_opts" # Filesystem Mount options
82FS_OPTS="" # FS mount options available
83CHK_NUM=16 # Used for FS mount options checklist length
84
85# Language Support
86CURR_LOCALE="en_US.UTF-8" # Default Locale
87FONT="" # Set new font if necessary
88
89# Edit Files
90FILE="" # Which file is to be opened?
91
92######################################################################
93## ##
94## Core Functions ##
95## ##
96######################################################################
97
98# Add locale on-the-fly and sets source translation file for installer
99select_language() {
100
101 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " Select Language " --menu "\nLanguage / sprache / taal / sprÃ¥k / lingua / idioma / nyelv / lÃngua" 0 0 9 \
102 "1" $"English (en_**)" \
103 "2" $"Español (es_ES)" \
104 "3" $"Português [Brasil] (pt_BR)" \
105 "4" $"Português (pt_PT)" \
106 "5" $"Français (fr_FR)" \
107 "6" $"Russkiy (ru_RU)" \
108 "7" $"Italiano (it_IT)" \
109 "8" $"Nederlands (nl_NL)" \
110 "9" $"Magyar (hu_HU)" 2>${ANSWER}
111
112 case $(cat ${ANSWER}) in
113 "1") source /abif-master/english.trans
114 CURR_LOCALE="en_US.UTF-8"
115 ;;
116 "2") source /abif-master/spanish.trans
117 CURR_LOCALE="es_ES.UTF-8"
118 ;;
119 "3") source /abif-master/portuguese_brasil.trans
120 CURR_LOCALE="pt_BR.UTF-8"
121 ;;
122 "4") source /abif-master/portuguese.trans
123 CURR_LOCALE="pt_PT.UTF-8"
124 ;;
125 "5") source /abif-master/french.trans
126 CURR_LOCALE="fr_FR.UTF-8"
127 ;;
128 "6") source /abif-master/russian.trans
129 CURR_LOCALE="ru_RU.UTF-8"
130 FONT="LatKaCyrHeb-14.psfu"
131 ;;
132 "7") source /abif-master/italian.trans
133 CURR_LOCALE="it_IT.UTF-8"
134 ;;
135 "8") source /abif-master/dutch.trans
136 CURR_LOCALE="nl_NL.UTF-8"
137 ;;
138 "9") source /abif-master/hungarian.trans
139 CURR_LOCALE="hu_HU.UTF-8"
140 FONT="lat2-16.psfu"
141 ;;
142 *) exit 0
143 ;;
144 esac
145
146 # Generate the chosen locale and set the language
147 sed -i "s/#${CURR_LOCALE}/${CURR_LOCALE}/" /etc/locale.gen
148 locale-gen >/dev/null 2>&1
149 export LANG=${CURR_LOCALE}
150 [[ $FONT != "" ]] && setfont $FONT
151}
152
153
154
155# Check user is root, and that there is an active internet connection
156# Seperated the checks into seperate "if" statements for readability.
157check_requirements() {
158
159 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ChkTitle " --infobox "$_PlsWaitBody" 0 0
160 sleep 2
161
162 if [[ $(whoami) != "root" ]]; then
163 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_Erritle " --infobox "$_RtFailBody" 0 0
164 sleep 2
165 exit 1
166 fi
167
168 # The error log is also cleared, just in case something is there from a previous use of the installer.
169 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ReqMetTitle " --infobox "$_ReqMetBody" 0 0
170 sleep 2
171 clear
172 echo "" > /tmp/.errlog
173}
174
175# Adapted from AIS. Checks if system is made by Apple, whether the system is BIOS or UEFI,
176# and for LVM and/or LUKS.
177id_system() {
178
179 # Apple System Detection
180 if [[ "$(cat /sys/class/dmi/id/sys_vendor)" == 'Apple Inc.' ]] || [[ "$(cat /sys/class/dmi/id/sys_vendor)" == 'Apple Computer, Inc.' ]]; then
181 modprobe -r -q efivars || true # if MAC
182 else
183 modprobe -q efivarfs # all others
184 fi
185
186 # BIOS or UEFI Detection
187 if [[ -d "/sys/firmware/efi/" ]]; then
188 # Mount efivarfs if it is not already mounted
189 if [[ -z $(mount | grep /sys/firmware/efi/efivars) ]]; then
190 mount -t efivarfs efivarfs /sys/firmware/efi/efivars
191 fi
192 SYSTEM="UEFI"
193 else
194 SYSTEM="BIOS"
195 fi
196
197
198}
199
200
201# Adapted from AIS. An excellent bit of code!
202arch_chroot() {
203 arch-chroot $MOUNTPOINT /bin/bash -c "${1}"
204}
205
206# If there is an error, display it, clear the log and then go back to the main menu (no point in continuing).
207check_for_error() {
208
209 if [[ $? -eq 1 ]] && [[ $(cat /tmp/.errlog | grep -i "error") != "" ]]; then
210 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$(cat /tmp/.errlog)" 0 0
211 echo "" > /tmp/.errlog
212 main_menu
213 fi
214
215}
216
217# Ensure that a partition is mounted
218check_mount() {
219
220 if [[ $(lsblk -o MOUNTPOINT | grep ${MOUNTPOINT}) == "" ]]; then
221 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_ErrNoMount" 0 0
222 main_menu
223 fi
224
225}
226
227# Ensure that Arch has been installed
228check_base() {
229
230 if [[ ! -e ${MOUNTPOINT}/etc ]]; then
231 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_ErrNoBase" 0 0
232 main_menu
233 fi
234
235}
236
237# Simple code to show devices / partitions.
238show_devices() {
239 lsblk -o NAME,MODEL,TYPE,FSTYPE,SIZE,MOUNTPOINT | grep "disk\|part\|lvm\|crypt\|NAME\|MODEL\|TYPE\|FSTYPE\|SIZE\|MOUNTPOINT" > /tmp/.devlist
240 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_DevShowOpt " --textbox /tmp/.devlist 0 0
241}
242
243
244
245######################################################################
246## ##
247## Configuration Functions ##
248## ##
249######################################################################
250
251# virtual console keymap
252set_keymap() {
253
254 KEYMAPS=""
255 for i in $(ls -R /usr/share/kbd/keymaps | grep "map.gz" | sed 's/\.map\.gz//g' | sort); do
256 KEYMAPS="${KEYMAPS} ${i} -"
257 done
258
259 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_VCKeymapTitle " \
260 --menu "$_VCKeymapBody" 20 40 16 ${KEYMAPS} 2>${ANSWER} || prep_menu
261 KEYMAP=$(cat ${ANSWER})
262
263 echo -e "KEYMAP=${KEYMAP}\nFONT=${FONT}" > /tmp/vconsole.conf
264 }
265
266# Set keymap for X11
267 set_xkbmap() {
268
269 XKBMAP_LIST=""
270 keymaps_xkb=("af al am at az ba bd be bg br bt bw by ca cd ch cm cn cz de dk ee es et eu fi fo fr gb ge gh gn gr hr hu ie il in iq ir is it jp ke kg kh kr kz la lk lt lv ma md me mk ml mm mn mt mv ng nl no np pc ph pk pl pt ro rs ru se si sk sn sy tg th tj tm tr tw tz ua us uz vn za")
271
272 for i in ${keymaps_xkb}; do
273 XKBMAP_LIST="${XKBMAP_LIST} ${i} -"
274 done
275
276 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepKBLayout " --menu "$_XkbmapBody" 0 0 16 ${XKBMAP_LIST} 2>${ANSWER} || install_graphics_menu
277 XKBMAP=$(cat ${ANSWER} |sed 's/_.*//')
278 echo -e "Section "\"InputClass"\"\nIdentifier "\"system-keyboard"\"\nMatchIsKeyboard "\"on"\"\nOption "\"XkbLayout"\" "\"${XKBMAP}"\"\nEndSection" > /tmp/01-keyboard-layout.conf
279
280 setxkbmap $XKBMAP 2>/tmp/.errlog
281 check_for_error
282
283}
284
285# locale array generation code adapted from the Manjaro 0.8 installer #### removed ${MOUNTPOINT} from /etc/locale.conf and /etc/locale.gen
286set_locale() {
287
288 LOCALES=""
289 for i in $(cat /etc/locale.gen | grep -v "# " | sed 's/#//g' | sed 's/ UTF-8//g' | grep .UTF-8); do
290 LOCALES="${LOCALES} ${i} -"
291 done
292
293 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfBseSysLoc " --menu "$_localeBody" 0 0 12 ${LOCALES} 2>${ANSWER} || config_base_menu
294
295 LOCALE=$(cat ${ANSWER})
296
297 echo "LANG=\"${LOCALE}\"" > ${MOUNTPOINT}/etc/locale.conf
298 sed -i "s/#${LOCALE}/${LOCALE}/" ${MOUNTPOINT}/etc/locale.gen 2>/tmp/.errlog
299 arch_chroot "locale-gen" >/dev/null 2>>/tmp/.errlog
300 check_for_error
301}
302
303# Set Zone and Sub-Zone
304set_timezone() {
305
306 ZONE=""
307 for i in $(cat /usr/share/zoneinfo/zone.tab | awk '{print $3}' | grep "/" | sed "s/\/.*//g" | sort -ud); do
308 ZONE="$ZONE ${i} -"
309 done
310
311 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfBseTimeHC " --menu "$_TimeZBody" 0 0 10 ${ZONE} 2>${ANSWER} || config_base_menu
312 ZONE=$(cat ${ANSWER})
313
314 SUBZONE=""
315 for i in $(cat /usr/share/zoneinfo/zone.tab | awk '{print $3}' | grep "${ZONE}/" | sed "s/${ZONE}\///g" | sort -ud); do
316 SUBZONE="$SUBZONE ${i} -"
317 done
318
319 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfBseTimeHC " --menu "$_TimeSubZBody" 0 0 11 ${SUBZONE} 2>${ANSWER} || config_base_menu
320 SUBZONE=$(cat ${ANSWER})
321
322 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfBseTimeHC " --yesno "$_TimeZQ ${ZONE}/${SUBZONE}?" 0 0
323
324 if [[ $? -eq 0 ]]; then
325 arch_chroot "ln -sf /usr/share/zoneinfo/${ZONE}/${SUBZONE} /etc/localtime" 2>/tmp/.errlog
326 check_for_error
327 else
328 config_base_menu
329 fi
330}
331
332set_hw_clock() {
333
334 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfBseTimeHC " --menu "$_HwCBody" 0 0 2 \
335 "utc" "-" "localtime" "-" 2>${ANSWER}
336
337 [[ $(cat ${ANSWER}) != "" ]] && arch_chroot "hwclock --systohc --$(cat ${ANSWER})" 2>/tmp/.errlog && check_for_error
338}
339
340# Generate the installed system's FSTAB
341generate_fstab() {
342
343 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfBseFstab " --menu "$_FstabBody" 0 0 4 \
344 "genfstab -p" "$_FstabDevName" \
345 "genfstab -L -p" "$_FstabDevLabel" \
346 "genfstab -U -p" "$_FstabDevUUID" \
347 "genfstab -t PARTUUID -p" "$_FstabDevPtUUID" 2>${ANSWER}
348
349 if [[ $(cat ${ANSWER}) != "" ]]; then
350 if [[ $SYSTEM == "BIOS" ]] && [[ $(cat ${ANSWER}) == "genfstab -t PARTUUID -p" ]]; then
351 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_FstabErr" 0 0
352 generate_fstab
353 else
354 $(cat ${ANSWER}) ${MOUNTPOINT} > ${MOUNTPOINT}/etc/fstab 2>/tmp/.errlog
355 check_for_error
356 [[ -f ${MOUNTPOINT}/swapfile ]] && sed -i "s/\\${MOUNTPOINT}//" ${MOUNTPOINT}/etc/fstab
357 fi
358 fi
359
360 #### COMENTED ####
361 # Determine if there is a swapfile before copying over appropriate OB configs
362 #if [[ $(cat $MOUNTPOINT/etc/fstab | grep "swap") != "" ]]; then
363 #cp -f /inst/rc2.xml $MOUNTPOINT/etc/skel/.config/openbox/menu.xml 2>/tmp/.errlog
364 #cp -f /inst/rc2.xml $MOUNTPOINT/home/$ISO_USER/.config/openbox/menu.xml 2>/tmp/.errlog
365
366 #cp -f /inst/menu2.xml $MOUNTPOINT/etc/skel/.config/openbox/menu.xml 2>/tmp/.errlog
367 #cp -f /inst/menu2.xml $MOUNTPOINT/home/$ISO_USER/.config/openbox/menu.xml 2>/tmp/.errlog
368 #else
369 #cp -f /inst/rc.xml $MOUNTPOINT/etc/skel/.config/openbox/menu.xml 2>/tmp/.errlog
370 #cp -f /inst/rc.xml $MOUNTPOINT/home/$ISO_USER/.config/openbox/menu.xml 2>/tmp/.errlog
371
372 #cp -f /inst/menu.xml $MOUNTPOINT/etc/skel/.config/openbox/menu.xml 2>/tmp/.errlog
373 #cp -f /inst/menu.xml $MOUNTPOINT/home/$ISO_USER/.config/openbox/menu.xml 2>/tmp/.errlog
374 #fi
375 #check_for_error
376
377}
378
379# Set the installed system's hostname
380set_hostname() {
381
382 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfBseHost " --inputbox "$_HostNameBody" 0 0 "archiso" 2>${ANSWER} || config_base_menu
383
384 echo "$(cat ${ANSWER})" > ${MOUNTPOINT}/etc/hostname 2>/tmp/.errlog
385 check_for_error
386}
387
388# Set the installed system's root password
389set_root_password() {
390
391 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfUsrRoot " --clear --insecure --passwordbox "$_PassRtBody" 0 0 2> ${ANSWER} || config_base_menu
392 PASSWD=$(cat ${ANSWER})
393
394 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfUsrRoot " --clear --insecure --passwordbox "$_PassReEntBody" 0 0 2> ${ANSWER} || config_base_menu
395 PASSWD2=$(cat ${ANSWER})
396
397 if [[ $PASSWD == $PASSWD2 ]]; then
398 echo -e "${PASSWD}\n${PASSWD}" > /tmp/.passwd
399 arch_chroot "passwd root" < /tmp/.passwd >/dev/null 2>/tmp/.errlog
400 rm /tmp/.passwd
401 check_for_error
402 else
403 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_PassErrBody" 0 0
404 set_root_password
405 fi
406
407}
408
409# Create new user(s) for installed system. First user is created by renaming the live account.
410# All others are brand new.
411create_new_user() {
412
413 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_NUsrTitle " --inputbox "$_NUsrBody" 0 0 "" 2>${ANSWER} || config_base_menu
414 USER=$(cat ${ANSWER})
415
416 # Loop while user name is blank, has spaces, or has capital letters in it.
417 while [[ ${#USER} -eq 0 ]] || [[ $USER =~ \ |\' ]] || [[ $USER =~ [^a-z0-9\ ] ]]; do
418 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_NUsrTitle " --inputbox "$_NUsrErrBody" 0 0 "" 2>${ANSWER} || config_base_menu
419 USER=$(cat ${ANSWER})
420 done
421
422 # Enter password. This step will only be reached where the loop has been skipped or broken.
423 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfUsrNew " --clear --insecure --passwordbox "$_PassNUsrBody $USER\n\n" 0 0 2> ${ANSWER} || config_base_menu
424 PASSWD=$(cat ${ANSWER})
425
426 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfUsrNew " --clear --insecure --passwordbox "$_PassReEntBody" 0 0 2> ${ANSWER} || config_base_menu
427 PASSWD2=$(cat ${ANSWER})
428
429 # loop while passwords entered do not match.
430 while [[ $PASSWD != $PASSWD2 ]]; do
431 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_PassErrBody" 0 0
432
433 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfUsrNew " --clear --insecure --passwordbox "$_PassNUsrBody $USER\n\n" 0 0 2> ${ANSWER} || config_base_menu
434 PASSWD=$(cat ${ANSWER})
435
436 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfUsrNew " --clear --insecure --passwordbox "$_PassReEntBody" 0 0 2> ${ANSWER} || config_base_menu
437 PASSWD2=$(cat ${ANSWER})
438 done
439
440 # create new user. This step will only be reached where the password loop has been skipped or broken.
441 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfUsrNew " --infobox "$_NUsrSetBody" 0 0
442 sleep 2
443 echo -e "${PASSWD}\n${PASSWD}" > /tmp/.passwd
444
445 # If the first (or only) user account, then change the live account
446 if [[ -e ${MOUNTPOINT}/home/$ISO_USER ]]; then
447 arch_chroot "passwd $ISO_USER" < /tmp/.passwd >/dev/null 2>>/tmp/.errlog
448 check_for_error
449
450 # Distro-specific configuration for entered username
451 sed -i "s/$ISO_USER/$USER/g" ${MOUNTPOINT}/home/$ISO_USER/.gtkrc-2.0 2>/tmp/.errlog
452
453 # Convert live account to entered username - group, password, folder, and ownership
454 sed -i "s/$ISO_USER/$USER/g" ${MOUNTPOINT}/etc/group 2>>/tmp/.errlog
455 sed -i "s/$ISO_USER/$USER/g" ${MOUNTPOINT}/etc/gshadow 2>>/tmp/.errlog
456 sed -i "s/$ISO_USER/$USER/g" ${MOUNTPOINT}/etc/passwd 2>>/tmp/.errlog
457 sed -i "s/$ISO_USER/$USER/g" ${MOUNTPOINT}/etc/shadow 2>>/tmp/.errlog
458 mv ${MOUNTPOINT}/home/$ISO_USER ${MOUNTPOINT}/home/$USER 2>>/tmp/.errlog
459 chown -R $USER:users ${MOUNTPOINT}/home/$USER 2>>/tmp/.errlog
460
461 # Change sudoers file to require passwords for sudo commands
462 sed -i '/%wheel ALL=(ALL) ALL/s/^#//' ${MOUNTPOINT}/etc/sudoers 2>>/tmp/.errlog
463 sed -i '/%wheel ALL=(ALL) ALL NOPASSWD: ALL/s/#%wheel ALL=(ALL) ALL NOPASSWD: ALL//' ${MOUNTPOINT}/etc/sudoers 2>>/tmp/.errlog
464 sudo echo "$USER ALL=(ALL) ALL" > ${MOUNTPOINT}/etc/sudoers.d/01_user
465 check_for_error
466 else
467 # If the live account has already been changed, create a new user account
468 arch_chroot "useradd ${USER} -m -g users -G wheel,storage,power,network,video,audio,lp -s /bin/bash" 2>/tmp/.errlog
469 arch_chroot "passwd ${USER}" < /tmp/.passwd >/dev/null 2>>/tmp/.errlog
470
471 # Set up basic configuration files and ownership for new account
472 arch_chroot "cp -R /etc/skel/ /home/${USER}" 2>>/tmp/.errlog
473 arch_chroot "chown -R ${USER}:users /home/${USER}" 2>>/tmp/.errlog
474 sudo echo "$USER ALL=(ALL) ALL" > ${MOUNTPOINT}/etc/sudoers.d/01_user
475 check_for_error
476 fi
477 rm /tmp/.passwd
478}
479
480run_mkinitcpio() {
481
482 clear
483
484 KERNEL=""
485
486 # If LVM and/or LUKS used, add the relevant hook(s)
487 ([[ $LVM -eq 1 ]] && [[ $LUKS -eq 0 ]]) && sed -i 's/block filesystems/block lvm2 filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>/tmp/.errlog
488 ([[ $LVM -eq 1 ]] && [[ $LUKS -eq 1 ]]) && sed -i 's/block filesystems/block encrypt lvm2 filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>/tmp/.errlog
489 ([[ $LVM -eq 0 ]] && [[ $LUKS -eq 1 ]]) && sed -i 's/block filesystems/block encrypt filesystems/g' ${MOUNTPOINT}/etc/mkinitcpio.conf 2>/tmp/.errlog
490 check_for_error
491
492 arch_chroot "mkinitcpio -p linux" 2>>/tmp/.errlog
493 check_for_error
494
495}
496
497######################################################################
498## ##
499## System and Partitioning Functions ##
500## ##
501######################################################################
502
503
504
505# Unmount partitions.
506umount_partitions(){
507
508 MOUNTED=""
509 MOUNTED=$(mount | grep "${MOUNTPOINT}" | awk '{print $3}' | sort -r)
510 swapoff -a
511
512 for i in ${MOUNTED[@]}; do
513 umount $i >/dev/null 2>>/tmp/.errlog
514 done
515
516 check_for_error
517
518}
519
520# Revised to deal with partion sizes now being displayed to the user
521confirm_mount() {
522 if [[ $(mount | grep $1) ]]; then
523 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_MntStatusTitle " --infobox "$_MntStatusSucc" 0 0
524 sleep 2
525 PARTITIONS=$(echo $PARTITIONS | sed "s~${PARTITION} [0-9]*[G-M]~~" | sed "s~${PARTITION} [0-9]*\.[0-9]*[G-M]~~" | sed s~${PARTITION}$' -'~~)
526 NUMBER_PARTITIONS=$(( NUMBER_PARTITIONS - 1 ))
527 else
528 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_MntStatusTitle " --infobox "$_MntStatusFail" 0 0
529 sleep 2
530 prep_menu
531 fi
532}
533
534# This function does not assume that the formatted device is the Root installation device as
535# more than one device may be formatted. Root is set in the mount_partitions function.
536select_device() {
537
538 DEVICE=""
539 devices_list=$(lsblk -lno NAME,SIZE,TYPE | grep 'disk' | awk '{print "/dev/" $1 " " $2}' | sort -u);
540
541 for i in ${devices_list[@]}; do
542 DEVICE="${DEVICE} ${i}"
543 done
544
545 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_DevSelTitle " --menu "$_DevSelBody" 0 0 4 ${DEVICE} 2>${ANSWER} || prep_menu
546 DEVICE=$(cat ${ANSWER})
547
548 }
549
550# Finds all available partitions according to type(s) specified and generates a list
551# of them. This also includes partitions on different devices.
552find_partitions() {
553
554 PARTITIONS=""
555 NUMBER_PARTITIONS=0
556 partition_list=$(lsblk -lno NAME,SIZE,TYPE | grep $INCLUDE_PART | sed 's/part$/\/dev\//g' | sed 's/lvm$\|crypt$/\/dev\/mapper\//g' | awk '{print $3$1 " " $2}' | sort -u)
557
558 for i in ${partition_list}; do
559 PARTITIONS="${PARTITIONS} ${i}"
560 NUMBER_PARTITIONS=$(( NUMBER_PARTITIONS + 1 ))
561 done
562
563 # Double-partitions will be counted due to counting sizes, so fix
564 NUMBER_PARTITIONS=$(( NUMBER_PARTITIONS / 2 ))
565
566 # Deal with partitioning schemes appropriate to mounting, lvm, and/or luks.
567 case $INCLUDE_PART in
568 'part\|lvm\|crypt') # Deal with incorrect partitioning for main mounting function
569
570 if ([[ $SYSTEM == "UEFI" ]] && [[ $NUMBER_PARTITIONS -lt 2 ]]) || ([[ $SYSTEM == "BIOS" ]] && [[ $NUMBER_PARTITIONS -eq 0 ]]); then
571 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_PartErrBody" 0 0
572 create_partitions
573 fi
574 ;;
575 'part\|crypt') # Ensure there is at least one partition for LVM
576 if [[ $NUMBER_PARTITIONS -eq 0 ]]; then
577 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_LvmPartErrBody" 0 0
578 create_partitions
579 fi
580 ;;
581 'part\|lvm') # Ensure there are at least two partitions for LUKS
582 if [[ $NUMBER_PARTITIONS -lt 2 ]]; then
583 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_LuksPartErrBody" 0 0
584 create_partitions
585 fi
586 ;;
587 esac
588
589}
590
591
592# Create partitions.
593create_partitions(){
594
595# Securely destroy all data on a given device.
596secure_wipe(){
597
598 # Warn the user. If they proceed, wipe the selected device.
599 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PartOptWipe " --yesno "$_AutoPartWipeBody1 ${DEVICE} $_AutoPartWipeBody2" 0 0
600 if [[ $? -eq 0 ]]; then
601
602 clear
603 wipe -Ifre ${DEVICE}
604
605 # Alternate dd command - requires pv to be installed
606 #dd if=/dev/zero | pv | dd of=${DEVICE} iflag=nocache oflag=direct bs=4096 2>/tmp/.errlog
607 else
608 create_partitions
609 fi
610}
611
612
613# BIOS and UEFI
614auto_partition(){
615
616 # Provide warning to user
617 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepPartDisk " --yesno "$_AutoPartBody1 $DEVICE $_AutoPartBody2 $_AutoPartBody3" 0 0
618
619 if [[ $? -eq 0 ]]; then
620
621 # Find existing partitions (if any) to remove
622 parted -s ${DEVICE} print | awk '/^ / {print $1}' > /tmp/.del_parts
623
624 for del_part in $(tac /tmp/.del_parts); do
625 parted -s ${DEVICE} rm ${del_part} 2>/tmp/.errlog
626 check_for_error
627 done
628
629 # Identify the partition table
630 part_table=$(parted -s ${DEVICE} print | grep -i 'partition table' | awk '{print $3}')
631
632 # Create partition table if one does not already exist
633 ([[ $SYSTEM == "BIOS" ]] && [[ $part_table != "msdos" ]]) && parted -s ${DEVICE} mklabel msdos 2>/tmp/.errlog
634 ([[ $SYSTEM == "UEFI" ]] && [[ $part_table != "gpt" ]]) && parted -s ${DEVICE} mklabel gpt 2>/tmp/.errlog
635 check_for_error
636
637 # Create paritions (same basic partitioning scheme for BIOS and UEFI)
638 if [[ $SYSTEM == "BIOS" ]]; then
639 parted -s ${DEVICE} mkpart primary ext3 1MiB 513MiB 2>/tmp/.errlog
640 else
641 parted -s ${DEVICE} mkpart ESP fat32 1MiB 513MiB 2>/tmp/.errlog
642 fi
643
644 parted -s ${DEVICE} set 1 boot on 2>>/tmp/.errlog
645 parted -s ${DEVICE} mkpart primary ext3 513MiB 100% 2>>/tmp/.errlog
646 check_for_error
647
648 # Show created partitions
649 lsblk ${DEVICE} -o NAME,TYPE,FSTYPE,SIZE > /tmp/.devlist
650 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title "" --textbox /tmp/.devlist 0 0
651 else
652 create_partitions
653 fi
654
655}
656
657 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title "$_PartToolTitle" --menu "$_PartToolBody" 0 0 5 \
658 "$_PartOptWipe" "BIOS & UEFI" \
659 "$_PartOptAuto" "BIOS & UEFI" \
660 "gparted" "BIOS & UEFI" \
661 "cfdisk" "BIOS/MBR" \
662 "parted" "UEFI/GPT" 2>${ANSWER}
663
664 clear
665 # If something selected
666 if [[ $(cat ${ANSWER}) != "" ]]; then
667 if ([[ $(cat ${ANSWER}) != "$_PartOptWipe" ]] && [[ $(cat ${ANSWER}) != "$_PartOptAuto" ]]); then
668 $(cat ${ANSWER}) ${DEVICE}
669 else
670 [[ $(cat ${ANSWER}) == "$_PartOptWipe" ]] && secure_wipe && create_partitions
671 [[ $(cat ${ANSWER}) == "$_PartOptAuto" ]] && auto_partition
672 fi
673 fi
674
675}
676
677
678# Set static list of filesystems rather than on-the-fly. Partially as most require additional flags, and
679# partially because some don't seem to be viable.
680# Set static list of filesystems rather than on-the-fly.
681select_filesystem(){
682
683 # prep variables
684 fs_opts=""
685 CHK_NUM=0
686
687 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_FSTitle " --menu "$_FSBody" 0 0 12 \
688 "$_FSSkip" "-" \
689 "btrfs" "mkfs.btrfs -f" \
690 "ext2" "mkfs.ext2 -q" \
691 "ext3" "mkfs.ext3 -q" \
692 "ext4" "mkfs.ext4 -q" \
693 "f2fs" "mkfs.f2fs" \
694 "jfs" "mkfs.jfs -q" \
695 "nilfs2" "mkfs.nilfs2 -q" \
696 "ntfs" "mkfs.ntfs -q" \
697 "reiserfs" "mkfs.reiserfs -q" \
698 "vfat" "mkfs.vfat -F32" \
699 "xfs" "mkfs.xfs -f" 2>${ANSWER}
700
701 case $(cat ${ANSWER}) in
702 "$_FSSkip") FILESYSTEM="$_FSSkip" ;;
703 "btrfs") FILESYSTEM="mkfs.btrfs -f"
704 CHK_NUM=16
705 fs_opts="autodefrag compress=zlib compress=lzo compress=no compress-force=zlib compress-force=lzo discard noacl noatime nodatasum nospace_cache recovery skip_balance space_cache ssd ssd_spread"
706 modprobe btrfs
707 ;;
708 "ext2") FILESYSTEM="mkfs.ext2 -q" ;;
709 "ext3") FILESYSTEM="mkfs.ext3 -q" ;;
710 "ext4") FILESYSTEM="mkfs.ext4 -q"
711 CHK_NUM=8
712 fs_opts="data=journal data=writeback dealloc discard noacl noatime nobarrier nodelalloc"
713 ;;
714 "f2fs") FILESYSTEM="mkfs.f2fs"
715 fs_opts="data_flush disable_roll_forward disable_ext_identify discard fastboot flush_merge inline_xattr inline_data inline_dentry no_heap noacl nobarrier noextent_cache noinline_data norecovery"
716 CHK_NUM=16
717 modprobe f2fs
718 ;;
719 "jfs") FILESYSTEM="mkfs.jfs -q"
720 CHK_NUM=4
721 fs_opts="discard errors=continue errors=panic nointegrity"
722 ;;
723 "nilfs2") FILESYSTEM="mkfs.nilfs2 -q"
724 CHK_NUM=7
725 fs_opts="discard nobarrier errors=continue errors=panic order=relaxed order=strict norecovery"
726 ;;
727 "ntfs") FILESYSTEM="mkfs.ntfs -q" ;;
728 "reiserfs") FILESYSTEM="mkfs.reiserfs -q"
729 CHK_NUM=5
730 fs_opts="acl nolog notail replayonly user_xattr"
731 ;;
732 "vfat") FILESYSTEM="mkfs.vfat -F32" ;;
733 "xfs") FILESYSTEM="mkfs.xfs -f"
734 CHK_NUM=9
735 fs_opts="discard filestreams ikeep largeio noalign nobarrier norecovery noquota wsync"
736 ;;
737 *) prep_menu ;;
738 esac
739
740 # Warn about formatting!
741 if [[ $FILESYSTEM != $_FSSkip ]]; then
742 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_FSTitle " --yesno "\n$FILESYSTEM $PARTITION\n\n" 0 0
743 if [[ $? -eq 0 ]]; then
744 ${FILESYSTEM} ${PARTITION} >/dev/null 2>/tmp/.errlog
745 check_for_error
746 else
747 select_filesystem
748 fi
749 fi
750
751
752 }
753
754mount_partitions() {
755
756# This subfunction allows for special mounting options to be applied for relevant fs's.
757# Seperate subfunction for neatness.
758mount_opts() {
759
760 FS_OPTS=""
761 echo "" > ${MOUNT_OPTS}
762
763 for i in ${fs_opts}; do
764 FS_OPTS="${FS_OPTS} ${i} - off"
765 done
766
767 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $(echo $FILESYSTEM | sed "s/.*\.//g" | sed "s/-.*//g") " --checklist "$_btrfsMntBody" 0 0 $CHK_NUM \
768 $FS_OPTS 2>${MOUNT_OPTS}
769
770 # Now clean up the file
771 sed -i 's/ /,/g' ${MOUNT_OPTS}
772 sed -i '$s/,$//' ${MOUNT_OPTS}
773
774 # If mount options selected, confirm choice
775 if [[ $(cat ${MOUNT_OPTS}) != "" ]]; then
776 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_MntStatusTitle " --yesno "\n${_btrfsMntConfBody}$(cat ${MOUNT_OPTS})\n" 10 75
777 [[ $? -eq 1 ]] && mount_opts
778 fi
779
780}
781
782# Subfunction to save repetition of code
783mount_current_partition(){
784
785 # Make the mount directory
786 mkdir -p ${MOUNTPOINT}${MOUNT} 2>/tmp/.errlog
787
788 # Get mounting options for appropriate filesystems
789 [[ $fs_opts != "" ]] && mount_opts
790
791 # Use special mounting options if selected, else standard mount
792 if [[ $(cat ${MOUNT_OPTS}) != "" ]]; then
793 mount -o $(cat ${MOUNT_OPTS}) ${PARTITION} ${MOUNTPOINT}${MOUNT} 2>>/tmp/.errlog
794 else
795 mount ${PARTITION} ${MOUNTPOINT}${MOUNT} 2>>/tmp/.errlog
796 fi
797
798 check_for_error
799 confirm_mount ${MOUNTPOINT}${MOUNT}
800
801 # Identify if mounted partition is type "crypt" (LUKS on LVM, or LUKS alone)
802 if [[ $(lsblk -lno TYPE ${PARTITION} | grep "crypt") != "" ]]; then
803
804 # cryptname for bootloader configuration either way
805 LUKS=1
806 LUKS_NAME=$(echo ${PARTITION} | sed "s~^/dev/mapper/~~g")
807
808 # Check if LUKS on LVM (parent = lvm /dev/mapper/...)
809 cryptparts=$(lsblk -lno NAME,FSTYPE,TYPE | grep "lvm" | grep -i "crypto_luks" | uniq | awk '{print "/dev/mapper/"$1}')
810 for i in ${cryptparts}; do
811 if [[ $(lsblk -lno NAME ${i} | grep $LUKS_NAME) != "" ]]; then
812 LUKS_DEV="$LUKS_DEV cryptdevice=${i}:$LUKS_NAME"
813 LVM=1
814 break;
815 fi
816 done
817
818 # Check if LUKS alone (parent = part /dev/...)
819 cryptparts=$(lsblk -lno NAME,FSTYPE,TYPE | grep "part" | grep -i "crypto_luks" | uniq | awk '{print "/dev/"$1}')
820 for i in ${cryptparts}; do
821 if [[ $(lsblk -lno NAME ${i} | grep $LUKS_NAME) != "" ]]; then
822 LUKS_UUID=$(lsblk -lno UUID,TYPE,FSTYPE ${i} | grep "part" | grep -i "crypto_luks" | awk '{print $1}')
823 LUKS_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME"
824 break;
825 fi
826 done
827
828 # If LVM logical volume....
829 elif [[ $(lsblk -lno TYPE ${PARTITION} | grep "lvm") != "" ]]; then
830 LVM=1
831
832 # First get crypt name (code above would get lv name)
833 cryptparts=$(lsblk -lno NAME,TYPE,FSTYPE | grep "crypt" | grep -i "lvm2_member" | uniq | awk '{print "/dev/mapper/"$1}')
834 for i in ${cryptparts}; do
835 if [[ $(lsblk -lno NAME ${i} | grep $(echo $PARTITION | sed "s~^/dev/mapper/~~g")) != "" ]]; then
836 LUKS_NAME=$(echo ${i} | sed s~/dev/mapper/~~g)
837 break;
838 fi
839 done
840
841 # Now get the device (/dev/...) for the crypt name
842 cryptparts=$(lsblk -lno NAME,FSTYPE,TYPE | grep "part" | grep -i "crypto_luks" | uniq | awk '{print "/dev/"$1}')
843 for i in ${cryptparts}; do
844 if [[ $(lsblk -lno NAME ${i} | grep $LUKS_NAME) != "" ]]; then
845 # Create UUID for comparison
846 LUKS_UUID=$(lsblk -lno UUID,TYPE,FSTYPE ${i} | grep "part" | grep -i "crypto_luks" | awk '{print $1}')
847
848 # Check if not already added as a LUKS DEVICE (i.e. multiple LVs on one crypt). If not, add.
849 if [[ $(echo $LUKS_DEV | grep $LUKS_UUID) == "" ]]; then
850 LUKS_DEV="$LUKS_DEV cryptdevice=UUID=$LUKS_UUID:$LUKS_NAME"
851 LUKS=1
852 fi
853
854 break;
855 fi
856 done
857 fi
858
859
860}
861
862# Seperate function due to ability to cancel
863make_swap(){
864
865 # Ask user to select partition or create swapfile
866 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart " --menu "$_SelSwpBody" 0 0 7 "$_SelSwpNone" $"-" "$_SelSwpFile" $"-" ${PARTITIONS} 2>${ANSWER} || prep_menu
867
868 if [[ $(cat ${ANSWER}) != "$_SelSwpNone" ]]; then
869 PARTITION=$(cat ${ANSWER})
870
871 if [[ $PARTITION == "$_SelSwpFile" ]]; then
872 total_memory=$(grep MemTotal /proc/meminfo | awk '{print $2/1024}' | sed 's/\..*//')
873 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SelSwpFile " --inputbox "\nM = MB, G = GB\n" 9 30 "${total_memory}M" 2>${ANSWER} || make_swap
874 m_or_g=$(cat ${ANSWER})
875
876 while [[ $(echo ${m_or_g: -1} | grep "M\|G") == "" ]]; do
877 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SelSwpFile " --msgbox "\n$_SelSwpFile $_ErrTitle: M = MB, G = GB\n\n" 0 0
878 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SelSwpFile " --inputbox "\nM = MB, G = GB\n" 9 30 "${total_memory}M" 2>${ANSWER} || make_swap
879 m_or_g=$(cat ${ANSWER})
880 done
881
882 fallocate -l ${m_or_g} ${MOUNTPOINT}/swapfile 2>/tmp/.errlog
883 chmod 600 ${MOUNTPOINT}/swapfile 2>>/tmp/.errlog
884 mkswap ${MOUNTPOINT}/swapfile 2>>/tmp/.errlog
885 swapon ${MOUNTPOINT}/swapfile 2>>/tmp/.errlog
886 check_for_error
887
888 else # Swap Partition
889 # Warn user if creating a new swap
890 if [[ $(lsblk -o FSTYPE ${PARTITION} | grep -i "swap") != "swap" ]]; then
891 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart " --yesno "\nmkswap ${PARTITION}\n\n" 0 0
892 [[ $? -eq 0 ]] && mkswap ${PARTITION} >/dev/null 2>/tmp/.errlog || mount_partitions
893 fi
894 # Whether existing to newly created, activate swap
895 swapon ${PARTITION} >/dev/null 2>>/tmp/.errlog
896 check_for_error
897 # Since a partition was used, remove that partition from the list
898 PARTITIONS=$(echo $PARTITIONS | sed "s~${PARTITION} [0-9]*[G-M]~~" | sed "s~${PARTITION} [0-9]*\.[0-9]*[G-M]~~" | sed s~${PARTITION}$' -'~~)
899 NUMBER_PARTITIONS=$(( NUMBER_PARTITIONS - 1 ))
900 fi
901 fi
902
903}
904 #### ####
905 #### MOUNTING FUNCTION BEGINS HERE ####
906 #### ####
907
908 # prep variables
909 MOUNT=""
910 LUKS_NAME=""
911 LUKS_DEV=""
912 LUKS_UUID=""
913 LUKS=0
914 LVM=0
915
916 # Warn users that they CAN mount partitions without formatting them!
917 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart " --msgbox "$_WarnMount1 '$_FSSkip' $_WarnMount2" 0 0
918
919 # LVM Detection. If detected, activate.
920 lvm_detect
921
922 # Ensure partitions are unmounted (i.e. where mounted previously), and then list available partitions
923 INCLUDE_PART='part\|lvm\|crypt'
924 umount_partitions
925 find_partitions
926
927 # Identify and mount root
928 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart " --menu "$_SelRootBody" 0 0 7 ${PARTITIONS} 2>${ANSWER} || prep_menu
929 PARTITION=$(cat ${ANSWER})
930 ROOT_PART=${PARTITION}
931
932 # Format with FS (or skip)
933 select_filesystem
934
935 # Make the directory and mount. Also identify LUKS and/or LVM
936 mount_current_partition
937
938 # Identify and create swap, if applicable
939 make_swap
940
941 # Extra Step for VFAT UEFI Partition. This cannot be in an LVM container.
942 if [[ $SYSTEM == "UEFI" ]]; then
943
944 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart " --menu "$_SelUefiBody" 0 0 7 ${PARTITIONS} 2>${ANSWER} || prep_menu
945 PARTITION=$(cat ${ANSWER})
946 UEFI_PART=${PARTITION}
947
948 # If it is already a fat/vfat partition...
949 if [[ $(fsck -N $PARTITION | grep fat) ]]; then
950 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart " --yesno "$_FormUefiBody $PARTITION $_FormUefiBody2" 0 0 && mkfs.vfat -F32 ${PARTITION} >/dev/null 2>/tmp/.errlog
951 else
952 mkfs.vfat -F32 ${PARTITION} >/dev/null 2>/tmp/.errlog
953 fi
954 check_for_error
955
956 # Inform users of the mountpoint options and consequences
957 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart " --menu "$_MntUefiBody" 0 0 2 \
958 "/boot" "systemd-boot"\
959 "/boot/efi" "-" 2>${ANSWER}
960
961 [[ $(cat ${ANSWER}) != "" ]] && UEFI_MOUNT=$(cat ${ANSWER}) || prep_menu
962
963 mkdir -p ${MOUNTPOINT}${UEFI_MOUNT} 2>/tmp/.errlog
964 mount ${PARTITION} ${MOUNTPOINT}${UEFI_MOUNT} 2>>/tmp/.errlog
965 check_for_error
966 confirm_mount ${MOUNTPOINT}${UEFI_MOUNT}
967 fi
968
969 # All other partitions
970 while [[ $NUMBER_PARTITIONS > 0 ]]; do
971 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart " --menu "$_ExtPartBody" 0 0 7 "$_Done" $"-" ${PARTITIONS} 2>${ANSWER} || prep_menu
972 PARTITION=$(cat ${ANSWER})
973
974 if [[ $PARTITION == $_Done ]]; then
975 break;
976 else
977 MOUNT=""
978 select_filesystem
979
980 # Ask user for mountpoint. Don't give /boot as an example for UEFI systems!
981 [[ $SYSTEM == "UEFI" ]] && MNT_EXAMPLES="/home\n/var" || MNT_EXAMPLES="/boot\n/home\n/var"
982 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart $PARTITON " --inputbox "$_ExtPartBody1$MNT_EXAMPLES\n" 0 0 "/" 2>${ANSWER} || prep_menu
983 MOUNT=$(cat ${ANSWER})
984
985 # loop while the mountpoint specified is incorrect (is only '/', is blank, or has spaces).
986 while [[ ${MOUNT:0:1} != "/" ]] || [[ ${#MOUNT} -le 1 ]] || [[ $MOUNT =~ \ |\' ]]; do
987 # Warn user about naming convention
988 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_ExtErrBody" 0 0
989 # Ask user for mountpoint again
990 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMntPart $PARTITON " --inputbox "$_ExtPartBody1$MNT_EXAMPLES\n" 0 0 "/" 2>${ANSWER} || prep_menu
991 MOUNT=$(cat ${ANSWER})
992 done
993
994 # Create directory and mount.
995 mount_current_partition
996
997 # Determine if a seperate /boot is used. 0 = no seperate boot, 1 = seperate non-lvm boot,
998 # 2 = seperate lvm boot. For Grub configuration
999 if [[ $MOUNT == "/boot" ]]; then
1000 [[ $(lsblk -lno TYPE ${PARTITION} | grep "lvm") != "" ]] && LVM_SEP_BOOT=2 || LVM_SEP_BOOT=1
1001 fi
1002
1003 fi
1004 done
1005}
1006
1007######################################################################
1008## ##
1009## Encryption (dm_crypt) Functions ##
1010## ##
1011######################################################################
1012
1013# Had to write it in this way due to (bash?) bug(?), as if/then statements in a single
1014# "create LUKS" function for default and "advanced" modes were interpreted as commands,
1015# not mere string statements. Not happy with it, but it works...
1016
1017# Save repetition of code.
1018luks_password(){
1019
1020 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepLUKS " --clear --insecure --passwordbox "$_LuksPassBody" 0 0 2> ${ANSWER} || prep_menu
1021 PASSWD=$(cat ${ANSWER})
1022
1023 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepLUKS " --clear --insecure --passwordbox "$_PassReEntBody" 0 0 2> ${ANSWER} || prep_menu
1024 PASSWD2=$(cat ${ANSWER})
1025
1026 if [[ $PASSWD != $PASSWD2 ]]; then
1027 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_PassErrBody" 0 0
1028 luks_password
1029 fi
1030
1031}
1032
1033luks_open(){
1034
1035 LUKS_ROOT_NAME=""
1036 INCLUDE_PART='part\|crypt\|lvm'
1037 umount_partitions
1038 find_partitions
1039
1040 # Select encrypted partition to open
1041 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LuksOpen " --menu "$_LuksMenuBody" 0 0 7 ${PARTITIONS} 2>${ANSWER} || luks_menu
1042 PARTITION=$(cat ${ANSWER})
1043
1044 # Enter name of the Luks partition and get password to open it
1045 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LuksOpen " --inputbox "$_LuksOpenBody" 10 50 "cryptroot" 2>${ANSWER} || luks_menu
1046 LUKS_ROOT_NAME=$(cat ${ANSWER})
1047 luks_password
1048
1049 # Try to open the luks partition with the credentials given. If successful show this, otherwise
1050 # show the error
1051 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LuksOpen " --infobox "$_PlsWaitBody" 0 0
1052 echo $PASSWD | cryptsetup open --type luks ${PARTITION} ${LUKS_ROOT_NAME} 2>/tmp/.errlog
1053 check_for_error
1054
1055 lsblk -o NAME,TYPE,FSTYPE,SIZE,MOUNTPOINT ${PARTITION} | grep "crypt\|NAME\|MODEL\|TYPE\|FSTYPE\|SIZE" > /tmp/.devlist
1056 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_DevShowOpt " --textbox /tmp/.devlist 0 0
1057
1058 luks_menu
1059}
1060
1061luks_setup(){
1062
1063 modprobe -a dm-mod dm_crypt
1064 INCLUDE_PART='part\|lvm'
1065 umount_partitions
1066 find_partitions
1067
1068 # Select partition to encrypt
1069 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LuksEncrypt " --menu "$_LuksCreateBody" 0 0 7 ${PARTITIONS} 2>${ANSWER} || luks_menu
1070 PARTITION=$(cat ${ANSWER})
1071
1072 # Enter name of the Luks partition and get password to create it
1073 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LuksEncrypt " --inputbox "$_LuksOpenBody" 10 50 "cryptroot" 2>${ANSWER} || luks_menu
1074 LUKS_ROOT_NAME=$(cat ${ANSWER})
1075 luks_password
1076}
1077
1078luks_default() {
1079
1080 # Encrypt selected partition or LV with credentials given
1081 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LuksEncrypt " --infobox "$_PlsWaitBody" 0 0
1082 sleep 2
1083 echo $PASSWD | cryptsetup -q luksFormat ${PARTITION} 2>/tmp/.errlog
1084
1085 # Now open the encrypted partition or LV
1086 echo $PASSWD | cryptsetup open ${PARTITION} ${LUKS_ROOT_NAME} 2>/tmp/.errlog
1087 check_for_error
1088
1089}
1090
1091luks_key_define() {
1092 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepLUKS " --inputbox "$_LuksCipherKey" 0 0 "-s 512 -c aes-xts-plain64" 2>${ANSWER} || luks_menu
1093
1094 # Encrypt selected partition or LV with credentials given
1095 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LuksEncryptAdv " --infobox "$_PlsWaitBody" 0 0
1096 sleep 2
1097
1098 echo $PASSWD | cryptsetup -q $(cat ${ANSWER}) luksFormat ${PARTITION} 2>/tmp/.errlog
1099 check_for_error
1100
1101 # Now open the encrypted partition or LV
1102 echo $PASSWD | cryptsetup open ${PARTITION} ${LUKS_ROOT_NAME} 2>/tmp/.errlog
1103 check_for_error
1104
1105}
1106
1107luks_show(){
1108
1109 echo -e ${_LuksEncruptSucc} > /tmp/.devlist
1110 lsblk -o NAME,TYPE,FSTYPE,SIZE ${PARTITION} | grep "part\|crypt\|NAME\|TYPE\|FSTYPE\|SIZE" >> /tmp/.devlist
1111 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LuksEncrypt " --textbox /tmp/.devlist 0 0
1112
1113 luks_menu
1114}
1115
1116luks_menu() {
1117
1118 LUKS_OPT=""
1119
1120 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepLUKS " --menu "$_LuksMenuBody$_LuksMenuBody2$_LuksMenuBody3" 0 0 4 \
1121 "$_LuksOpen" "cryptsetup open --type luks" \
1122 "$_LuksEncrypt" "cryptsetup -q luksFormat" \
1123 "$_LuksEncryptAdv" "cryptsetup -q -s -c luksFormat" \
1124 "$_Back" "-" 2>${ANSWER}
1125
1126 case $(cat ${ANSWER}) in
1127 "$_LuksOpen") luks_open ;;
1128 "$_LuksEncrypt") luks_setup
1129 luks_default
1130 luks_show ;;
1131 "$_LuksEncryptAdv") luks_setup
1132 luks_key_define
1133 luks_show ;;
1134 *) prep_menu ;;
1135 esac
1136
1137 luks_menu
1138
1139}
1140
1141
1142######################################################################
1143## ##
1144## Logical Volume Management Functions ##
1145## ##
1146######################################################################
1147
1148# LVM Detection.
1149lvm_detect() {
1150
1151 LVM_PV=$(pvs -o pv_name --noheading 2>/dev/null)
1152 LVM_VG=$(vgs -o vg_name --noheading 2>/dev/null)
1153 LVM_LV=$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)
1154
1155 if [[ $LVM_LV != "" ]] && [[ $LVM_VG != "" ]] && [[ $LVM_PV != "" ]]; then
1156 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepLVM " --infobox "$_LvmDetBody" 0 0
1157 modprobe dm-mod 2>/tmp/.errlog
1158 check_for_error
1159 vgscan >/dev/null 2>&1
1160 vgchange -ay >/dev/null 2>&1
1161 fi
1162}
1163
1164lvm_show_vg(){
1165
1166 VG_LIST=""
1167 vg_list=$(lvs --noheadings | awk '{print $2}' | uniq)
1168
1169 for i in ${vg_list}; do
1170 VG_LIST="${VG_LIST} ${i} $(vgdisplay ${i} | grep -i "vg size" | awk '{print $3$4}')"
1171 done
1172
1173 # If no VGs, no point in continuing
1174 if [[ $VG_LIST == "" ]]; then
1175 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_LvmVGErr" 0 0
1176 lvm_menu
1177 fi
1178
1179 # Select VG
1180 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepLVM " --menu "$_LvmSelVGBody" 0 0 5 \
1181 ${VG_LIST} 2>${ANSWER} || lvm_menu
1182}
1183
1184# Create Volume Group and Logical Volumes
1185lvm_create() {
1186
1187# subroutine to save a lot of repetition.
1188check_lv_size() {
1189
1190 LV_SIZE_INVALID=0
1191 chars=0
1192
1193 # Check to see if anything was actually entered and if first character is '0'
1194 ([[ ${#LVM_LV_SIZE} -eq 0 ]] || [[ ${LVM_LV_SIZE:0:1} -eq "0" ]]) && LV_SIZE_INVALID=1
1195
1196 # If not invalid so far, check for non numberic characters other than the last character
1197 if [[ $LV_SIZE_INVALID -eq 0 ]]; then
1198 while [[ $chars -lt $(( ${#LVM_LV_SIZE} - 1 )) ]]; do
1199 [[ ${LVM_LV_SIZE:chars:1} != [0-9] ]] && LV_SIZE_INVALID=1 && break;
1200 chars=$(( chars + 1 ))
1201 done
1202 fi
1203
1204 # If not invalid so far, check that last character is a M/m or G/g
1205 if [[ $LV_SIZE_INVALID -eq 0 ]]; then
1206 LV_SIZE_TYPE=$(echo ${LVM_LV_SIZE:$(( ${#LVM_LV_SIZE} - 1 )):1})
1207
1208 case $LV_SIZE_TYPE in
1209 "m"|"M"|"g"|"G") LV_SIZE_INVALID=0 ;;
1210 *) LV_SIZE_INVALID=1 ;;
1211 esac
1212
1213 fi
1214
1215 # If not invalid so far, check whether the value is greater than or equal to the LV remaining Size.
1216 # If not, convert into MB for VG space remaining.
1217 if [[ ${LV_SIZE_INVALID} -eq 0 ]]; then
1218
1219 case ${LV_SIZE_TYPE} in
1220 "G"|"g") if [[ $(( $(echo ${LVM_LV_SIZE:0:$(( ${#LVM_LV_SIZE} - 1 ))}) * 1000 )) -ge ${LVM_VG_MB} ]]; then
1221 LV_SIZE_INVALID=1
1222 else
1223 LVM_VG_MB=$(( LVM_VG_MB - $(( $(echo ${LVM_LV_SIZE:0:$(( ${#LVM_LV_SIZE} - 1 ))}) * 1000 )) ))
1224 fi
1225 ;;
1226 "M"|"m") if [[ $(echo ${LVM_LV_SIZE:0:$(( ${#LVM_LV_SIZE} - 1 ))}) -ge ${LVM_VG_MB} ]]; then
1227 LV_SIZE_INVALID=1
1228 else
1229 LVM_VG_MB=$(( LVM_VG_MB - $(echo ${LVM_LV_SIZE:0:$(( ${#LVM_LV_SIZE} - 1 ))}) ))
1230 fi
1231 ;;
1232 *) LV_SIZE_INVALID=1
1233 ;;
1234 esac
1235
1236 fi
1237
1238}
1239
1240 # #
1241 # LVM Create Starts Here #
1242 # #
1243
1244 # Prep Variables
1245 LVM_VG=""
1246 VG_PARTS=""
1247 LVM_VG_MB=0
1248
1249 # Find LVM appropriate partitions.
1250 INCLUDE_PART='part\|crypt'
1251 umount_partitions
1252 find_partitions
1253 # Amend partition(s) found for use in check list
1254 PARTITIONS=$(echo $PARTITIONS | sed 's/M\|G\|T/& off/g')
1255
1256 # Name the Volume Group
1257 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG " --inputbox "$_LvmNameVgBody" 0 0 "" 2>${ANSWER} || prep_menu
1258 LVM_VG=$(cat ${ANSWER})
1259
1260 # Loop while the Volume Group name starts with a "/", is blank, has spaces, or is already being used
1261 while [[ ${LVM_VG:0:1} == "/" ]] || [[ ${#LVM_VG} -eq 0 ]] || [[ $LVM_VG =~ \ |\' ]] || [[ $(lsblk | grep ${LVM_VG}) != "" ]]; do
1262 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title "$_ErrTitle" --msgbox "$_LvmNameVgErr" 0 0
1263
1264 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG " --inputbox "$_LvmNameVgBody" 0 0 "" 2>${ANSWER} || prep_menu
1265 LVM_VG=$(cat ${ANSWER})
1266 done
1267
1268 # Select the partition(s) for the Volume Group
1269 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG " --checklist "$_LvmPvSelBody $_UseSpaceBar" 0 0 7 ${PARTITIONS} 2>${ANSWER} || prep_menu
1270 [[ $(cat ${ANSWER}) != "" ]] && VG_PARTS=$(cat ${ANSWER}) || prep_menu
1271
1272 # Once all the partitions have been selected, show user. On confirmation, use it/them in 'vgcreate' command.
1273 # Also determine the size of the VG, to use for creating LVs for it.
1274 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG " --yesno "$_LvmPvConfBody1${LVM_VG} $_LvmPvConfBody2${VG_PARTS}" 0 0
1275
1276 if [[ $? -eq 0 ]]; then
1277 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG " --infobox "$_LvmPvActBody1${LVM_VG}.$_PlsWaitBody" 0 0
1278 sleep 1
1279 vgcreate -f ${LVM_VG} ${VG_PARTS} >/dev/null 2>/tmp/.errlog
1280 check_for_error
1281
1282 # Once created, get size and size type for display and later number-crunching for lv creation
1283 VG_SIZE=$(vgdisplay $LVM_VG | grep 'VG Size' | awk '{print $3}' | sed 's/\..*//')
1284 VG_SIZE_TYPE=$(vgdisplay $LVM_VG | grep 'VG Size' | awk '{print $4}')
1285
1286 # Convert the VG size into GB and MB. These variables are used to keep tabs on space available and remaining
1287 [[ ${VG_SIZE_TYPE:0:1} == "G" ]] && LVM_VG_MB=$(( VG_SIZE * 1000 )) || LVM_VG_MB=$VG_SIZE
1288
1289 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG " --msgbox "$_LvmPvDoneBody1 '${LVM_VG}' $_LvmPvDoneBody2 (${VG_SIZE} ${VG_SIZE_TYPE}).\n\n" 0 0
1290 else
1291 lvm_menu
1292 fi
1293
1294 #
1295 # Once VG created, create Logical Volumes
1296 #
1297
1298 # Specify number of Logical volumes to create.
1299 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG " --radiolist "$_LvmLvNumBody1 ${LVM_VG}. $_LvmLvNumBody2" 0 0 9 \
1300 "1" "-" off "2" "-" off "3" "-" off "4" "-" off "5" "-" off "6" "-" off "7" "-" off "8" "-" off "9 " "-" off 2>${ANSWER}
1301
1302 [[ $(cat ${ANSWER}) == "" ]] && lvm_menu || NUMBER_LOGICAL_VOLUMES=$(cat ${ANSWER})
1303
1304 # Loop while the number of LVs is greater than 1. This is because the size of the last LV is automatic.
1305 while [[ $NUMBER_LOGICAL_VOLUMES -gt 1 ]]; do
1306 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG (LV:$NUMBER_LOGICAL_VOLUMES) " --inputbox "$_LvmLvNameBody1" 0 0 "lvol" 2>${ANSWER} || prep_menu
1307 LVM_LV_NAME=$(cat ${ANSWER})
1308
1309 # Loop if preceeded with a "/", if nothing is entered, if there is a space, or if that name already exists.
1310 while [[ ${LVM_LV_NAME:0:1} == "/" ]] || [[ ${#LVM_LV_NAME} -eq 0 ]] || [[ ${LVM_LV_NAME} =~ \ |\' ]] || [[ $(lsblk | grep ${LVM_LV_NAME}) != "" ]]; do
1311 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_LvmLvNameErrBody" 0 0
1312 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG (LV:$NUMBER_LOGICAL_VOLUMES) " --inputbox "$_LvmLvNameBody1" 0 0 "lvol" 2>${ANSWER} || prep_menu
1313 LVM_LV_NAME=$(cat ${ANSWER})
1314 done
1315
1316 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG (LV:$NUMBER_LOGICAL_VOLUMES) " --inputbox "\n${LVM_VG}: ${VG_SIZE}${VG_SIZE_TYPE} (${LVM_VG_MB}MB $_LvmLvSizeBody1).$_LvmLvSizeBody2" 0 0 "" 2>${ANSWER} || prep_menu
1317 LVM_LV_SIZE=$(cat ${ANSWER})
1318 check_lv_size
1319
1320 # Loop while an invalid value is entered.
1321 while [[ $LV_SIZE_INVALID -eq 1 ]]; do
1322 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_LvmLvSizeErrBody" 0 0
1323 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG (LV:$NUMBER_LOGICAL_VOLUMES) " --inputbox "\n${LVM_VG}: ${VG_SIZE}${VG_SIZE_TYPE} (${LVM_VG_MB}MB $_LvmLvSizeBody1).$_LvmLvSizeBody2" 0 0 "" 2>${ANSWER} || prep_menu
1324 LVM_LV_SIZE=$(cat ${ANSWER})
1325 check_lv_size
1326 done
1327
1328 # Create the LV
1329 lvcreate -L ${LVM_LV_SIZE} ${LVM_VG} -n ${LVM_LV_NAME} 2>/tmp/.errlog
1330 check_for_error
1331 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG (LV:$NUMBER_LOGICAL_VOLUMES) " --msgbox "\n$_Done\n\nLV ${LVM_LV_NAME} (${LVM_LV_SIZE}) $_LvmPvDoneBody2.\n\n" 0 0
1332 NUMBER_LOGICAL_VOLUMES=$(( NUMBER_LOGICAL_VOLUMES - 1 ))
1333 done
1334
1335 # Now the final LV. Size is automatic.
1336 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG (LV:$NUMBER_LOGICAL_VOLUMES) " --inputbox "$_LvmLvNameBody1 $_LvmLvNameBody2 (${LVM_VG_MB}MB)." 0 0 "lvol" 2>${ANSWER} || prep_menu
1337 LVM_LV_NAME=$(cat ${ANSWER})
1338
1339 # Loop if preceeded with a "/", if nothing is entered, if there is a space, or if that name already exists.
1340 while [[ ${LVM_LV_NAME:0:1} == "/" ]] || [[ ${#LVM_LV_NAME} -eq 0 ]] || [[ ${LVM_LV_NAME} =~ \ |\' ]] || [[ $(lsblk | grep ${LVM_LV_NAME}) != "" ]]; do
1341 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_LvmLvNameErrBody" 0 0
1342 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG (LV:$NUMBER_LOGICAL_VOLUMES) " --inputbox "$_LvmLvNameBody1 $_LvmLvNameBody2 (${LVM_VG_MB}MB)." 0 0 "lvol" 2>${ANSWER} || prep_menu
1343 LVM_LV_NAME=$(cat ${ANSWER})
1344 done
1345
1346 # Create the final LV
1347 lvcreate -l +100%FREE ${LVM_VG} -n ${LVM_LV_NAME} 2>/tmp/.errlog
1348 check_for_error
1349 NUMBER_LOGICAL_VOLUMES=$(( NUMBER_LOGICAL_VOLUMES - 1 ))
1350 LVM=1
1351 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmCreateVG " --yesno "$_LvmCompBody" 0 0 \
1352 && show_devices || lvm_menu
1353
1354}
1355
1356lvm_del_vg(){
1357
1358 # Generate list of VGs for selection
1359 lvm_show_vg
1360
1361 # Ask for confirmation
1362 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmDelVG " --yesno "$_LvmDelQ" 0 0
1363
1364 # if confirmation given, delete
1365 if [[ $? -eq 0 ]]; then
1366 vgremove -f $(cat ${ANSWER}) >/dev/null 2>&1
1367 fi
1368
1369 lvm_menu
1370}
1371
1372lvm_del_all(){
1373
1374 LVM_PV=$(pvs -o pv_name --noheading 2>/dev/null)
1375 LVM_VG=$(vgs -o vg_name --noheading 2>/dev/null)
1376 LVM_LV=$(lvs -o vg_name,lv_name --noheading --separator - 2>/dev/null)
1377
1378 # Ask for confirmation
1379 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_LvmDelLV " --yesno "$_LvmDelQ" 0 0
1380
1381 # if confirmation given, delete
1382 if [[ $? -eq 0 ]]; then
1383
1384 for i in ${LVM_LV}; do
1385 lvremove -f /dev/mapper/${i} >/dev/null 2>&1
1386 done
1387
1388 for i in ${LVM_VG}; do
1389 vgremove -f ${i} >/dev/null 2>&1
1390 done
1391
1392 for i in ${LV_PV}; do
1393 pvremove -f ${i} >/dev/null 2>&1
1394 done
1395
1396 fi
1397
1398 lvm_menu
1399}
1400
1401lvm_menu(){
1402
1403 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepLVM $_PrepLVM2 " --infobox "$_PlsWaitBody" 0 0
1404 sleep 1
1405 lvm_detect
1406
1407 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepLVM $_PrepLVM2 " --menu "$_LvmMenu" 0 0 4 \
1408 "$_LvmCreateVG" "vgcreate -f, lvcreate -L -n" \
1409 "$_LvmDelVG" "vgremove -f" \
1410 "$_LvMDelAll" "lvrmeove, vgremove, pvremove -f" \
1411 "$_Back" "-" 2>${ANSWER}
1412
1413 case $(cat ${ANSWER}) in
1414 "$_LvmCreateVG") lvm_create ;;
1415 "$_LvmDelVG") lvm_del_vg ;;
1416 "$_LvMDelAll") lvm_del_all ;;
1417 *) prep_menu ;;
1418 esac
1419
1420
1421}
1422
1423######################################################################
1424## ##
1425## Installation Functions ##
1426## ##
1427######################################################################
1428OTHER(){
1429# Keyboard config for vc and x11
1430 [[ -e /tmp/vconsole.conf ]] && cp /tmp/vconsole.conf ${MOUNTPOINT}/etc/vconsole.conf 2>>/tmp/.errlog
1431 [[ -e /tmp/01-keyboard-layout.conf ]] && cp -f /tmp/01-keyboard-layout.conf ${MOUNTPOINT}/etc/X11/xorg.conf.d/$(ls ${MOUNTPOINT}/etc/X11/xorg.conf.d/ | grep "keyboard") 2>>/tmp/.errlog
1432
1433 # set up kernel for mkiniticpio
1434 cp /run/archiso/bootmnt/arch/boot/${ARCHI}/vmlinuz ${MOUNTPOINT}/boot/vmlinuz-linux 2>>/tmp/.errlog
1435
1436 # copy over new mirrorlist #### COMMENTED ####
1437 # cp /etc/pacman.d/mirrorlist ${MOUNTPOINT}/etc/pacman.d/mirrorlist 2>>/tmp/.errlog
1438
1439 # Clean up installation
1440 #[[ -d ${MOUNTPOINT}/abif-master ]] && rm -R ${MOUNTPOINT}/abif-master 2>>/tmp/.errlog
1441 rm -rf ${MOUNTPOINT}/vomi 2>>/tmp/.errlog
1442 rm -rf ${BYPASS} 2>>/tmp/.errlog
1443 rm -rf ${MOUNTPOINT}/source 2>>/tmp/.errlog
1444 rm -rf ${MOUNTPOINT}/src 2>>/tmp/.errlog
1445 rmdir ${MOUNTPOINT}/bypass 2>>/tmp/.errlog
1446 rmdir ${MOUNTPOINT}/src 2>>/tmp/.errlog
1447 rmdir ${MOUNTPOINT}/source 2>>/tmp/.errlog
1448 rm -f ${MOUNTPOINT}/etc/sudoers.d/g_wheel 2>>/tmp/.errlog
1449 rm -f ${MOUNTPOINT}/var/lib/NetworkManager/NetworkManager.state 2>>/tmp/.errlog
1450 rm -f ${MOUNTPOINT}/update-abif 2>>/tmp/.errlog
1451 sed -i 's/.*pam_wheel\.so/#&/' ${MOUNTPOINT}/etc/pam.d/su 2>>/tmp/.errlog
1452
1453 # clean out archiso files from install #### COMMENTED ####
1454 #find ${MOUNTPOINT}/usr/lib/initcpio -name archiso* -type f -exec rm '{}' \;
1455
1456 # systemd #### COMMENTED AND ADDED ####
1457 #rm -R ${MOUNTPOINT}/etc/systemd/system/getty@tty1.service.d 2>>/tmp/.errlog
1458 #rm ${MOUNTPOINT}/etc/systemd/system/default.target 2>>/tmp/.errlog
1459 # ADDED, BUT DOENS'T WORK, SO COMMENTED ### testeing again
1460 arch_chroot "systemctl disable pacman-init.service choose-mirror.service"
1461 rm -Rf ${MOUNTPOINT}/etc/systemd/system/{choose-mirror.service,pacman-init.service,etc-pacman.d-gnupg.mount,getty@tty1.service.d}
1462 rm -Rf ${MOUNTPOINT}/etc/systemd/scripts/choose-mirror
1463 rm -f ${MOUNTPOINT}/etc/systemd/system/getty@tty1.service.d/autologin.conf
1464 rm -f ${MOUNTPOINT}/root/{.automated_script.sh,.zlogin}
1465 rm -f ${MOUNTPOINT}/etc/mkinitcpio-archiso.conf
1466 rm -Rf ${MOUNTPOINT}/etc/initcpio
1467 rm -Rf ${MOUNTPOINT}/etc/udev/rules.d/81-dhcpcd.rules
1468 arch_chroot "systemctl enable NetworkManager"
1469 arch_chroot "systemctl disable multi-user.target"
1470 arch_chroot "systemctl enable sddm"
1471 arch_chroot "systemctl enable vboxservice"
1472 mv -f ${MOUNTPOINT}/etc/xdg/autostart ${MOUNTPOINT}/etc/xdg/autostart.bak
1473 rm -Rf ${MOUNTPOINT}/home/$ISO_USER/.xinitrc
1474 #mv -f ${MOUNTPOINT}/home/$ISO_USER/.xinitrc ${MOUNTPOINT}/home/$ISO_USER/.xinitrc.bak
1475 rm -Rf ${MOUNTPOINT}/home/$ISO_USER/.xsession
1476 #mv -f ${MOUNTPOINT}/home/$ISO_USER/.xsession ${MOUNTPOINT}/home/$ISO_USER/.xsession.bak
1477 rm -Rf ${MOUNTPOINT}/home/$ISO_USER/.bash_profile
1478 #mv -f ${MOUNTPOINT}/home/$ISO_USER/.bash_profile ${MOUNTPOINT}/home/$ISO_USER/.bash_profile.bak
1479 mv -f ${MOUNTPOINT}/home/$ISO_USER/.bash_profile.comented ${MOUNTPOINT}/home/$ISO_USER/.bash_profile
1480 arch_chroot "systemctl enable org.cups.cupsd.service"
1481 arch_chroot "systemctl enable avahi-daemon.service"
1482 #arch_chroot "dconf load / < ${MOUNTPOINT}/home/$ISO_USER/tilix.dconf"
1483 #rm -Rf ${MOUNTPOINT}/home/$ISO_USER/tilix.dconf
1484
1485 # Journal
1486 sed -i 's/volatile/auto/g' ${MOUNTPOINT}/etc/systemd/journald.conf 2>>/tmp/.errlog
1487
1488 # Stop pacman complaining
1489 arch_chroot "mkdir -p /var/lib/pacman/sync" 2>>/tmp/.errlog
1490 arch_chroot "touch /var/lib/pacman/sync/{core.db,extra.db,community.db,antergos.db,multilib.db}" 2>>/tmp/.errlog
1491
1492 # Fix NetworkManager
1493 arch_chroot "systemctl enable NetworkManager -f" 2>>/tmp/.errlog
1494
1495 # Keyboard config for vc and x11
1496 [[ -e /tmp/vconsole.conf ]] && cp /tmp/vconsole.conf ${MOUNTPOINT}/etc/vconsole.conf 2>>/tmp/.errlog
1497 [[ -e /tmp/01-keyboard-layout.conf ]] && cp -f /tmp/01-keyboard-layout.conf ${MOUNTPOINT}/etc/X11/xorg.conf.d/$(ls ${MOUNTPOINT}/etc/X11/xorg.conf.d/ | grep "keyboard") 2>>/tmp/.errlog
1498
1499 # Display Manager #### COMMENTED ####
1500 #arch_chroot "systemctl enable sddm" 2>>/tmp/.errlog
1501 #cp -f /inst/sddm.conf ${MOUNTPOINT}/etc/sddm/sddm.conf 2>>/tmp/.errlog
1502 #[[ -d ${MOUNTPOINT}/inst ]] && rm -R ${MOUNTPOINT}/inst &> /dev/null 2>>/tmp/.errlog
1503 #check_for_error
1504
1505 # Virtualbox Guest
1506 [[ $(lspci | grep -i "vga" | sed 's/.*://' | sed 's/(.*//' | sed 's/^[ \t]*//' | grep -i "virtualbox") != "" ]] && arch_chroot "systemctl enable vboxservice"
1507}
1508
1509OTHER2(){
1510# Keyboard config for vc and x11
1511 [[ -e /tmp/vconsole.conf ]] && cp /tmp/vconsole.conf ${MOUNTPOINT}/etc/vconsole.conf 2>>/tmp/.errlog
1512 [[ -e /tmp/01-keyboard-layout.conf ]] && cp -f /tmp/01-keyboard-layout.conf ${MOUNTPOINT}/etc/X11/xorg.conf.d/$(ls ${MOUNTPOINT}/etc/X11/xorg.conf.d/ | grep "keyboard") 2>>/tmp/.errlog
1513
1514 arch_chroot "systemctl enable NetworkManager"
1515 arch_chroot "systemctl enable sddm"
1516 arch_chroot "systemctl enable vboxservice"
1517 arch_chroot "systemctl enable org.cups.cupsd.service"
1518 arch_chroot "systemctl enable avahi-daemon.service"
1519
1520 # Journal
1521 sed -i 's/volatile/auto/g' ${MOUNTPOINT}/etc/systemd/journald.conf 2>>/tmp/.errlog
1522
1523 # Fix NetworkManager
1524 arch_chroot "systemctl enable NetworkManager -f" 2>>/tmp/.errlog
1525
1526 # Keyboard config for vc and x11
1527 [[ -e /tmp/vconsole.conf ]] && cp /tmp/vconsole.conf ${MOUNTPOINT}/etc/vconsole.conf 2>>/tmp/.errlog
1528 [[ -e /tmp/01-keyboard-layout.conf ]] && cp -f /tmp/01-keyboard-layout.conf ${MOUNTPOINT}/etc/X11/xorg.conf.d/$(ls ${MOUNTPOINT}/etc/X11/xorg.conf.d/ | grep "keyboard") 2>>/tmp/.errlog
1529
1530 # Virtualbox Guest
1531 [[ $(lspci | grep -i "vga" | sed 's/.*://' | sed 's/(.*//' | sed 's/^[ \t]*//' | grep -i "virtualbox") != "" ]] && arch_chroot "systemctl enable vboxservice"
1532}
1533
1534resume_install(){
1535
1536dialog --title "Edit list" --menu "Select CONTINUE when you are ready" 0 0 1 \
1537 "1" $"CONTINUE" 2>${ANSWER}
1538
1539case $(cat ${ANSWER}) in
1540 "1") sleep 1
1541 ;;
1542 *) exit 0
1543 ;;
1544esac
1545}
1546
1547edit_pkg(){
1548
1549dialog --title "Edit package list" --menu "Choose pakages to be installed" 0 0 1 \
1550 "1" $"Edit list" 2>${ANSWER}
1551
1552case $(cat ${ANSWER}) in
1553 "1") sudo xed /abif-master/packages_pacman.txt /abif-master/packages_yaourt.txt
1554 resume_install
1555 ;;
1556 *) exit 0
1557 ;;
1558esac
1559}
1560
1561online_install(){
1562
1563
1564dialog --title "Install method" --menu "Choose install method" 0 0 2 \
1565 "1" $"Use pacstrap only (Standard)" \
1566 "2" $"Use powerpill to download packages and pacstrap to install (Faster)" 2>${ANSWER}
1567
1568 case $(cat ${ANSWER}) in
1569 "1") edit_pkg
1570 # pacstrap
1571 sudo haveged -w 1024
1572 pacman-key --init; pacman-key --populate archlinux antergos; pacman-key --refresh-keys
1573 sudo pkill haveged
1574 sudo reflector --verbose --age 8 --fastest 128 --latest 64 --number 32 --sort rate --save /etc/pacman.d/mirrorlist
1575 cat /abif-master/packages_pacman.txt | xargs >/home/$ISO_USER/packages_pacman.txt
1576 pacstrap -c ${MOUNTPOINT} $(cat /home/$ISO_USER/packages_pacman.txt)
1577 # yaourt packages
1578 cat /abif-master/packages_yaourt.txt | xargs > /home/$ISO_USER/packages_yaourt.txt
1579 sudo mkdir /home/$ISO_USER/yaourt
1580/{core.db,extra.db,community.db,antergos.db,multilib.db}
1581 sudo su -- "$ISO_USER" -c "yaourt -S --root /home/$ISO_USER/yaourt --noconfirm --dbpath /var/lib/pacman $(cat /home/$ISO_USER/packages_yaourt.txt)"
1582 sudo cp -r /home/$ISO_USER/yaourt/* ${MOUNTPOINT}
1583
1584 OTHER2
1585 sudo cp -r /etc/pacman.conf ${MOUNTPOINT}/etc/pacman.conf
1586 ;;
1587 "2") edit_pkg
1588 # Powerpill
1589 sudo haveged -w 1024
1590 pacman-key --init; pacman-key --populate archlinux antergos; pacman-key --refresh-keys
1591 sudo pkill haveged
1592 sudo reflector --verbose --age 8 --fastest 128 --latest 64 --number 32 --sort rate --save /etc/pacman.d/mirrorlist
1593 cat /abif-master/packages_pacman.txt | xargs >/home/$ISO_USER/packages_pacman.txt
1594 # Create and fix a list of all dependencies's packages
1595 # /abif-master/packages_pacman.txt
1596 for x in $(cat /abif-master/packages_pacman.txt); do pactree -u $x 2>>/home/$ISO_USER/error1; done
1597 for x in $(cat /abif-master/packages_pacman.txt); do pactree -u $x >>/home/$ISO_USER/dependencies.txt; done
1598 # Added expac redundance, due to pactree failure in display "dependencies of dependencies"
1599 for x in $(cat /abif-master/packages_pacman.txt); do expac %E -S $x 2>>/home/$ISO_USER/error1; done
1600 for x in $(cat /abif-master/packages_pacman.txt); do expac %E -S $(expac %E -S $x) 2>>/home/$ISO_USER/error1; done
1601 for x in $(cat /abif-master/packages_pacman.txt); do expac %E -S $x >>/home/$ISO_USER/dependencies.txt; done
1602 for x in $(cat /abif-master/packages_pacman.txt); do expac %E -S $(expac %E -S $x) >>/home/$ISO_USER/dependencies.txt; done
1603 # Dependencies in single line to multiple lines
1604 sed -i 's/\s\+/\n/g' /home/$ISO_USER/error1
1605 sed -i 's/\s\+/\n/g' /home/$ISO_USER/dependencies.txt
1606 # /abif-master/base
1607 for x in $(cat /abif-master/base); do pactree -u $x 2>>/home/$ISO_USER/error1; done
1608 for x in $(cat /abif-master/base); do pactree -u $x >>/home/$ISO_USER/dependencies.txt; done
1609 cat error1 | cut -f2 -d"'" >>/home/$ISO_USER/dependencies.txt
1610 cat /abif-master/base >>/home/$ISO_USER/dependencies.txt
1611
1612 # Remove repeated packages (keep 1 occurrance)
1613 sort /home/$ISO_USER/dependencies.txt | uniq >/home/$ISO_USER/dependencies2.txt
1614
1615 # Download packages with powerpill
1616 sudo powerpill -Sw $(cat /home/$ISO_USER/dependencies2.txt) --noconfirm
1617
1618 # Check incomplete download (.aria2) and remove full path and extension
1619 sudo find /var/cache/pacman/pkg -iname "*.pkg.tar.xz.aria2" > /home/$ISO_USER/aria2.txt
1620 sed -i "s/\/var\/cache\/pacman\/pkg\///g" /home/$ISO_USER/aria2.txt
1621 sed -i "s/.pkg.tar.xz.aria2//g" /home/$ISO_USER/aria2.txt
1622
1623 # Check files not installed and generate a list to redownload
1624 grep -Fof /home/$ISO_USER/dependencies2.txt /home/$ISO_USER/aria2.txt >/home/$ISO_USER/pkgs_not_installed.txt
1625
1626 # Remove broken files (.aria2)
1627 sudo rm -r $(sudo find /var/cache/pacman/pkg -iname "*.pkg.tar.xz.aria2")
1628 sudo pacman -Sw $(cat /home/$ISO_USER/pkgs_not_installed.txt) --noconfirm
1629
1630 pacstrap -c ${MOUNTPOINT} $(cat /home/$ISO_USER/packages_pacman.txt)
1631
1632 # yaourt packages
1633 cat /abif-master/packages_yaourt.txt | xargs > /home/$ISO_USER/packages_yaourt.txt
1634 sudo mkdir /home/$ISO_USER/yaourt
1635 sudo su -- "$ISO_USER" -c "yaourt -S --root /home/$ISO_USER/yaourt --noconfirm --dbpath /var/lib/pacman $(cat /home/$ISO_USER/packages_yaourt.txt)"
1636 sudo cp -r /home/$ISO_USER/yaourt/* ${MOUNTPOINT}
1637
1638 OTHER2
1639 sudo cp -r /etc/pacman.conf ${MOUNTPOINT}/etc/pacman.conf
1640 ;;
1641 *) exit 0
1642 ;;
1643esac
1644}
1645
1646install_root(){
1647
1648 clear
1649 dialog --title "Choose install method" --menu "Choose install method" 0 0 3 \
1650 "1" $"Install ISO with it's configs (RECOMMENDED)" \
1651 "2" $"Install from already installed USB/HD OR keep changed files" \
1652 "3" $"Online installer - packages+yaourt - Edit packages_pacman.txt and packages_yaourt.txt at /abif-master " 2>${ANSWER}
1653
1654 case $(cat ${ANSWER}) in
1655 "1") cp -var /run/archiso/sfs/airootfs/* ${MOUNTPOINT}/ 2>/tmp/.errlog
1656 OTHER
1657 ;;
1658 "2") cp -xav / ${MOUNTPOINT}/ 2>/tmp/.errlog
1659 OTHER
1660 ;;
1661 "3") online_install
1662 ;;
1663 *) exit 0
1664 ;;
1665esac
1666}
1667
1668# Install Bootloader
1669install_bootloader() {
1670
1671bios_bootloader() {
1672
1673 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title "$_InstBiosBtTitle" --menu "$_InstBiosBtBody" 0 0 3 \
1674 "grub" "-" "syslinux [MBR]" "-" "syslinux [/]" "-" 2>${ANSWER}
1675
1676 if [[ $(cat ${ANSWER}) == "grub" ]];then
1677 select_device
1678 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " Grub-install " --infobox "$_PlsWaitBody" 0 0
1679 arch_chroot "grub-install --target=i386-pc --recheck $DEVICE" 2>/tmp/.errlog
1680 check_for_error
1681
1682 arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" 2>/tmp/.errlog
1683 check_for_error
1684
1685 # if /boot is LVM (whether using a seperate /boot mount or not), amend grub
1686 if ( [[ $LVM -eq 1 ]] && [[ $LVM_SEP_BOOT -eq 0 ]] ) || [[ $LVM_SEP_BOOT -eq 2 ]]; then
1687 sed -i "s/GRUB_PRELOAD_MODULES=\"\"/GRUB_PRELOAD_MODULES=\"lvm\"/g" ${MOUNTPOINT}/etc/default/grub
1688 fi
1689
1690 # If encryption used amend grub
1691 [[ $LUKS_DEV != "" ]] && sed -i "s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"$LUKS_DEV\"~g" ${MOUNTPOINT}/etc/default/grub
1692
1693 arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" 2>>/tmp/.errlog
1694 check_for_error
1695 BOOTLOADER="grub"
1696
1697 elif ([[ $(cat ${ANSWER}) == "syslinux [MBR]" ]] || [[ $(cat ${ANSWER}) == "syslinux [/]" ]]);then
1698 [[ $(cat ${ANSWER}) == "syslinux [MBR]" ]] && arch_chroot "syslinux-install_update -iam" 2>/tmp/.errlog
1699 [[ $(cat ${ANSWER}) == "syslinux [/]" ]] && arch_chroot "syslinux-install_update -i" 2>/tmp/.errlog
1700 check_for_error
1701
1702 # Amend configuration file. First remove all existing entries, then input new ones.
1703 sed -i '/^LABEL.*$/,$d' ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1704
1705 # First the "main" entries
1706 [[ -e ${MOUNTPOINT}/boot/initramfs-linux.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL $ISO_HOST Linux\n\tLINUX ../vmlinuz-linux\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1707 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-lts.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL $ISO_HOST Linux LTS\n\tLINUX ../vmlinuz-linux-lts\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-lts.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1708 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-grsec.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL $ISO_HOST Linux Grsec\n\tLINUX ../vmlinuz-linux-grsec\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-grsec.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1709 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-zen.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL $ISO_HOST Linux Zen\n\tLINUX ../vmlinuz-linux-zen\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-zen.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1710
1711 # Second the "fallback" entries
1712 [[ -e ${MOUNTPOINT}/boot/initramfs-linux.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL $ISO_HOST Linux Fallback\n\tLINUX ../vmlinuz-linux\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-fallback.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1713 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-lts.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL $ISO_HOST Linux Fallback LTS\n\tLINUX ../vmlinuz-linux-lts\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-lts-fallback.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1714 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-grsec.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL $ISO_HOST Linux Fallback Grsec\n\tLINUX ../vmlinuz-linux-grsec\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-grsec-fallback.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1715 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-zen.img ]] && echo -e "\n\nLABEL arch\n\tMENU LABEL $ISO_HOST Linux Fallbacl Zen\n\tLINUX ../vmlinuz-linux-zen\n\tAPPEND root=${ROOT_PART} rw\n\tINITRD ../initramfs-linux-zen-fallback.img" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1716
1717 # Third, amend for LUKS
1718 [[ $LUKS_DEV != "" ]] && sed -i "s~rw~$LUKS_DEV rw~g" ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1719
1720 # Finally, re-add the "default" entries
1721 echo -e "\n\nLABEL hdt\n\tMENU LABEL HDT (Hardware Detection Tool)\n\tCOM32 hdt.c32" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1722 echo -e "\n\nLABEL reboot\n\tMENU LABEL Reboot\n\tCOM32 reboot.c32" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1723 echo -e "\n\n#LABEL windows\n\t#MENU LABEL Windows\n\t#COM32 chain.c32\n\t#APPEND root=/dev/sda2 rw" >> ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1724 echo -e "\n\nLABEL poweroff\n\tMENU LABEL Poweroff\n\tCOM32 poweroff.c32" ${MOUNTPOINT}/boot/syslinux/syslinux.cfg
1725
1726 BOOTLOADER="syslinux"
1727 fi
1728
1729}
1730
1731uefi_bootloader() {
1732
1733 #Ensure again that efivarfs is mounted
1734 [[ -z $(mount | grep /sys/firmware/efi/efivars) ]] && mount -t efivarfs efivarfs /sys/firmware/efi/efivars
1735
1736 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_InstUefiBtTitle " --menu "$_InstUefiBtBody" 0 0 2 \
1737 "grub" "-" "systemd-boot" "/boot" 2>${ANSWER}
1738
1739 if [[ $(cat ${ANSWER}) == "grub" ]];then
1740
1741 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " Grub-install " --infobox "$_PlsWaitBody" 0 0
1742 arch_chroot "grub-install --target=x86_64-efi --efi-directory=${UEFI_MOUNT} --bootloader-id=arch_grub --recheck" 2>/tmp/.errlog
1743
1744 # If encryption used amend grub
1745 [[ $LUKS_DEV != "" ]] && sed -i "s~GRUB_CMDLINE_LINUX=.*~GRUB_CMDLINE_LINUX=\"$LUKS_DEV\"~g" ${MOUNTPOINT}/etc/default/grub
1746
1747 # Generate config file
1748 arch_chroot "grub-mkconfig -o /boot/grub/grub.cfg" 2>>/tmp/.errlog
1749 check_for_error
1750
1751 # Ask if user wishes to set Grub as the default bootloader and act accordingly
1752 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_InstUefiBtTitle " --yesno "$_SetBootDefBody ${UEFI_MOUNT}/EFI/boot $_SetBootDefBody2" 0 0
1753
1754 if [[ $? -eq 0 ]]; then
1755 arch_chroot "mkdir ${UEFI_MOUNT}/EFI/boot" 2>/tmp/.errlog
1756 arch_chroot "cp -r ${UEFI_MOUNT}/EFI/arch_grub/grubx64.efi ${UEFI_MOUNT}/EFI/boot/bootx64.efi" 2>>/tmp/.errlog
1757 check_for_error
1758 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_InstUefiBtTitle " --infobox "\nGrub $_SetDefDoneBody" 0 0
1759 sleep 2
1760 fi
1761
1762 BOOTLOADER="grub"
1763
1764 elif [[ $(cat ${ANSWER}) == "systemd-boot" ]];then
1765
1766 arch_chroot "bootctl --path=${UEFI_MOUNT} install" 2>/tmp/.errlog
1767 check_for_error
1768
1769 # Deal with LVM Root
1770 [[ $(echo $ROOT_PART | grep "/dev/mapper/") != "" ]] && bl_root=$ROOT_PART \
1771 || bl_root=$"PARTUUID="$(blkid -s PARTUUID ${ROOT_PART} | sed 's/.*=//g' | sed 's/"//g')
1772
1773 # Create default config files. First the loader
1774 echo -e "default $ISO_HOST\ntimeout 10" > ${MOUNTPOINT}${UEFI_MOUNT}/loader/loader.conf 2>/tmp/.errlog
1775
1776 # Second, the kernel conf files
1777 [[ -e ${MOUNTPOINT}/boot/initramfs-linux.img ]] && echo -e "title\t$ISO_HOST Linux\nlinux\t/vmlinuz-linux\ninitrd\t/initramfs-linux.img\noptions\troot=${bl_root} rw" > ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/$ISO_HOST.conf
1778 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-lts.img ]] && echo -e "title\t$ISO_HOST Linux LTS\nlinux\t/vmlinuz-linux-lts\ninitrd\t/initramfs-linux-lts.img\noptions\troot=${bl_root} rw" > ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/$ISO_HOST-lts.conf
1779 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-grsec.img ]] && echo -e "title\t$ISO_HOST Linux Grsec\nlinux\t/vmlinuz-linux-grsec\ninitrd\t/initramfs-linux-grsec.img\noptions\troot=${bl_root} rw" > ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/$ISO_HOST-grsec.conf
1780 [[ -e ${MOUNTPOINT}/boot/initramfs-linux-zen.img ]] && echo -e "title\t$ISO_HOST Linux Zen\nlinux\t/vmlinuz-linux-zen\ninitrd\t/initramfs-linux-zen.img\noptions\troot=${bl_root} rw" > ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/$ISO_HOST-zen.conf
1781
1782 # Finally, amend kernel conf files for LUKS
1783 sysdconf=$(ls ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/$ISO_HOST*.conf)
1784 for i in ${sysdconf}; do
1785 [[ $LUKS_DEV != "" ]] && sed -i "s~rw~$LUKS_DEV rw~g" ${i}
1786 done
1787
1788 BOOTLOADER="systemd-boot"
1789 fi
1790
1791}
1792 # #
1793 # Bootloader function begins here #
1794 # #
1795 check_mount
1796 # Set the default PATH variable
1797 arch_chroot "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl" 2>/tmp/.errlog
1798 check_for_error
1799
1800 if [[ $SYSTEM == "BIOS" ]]; then
1801 bios_bootloader
1802 else
1803 uefi_bootloader
1804 fi
1805}
1806
1807######################################################################
1808## ##
1809## Main Interfaces ##
1810## ##
1811######################################################################
1812
1813security_menu(){
1814
1815 if [[ $SUB_MENU != "security_menu" ]]; then
1816 SUB_MENU="security_menu"
1817 HIGHLIGHT_SUB=1
1818 else
1819 if [[ $HIGHLIGHT_SUB != 4 ]]; then
1820 HIGHLIGHT_SUB=$(( HIGHLIGHT_SUB + 1 ))
1821 fi
1822 fi
1823
1824 dialog --default-item ${HIGHLIGHT_SUB} --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SecMenuTitle " --menu "$_SecMenuBody" 0 0 4 \
1825 "1" "$_SecJournTitle" \
1826 "2" "$_SecCoreTitle" \
1827 "3" "$_SecKernTitle" \
1828 "4" "$_Back" 2>${ANSWER}
1829
1830 HIGHLIGHT_SUB=$(cat ${ANSWER})
1831 case $(cat ${ANSWER}) in
1832 "1") # systemd-journald
1833 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SecJournTitle " --menu "$_SecJournBody" 0 0 7 \
1834 "$_Edit" "/etc/systemd/journald.conf" \
1835 "10M" "SystemMaxUse=10M" \
1836 "20M" "SystemMaxUse=20M" \
1837 "50M" "SystemMaxUse=50M" \
1838 "100M" "SystemMaxUse=100M" \
1839 "200M" "SystemMaxUse=200M" \
1840 "$_Disable" "Storage=none" 2>${ANSWER}
1841
1842 if [[ $(cat ${ANSWER}) != "" ]]; then
1843 if [[ $(cat ${ANSWER}) == "$_Disable" ]]; then
1844 sed -i "s/#Storage.*\|Storage.*/Storage=none/g" ${MOUNTPOINT}/etc/systemd/journald.conf
1845 sed -i "s/SystemMaxUse.*/#&/g" ${MOUNTPOINT}/etc/systemd/journald.conf
1846 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SecJournTitle " --infobox "\n$_Done!\n\n" 0 0
1847 sleep 2
1848 elif [[ $(cat ${ANSWER}) == "$_Edit" ]]; then
1849 nano ${MOUNTPOINT}/etc/systemd/journald.conf
1850 else
1851 sed -i "s/#SystemMaxUse.*\|SystemMaxUse.*/SystemMaxUse=$(cat ${ANSWER})/g" ${MOUNTPOINT}/etc/systemd/journald.conf
1852 sed -i "s/Storage.*/#&/g" ${MOUNTPOINT}/etc/systemd/journald.conf
1853 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SecJournTitle " --infobox "\n$_Done!\n\n" 0 0
1854 sleep 2
1855 fi
1856 fi
1857 ;;
1858 "2") # core dump
1859 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SecCoreTitle " --menu "$_SecCoreBody" 0 0 2 \
1860 "$_Disable" "Storage=none" "$_Edit" "/etc/systemd/coredump.conf" 2>${ANSWER}
1861
1862 if [[ $(cat ${ANSWER}) == "$_Disable" ]]; then
1863 sed -i "s/#Storage.*\|Storage.*/Storage=none/g" ${MOUNTPOINT}/etc/systemd/coredump.conf
1864 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SecCoreTitle " --infobox "\n$_Done!\n\n" 0 0
1865 sleep 2
1866 elif [[ $(cat ${ANSWER}) == "$_Edit" ]]; then
1867 nano ${MOUNTPOINT}/etc/systemd/coredump.conf
1868 fi
1869 ;;
1870 "3") # Kernel log access
1871 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SecKernTitle " --menu "\nKernel logs may contain information an attacker can use to identify and exploit kernel vulnerabilities, including sensitive memory addresses.\n\nIf systemd-journald logging has not been disabled, it is possible to create a rule in /etc/sysctl.d/ to disable access to these logs unless using root privilages (e.g. via sudo).\n" 0 0 2 \
1872 "$_Disable" "kernel.dmesg_restrict = 1" "$_Edit" "/etc/systemd/coredump.conf.d/custom.conf" 2>${ANSWER}
1873
1874 case $(cat ${ANSWER}) in
1875 "$_Disable") echo "kernel.dmesg_restrict = 1" > ${MOUNTPOINT}/etc/sysctl.d/50-dmesg-restrict.conf
1876 dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SecKernTitle " --infobox "\n$_Done!\n\n" 0 0
1877 sleep 2 ;;
1878 "$_Edit") [[ -e ${MOUNTPOINT}/etc/sysctl.d/50-dmesg-restrict.conf ]] && nano ${MOUNTPOINT}/etc/sysctl.d/50-dmesg-restrict.conf \
1879 || dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SeeConfErrTitle " --msgbox "$_SeeConfErrBody1" 0 0 ;;
1880 esac
1881 ;;
1882 *) main_menu
1883 ;;
1884 esac
1885
1886 security_menu
1887}
1888
1889
1890# Greet the user when first starting the installer
1891greeting() {
1892
1893dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_WelTitle $VERSION " --msgbox "$_WelBody" 0 0
1894
1895}
1896
1897# Preparation
1898prep_menu() {
1899
1900 if [[ $SUB_MENU != "prep_menu" ]]; then
1901 SUB_MENU="prep_menu"
1902 HIGHLIGHT_SUB=1
1903 else
1904 if [[ $HIGHLIGHT_SUB != 8 ]]; then
1905 HIGHLIGHT_SUB=$(( HIGHLIGHT_SUB + 1 ))
1906 fi
1907 fi
1908
1909 dialog --default-item ${HIGHLIGHT_SUB} --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_PrepMenuTitle " --menu "$_PrepMenuBody" 0 0 8 \
1910 "1" "$_VCKeymapTitle" \
1911 "2" "$_PrepKBLayout" \
1912 "3" "$_DevShowOpt" \
1913 "4" "$_PrepPartDisk" \
1914 "5" "$_PrepLUKS" \
1915 "6" "$_PrepLVM $_PrepLVM2" \
1916 "7" "$_PrepMntPart" \
1917 "8" "$_Back" 2>${ANSWER}
1918
1919 HIGHLIGHT_SUB=$(cat ${ANSWER})
1920 case $(cat ${ANSWER}) in
1921 "1") set_keymap
1922 ;;
1923 "2") set_xkbmap
1924 ;;
1925 "3") show_devices
1926 ;;
1927 "4") umount_partitions
1928 select_device
1929 create_partitions
1930 ;;
1931 "5") luks_menu
1932 ;;
1933 "6") lvm_menu
1934 ;;
1935 "7") mount_partitions
1936 ;;
1937 *) main_menu
1938 ;;
1939 esac
1940
1941 prep_menu
1942
1943}
1944
1945# Base Installation
1946install_root_menu() {
1947
1948 if [[ $SUB_MENU != "install_base_menu" ]]; then
1949 SUB_MENU="install_base_menu"
1950 HIGHLIGHT_SUB=1
1951 else
1952 if [[ $HIGHLIGHT_SUB != 4 ]]; then
1953 HIGHLIGHT_SUB=$(( HIGHLIGHT_SUB + 1 ))
1954 fi
1955 fi
1956
1957 dialog --default-item ${HIGHLIGHT_SUB} --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title "$_InstBsMenuTitle" --menu "$_InstBseMenuBody" 0 0 4 \
1958 "1" "$_InstBse" \
1959 "2" "$_MMRunMkinit" \
1960 "3" "$_InstBootldr" \
1961 "4" "$_Back" 2>${ANSWER}
1962
1963 HIGHLIGHT_SUB=$(cat ${ANSWER})
1964 case $(cat ${ANSWER}) in
1965 "1") install_root
1966 ;;
1967 "2") run_mkinitcpio
1968 ;;
1969 "3") install_bootloader
1970 ;;
1971 *) main_menu
1972 ;;
1973 esac
1974
1975 install_root_menu
1976}
1977
1978# Base Configuration
1979config_base_menu() {
1980
1981 # Set the default PATH variable
1982 arch_chroot "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/bin/core_perl" 2>/tmp/.errlog
1983 check_for_error
1984
1985 if [[ $SUB_MENU != "config_base_menu" ]]; then
1986 SUB_MENU="config_base_menu"
1987 HIGHLIGHT_SUB=1
1988 else
1989 if [[ $HIGHLIGHT_SUB != 8 ]]; then
1990 HIGHLIGHT_SUB=$(( HIGHLIGHT_SUB + 1 ))
1991 fi
1992 fi
1993
1994 dialog --default-item ${HIGHLIGHT_SUB} --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ConfBseMenuTitle " --menu "$_ConfBseBody" 0 0 8 \
1995 "1" "$_ConfBseFstab" \
1996 "2" "$_ConfBseHost" \
1997 "3" "$_ConfBseSysLoc" \
1998 "4" "$_ConfBseTimeHC" \
1999 "5" "$_ConfUsrRoot" \
2000 "6" "$_ConfUsrNew" \
2001 "7" "$_SecMenuTitle" \
2002 "8" "$_Back" 2>${ANSWER}
2003
2004 HIGHLIGHT_SUB=$(cat ${ANSWER})
2005 case $(cat ${ANSWER}) in
2006 "1") generate_fstab
2007 ;;
2008 "2") set_hostname
2009 ;;
2010 "3") set_locale
2011 ;;
2012 "4") set_timezone
2013 set_hw_clock
2014 ;;
2015 "5") set_root_password
2016 ;;
2017 "6") create_new_user
2018 ;;
2019 "7") security_menu
2020 ;;
2021 *) main_menu
2022 ;;
2023 esac
2024
2025 config_base_menu
2026
2027}
2028
2029# Edit configs of installed system
2030#edit_configs() {
2031
2032 # Clear the file variables
2033# FILE=""
2034# user_list=""
2035
2036# if [[ $SUB_MENU != "edit configs" ]]; then
2037# SUB_MENU="edit configs"
2038## HIGHLIGHT_SUB=1
2039# else
2040# if [[ $HIGHLIGHT_SUB != 12 ]]; then
2041# HIGHLIGHT_SUB=$(( HIGHLIGHT_SUB + 1 ))
2042# fi
2043# fi
2044#
2045 # dialog --default-item ${HIGHLIGHT_SUB} --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_SeeConfOptTitle " --menu "$_SeeConfOptBody" 0 0 12 \
2046# "1" "/etc/vconsole.conf" \
2047# "2" "/etc/locale.conf" \
2048# "3" "/etc/hostname" \
2049# "4" "/etc/hosts" \
2050# "5" "/etc/sudoers" \
2051# "6" "/etc/mkinitcpio.conf" \
2052# "7" "/etc/fstab" \
2053# "8" "/etc/crypttab" \
2054# "9" "grub/syslinux/systemd-boot" \
2055# "10" "/etc/lxdm/lxdm.conf" \
2056# "11" "/etc/pacman.conf" \
2057# "12" "$_Back" 2>${ANSWER}
2058
2059# HIGHLIGHT_SUB=$(cat ${ANSWER})
2060# case $(cat ${ANSWER}) in
2061# "1") [[ -e ${MOUNTPOINT}/etc/vconsole.conf ]] && FILE="${MOUNTPOINT}/etc/vconsole.conf"
2062# ;;
2063# "2") [[ -e ${MOUNTPOINT}/etc/locale.conf ]] && FILE="${MOUNTPOINT}/etc/locale.conf"
2064# ;;
2065# "3") [[ -e ${MOUNTPOINT}/etc/hostname ]] && FILE="${MOUNTPOINT}/etc/hostname"
2066# ;;
2067# "4") [[ -e ${MOUNTPOINT}/etc/hosts ]] && FILE="${MOUNTPOINT}/etc/hosts"
2068# ;;
2069# "5") [[ -e ${MOUNTPOINT}/etc/sudoers ]] && FILE="${MOUNTPOINT}/etc/sudoers"
2070# ;;
2071# "6") [[ -e ${MOUNTPOINT}/etc/mkinitcpio.conf ]] && FILE="${MOUNTPOINT}/etc/mkinitcpio.conf"
2072# ;;
2073# "7") [[ -e ${MOUNTPOINT}/etc/fstab ]] && FILE="${MOUNTPOINT}/etc/fstab"
2074# ;;
2075# "8") [[ -e ${MOUNTPOINT}/etc/crypttab ]] && FILE="${MOUNTPOINT}/etc/crypttab"
2076# ;;
2077# "9") [[ $BOOTLOADER == "grub" ]] && FILE="${MOUNTPOINT}/etc/default/grub"
2078# [[ $BOOTLOADER == "syslinux" ]] && FILE="${MOUNTPOINT}/boot/syslinux/syslinux.cfg"
2079# if [[ $BOOTLOADER == "systemd-boot" ]]; then
2080# FILE="${MOUNTPOINT}${UEFI_MOUNT}/loader/loader.conf"
2081# files=$(ls ${MOUNTPOINT}${UEFI_MOUNT}/loader/entries/*.conf)
2082# for i in ${files}; do
2083# FILE="$FILE ${i}"
2084# done
2085# fi
2086# ;;
2087 #"10") [[ -e ${MOUNTPOINT}/etc/lxdm/lxdm.conf ]] && FILE="${MOUNTPOINT}/etc/lxdm/lxdm.conf"
2088 # ;;
2089 #"11") [[ -e ${MOUNTPOINT}/etc/pacman.conf ]] && FILE="${MOUNTPOINT}/etc/pacman.conf"
2090 # ;;
2091# *) main_menu
2092# ;;
2093 # esac
2094
2095# [[ $FILE != "" ]] && mousepad -i $FILE \
2096# || dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_ErrTitle " --msgbox "$_SeeConfErrBody" 0 0
2097
2098# edit_configs
2099#}
2100
2101main_menu() {
2102
2103 if [[ $HIGHLIGHT != 5 ]]; then
2104 HIGHLIGHT=$(( HIGHLIGHT + 1 ))
2105 fi
2106
2107 dialog --default-item ${HIGHLIGHT} --backtitle "$VERSION - $SYSTEM ($ARCHI)" --title " $_MMTitle " \
2108 --menu "$_MMBody" 0 0 5 \
2109 "1" "$_PrepMenuTitle" \
2110 "2" "$_InstBsMenuTitle" \
2111 "3" "$_ConfBseMenuTitle" \
2112 "4" "$_SeeConfOptTitle" \
2113 "5" "$_Done" 2>${ANSWER}
2114
2115 HIGHLIGHT=$(cat ${ANSWER})
2116
2117 # Depending on the answer, first check whether partition(s) are mounted and whether base has been installed
2118 if [[ $(cat ${ANSWER}) -eq 2 ]]; then
2119 check_mount
2120 fi
2121
2122 if [[ $(cat ${ANSWER}) -ge 3 ]] && [[ $(cat ${ANSWER}) -le 4 ]]; then
2123 check_mount
2124 check_base
2125 fi
2126
2127 case $(cat ${ANSWER}) in
2128 "1") prep_menu
2129 ;;
2130 "2") install_root_menu
2131 ;;
2132 "3") config_base_menu
2133 ;;
2134 "4") edit_configs
2135 ;;
2136 *) dialog --backtitle "$VERSION - $SYSTEM ($ARCHI)" --yesno "$_CloseInstBody" 0 0
2137
2138 if [[ $? -eq 0 ]]; then
2139 umount_partitions
2140 clear
2141 exit 0
2142 else
2143 main_menu
2144 fi
2145
2146 ;;
2147 esac
2148
2149 main_menu
2150
2151}
2152
2153######################################################################
2154## ##
2155## Execution ##
2156## ##
2157######################################################################
2158id_system
2159select_language
2160check_requirements
2161
2162 while true; do
2163 main_menu
2164 done