-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathvli.sh
executable file
·2734 lines (2369 loc) · 102 KB
/
vli.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /bin/bash
# Author: Le0xFF
# Script name: vli.sh
# Github repo: https://github.com/Le0xFF/VoidLinuxInstaller
#
# Description: My first attempt at creating a bash script, trying to converting my gist into a bash script. Bugs are more than expected.
# https://gist.github.com/Le0xFF/ff0e3670c06def675bb6920fe8dd64a3
#
# Catch kill signals
trap "kill_script" INT TERM QUIT
# Variables
## Can be manually modified
user_drive=''
boot_partition=''
root_partition=''
boot_label=''
root_label=''
current_xkeyboard_layout=''
user_keyboard_layout=''
## Better not change them
drive_partition_selection='0'
encryption_yn='n'
luks_ot=''
encrypted_name=''
encrypted_partition=''
lvm_yn='n'
vg_name=''
lv_root_name=''
lvm_partition=''
final_drive=''
hdd_ssd=''
# Constants
regex_GPT="[Gg][Pp][Tt]"
regex_YES="[Yy]"
regex_NO="[Nn]"
regex_BACK="[Bb][Aa][Cc][Kk]"
regex_EFISTUB="[Ee][Ff][Ii][Ss][Tt][Uu][Bb]"
regex_GRUB2="[Gg][Rr][Uu][Bb][2]"
regex_ROOT="[Rr][Oo][Oo][Tt]"
regex_FAT32="[Vv][Ff][Aa][Tt]"
void_packages_repo="https://github.com/void-linux/void-packages.git"
# Colours
BLUE_LIGHT="\e[1;34m"
BLUE_LIGHT_FIND="\033[1;34m"
GREEN_DARK="\e[0;32m"
GREEN_LIGHT="\e[1;32m"
NORMAL="\e[0m"
NORMAL_FIND="\033[0m"
RED_LIGHT="\e[1;31m"
BLACK_FG_WHITE_BG="\e[30;47m"
# Functions
function press_any_key_to_continue {
echo -e -n "${BLACK_FG_WHITE_BG}[Press any key to continue...]${NORMAL}"
read -n 1 -r _key
}
function kill_script {
echo -e -n "\n\n${RED_LIGHT}Kill or quit signal captured.\nUnmonting what should have been mounted, cleaning and closing everything...${NORMAL}\n\n"
if findmnt /mnt &>/dev/null; then
umount --recursive /mnt
fi
if [[ "$lvm_yn" == "y" ]] || [[ "$lvm_yn" == "Y" ]]; then
lvchange -an /dev/mapper/"$vg_name"-"$lv_root_name"
vgchange -an /dev/mapper/"$vg_name"
fi
if [[ "$encryption_yn" == "y" ]] || [[ "$encryption_yn" == "Y" ]]; then
cryptsetup close /dev/mapper/"$encrypted_name"
fi
if [[ -f "$HOME"/chroot.sh ]]; then
rm -f "$HOME"/chroot.sh
fi
echo -e -n "\n${GREEN_LIGHT}Everything's done, quitting.${NORMAL}\n\n"
exit 1
}
function check_if_bash {
if [[ "$(/bin/ps -p $$ | awk 'NR==2 {print $4}')" != "bash" ]]; then
echo -e -n "Please run this script with bash shell: \"bash vli.sh\".\n"
exit 1
fi
}
function check_if_run_as_root {
if [[ "$UID" != "0" ]]; then
echo -e -n "Please run this script as root.\n"
exit 1
fi
}
function check_if_uefi {
if ! grep efivar -q /proc/mounts; then
if ! mount -t efivarfs efivarfs /sys/firmware/efi/efivars/ &>/dev/null; then
echo -e -n "Please run this script only on a UEFI system."
exit 1
fi
fi
}
function create_chroot_script {
if [[ -f "$HOME"/chroot.sh ]]; then
rm -f "$HOME"/chroot.sh
fi
cat >>"$HOME"/chroot.sh <<'EndOfChrootScript'
#! /bin/bash
# Variables
bootloader_id=''
bootloader=''
newuser_yn='n'
# Functions
function press_any_key_to_continue {
echo -e -n "${BLACK_FG_WHITE_BG}[Press any key to continue...]${NORMAL}"
read -n 1 -r _key
}
# Source: https://www.reddit.com/r/voidlinux/comments/jlkv1j/xs_quick_install_tool_for_void_linux/
function xs {
xpkg -a |
fzf -m --preview 'xq {1}' --preview-window=right:66%:wrap |
xargs -ro xi
press_any_key_to_continue
}
function header_ic {
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}# VLI #${NORMAL} ${GREEN_LIGHT}Chroot${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######${NORMAL} ${GREEN_LIGHT}Initial configuration${NORMAL} ${GREEN_LIGHT}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
}
function initial_configuration {
clear
header_ic
# Root password
echo -e -n "\nSetting ${BLUE_LIGHT}root password${NORMAL}:\n"
while true; do
echo
if passwd root; then
break
else
echo -e -n "\n${RED_LIGHT}Something went wrong, please try again.${NORMAL}\n\n"
press_any_key_to_continue
echo
fi
done
echo -e -n "\nSetting root permissions...\n"
chown root:root /
chmod 755 /
echo -e -n "\nEnabling wheel group to use sudo...\n"
echo "%wheel ALL=(ALL) ALL" >/etc/sudoers.d/10-wheel
echo -e -n "\nExporting variables that will be used for fstab...\n"
export LUKS_UUID=$(blkid -s UUID -o value "$root_partition")
export ROOT_UUID=$(blkid -s UUID -o value "$final_drive")
echo -e -n "\nWriting fstab...\n"
sed -i '/tmpfs/d' /etc/fstab
cat <<EOF >>/etc/fstab
# Root subvolume
UUID=$ROOT_UUID / $(blkid --match-tag TYPE --output value "$final_drive") $BTRFS_OPT,subvol=@ 0 0
# Home subvolume
UUID=$ROOT_UUID /home $(blkid --match-tag TYPE --output value "$final_drive") $BTRFS_OPT,subvol=@home 0 0
# Snapshots subvolume, uncomment the following line after creating a config for root [/] in snapper
#UUID=$ROOT_UUID /.snapshots $(blkid --match-tag TYPE --output value "$final_drive") $BTRFS_OPT,subvol=@snapshots 0 0
# Some applications don't like to have /var/log folders as read only.
# Log folders, to allow booting snapshots with rd.live.overlay.overlayfs=1
UUID=$ROOT_UUID /var/log $(blkid --match-tag TYPE --output value "$final_drive") $BTRFS_OPT,subvol=@/var/log 0 0
# TMPfs
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
EOF
echo -e -n "\nEnabling internet service at first boot...\n"
ln -s /etc/sv/dbus /etc/runit/runsvdir/default/
ln -s /etc/sv/NetworkManager /etc/runit/runsvdir/default/
echo -e -n "\nAdding needed dracut configuration files...\n"
echo -e "hostonly=yes\nhostonly_cmdline=yes" >>/etc/dracut.conf.d/00-hostonly.conf
echo -e "add_dracutmodules+=\" crypt btrfs lvm resume \"" >>/etc/dracut.conf.d/20-addmodules.conf
echo -e "tmpdir=/tmp" >>/etc/dracut.conf.d/30-tmpfs.conf
echo -e -n "\nGenerating new dracut initramfs...\n\n"
press_any_key_to_continue
echo
dracut --regenerate-all --force --hostonly
echo
press_any_key_to_continue
# Set timezone
clear
header_ic
echo -e -n "\nSetting the ${BLUE_LIGHT}timezone${NORMAL} in /etc/rc.conf.\n"
echo -e -n "\nPress any key to list all the timezones. Move with arrow keys and press \"q\" to exit the list."
read -n 1 -r _key
echo
awk '/^Z/ { print $2 }; /^L/ { print $3 }' /usr/share/zoneinfo/tzdata.zi |
less --RAW-CONTROL-CHARS --no-init
while true; do
echo -e -n "\nType the timezone you want to set and press [ENTER] (i.e. America/New_York): "
read -r user_timezone
if [[ ! -f /usr/share/zoneinfo/"$user_timezone" ]]; then
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
else
sed -i "/#TIMEZONE=/s|.*|TIMEZONE=\"$user_timezone\"|" /etc/rc.conf
echo -e -n "\n${GREEN_LIGHT}Timezone set to: $user_timezone.${NORMAL}\n\n"
press_any_key_to_continue
clear
break
fi
done
# Set keyboard layout
clear
header_ic
if [[ -n "$user_keyboard_layout" ]]; then
echo -e -n "\nSetting ${BLUE_LIGHT}$user_keyboard_layout${NORMAL} keyboard layout in /etc/rc.conf...\n"
sed -i "/#KEYMAP=/s/.*/KEYMAP=\"$user_keyboard_layout\"/" /etc/rc.conf
echo -e -n "\nSetting keymap in dracut configuration and regenerating initramfs...\n\n"
echo -e "i18n_vars=\"/etc/rc.conf:KEYMAP\"\ni18n_install_all=\"no\"" >>/etc/dracut.conf.d/i18n.conf
press_any_key_to_continue
echo
dracut --regenerate-all --force --hostonly
echo
press_any_key_to_continue
clear
else
echo -e -n "\nSetting ${BLUE_LIGHT}keyboard layout${NORMAL} in /etc/rc.conf.\n\nPress any key to list all the keyboard layouts.\nMove with arrow keys and press \"q\" to exit the list."
read -n 1 -r _key
echo
find /usr/share/kbd/keymaps/ -type f -iname "*.map.gz" -printf "${BLUE_LIGHT_FIND}%f\0${NORMAL_FIND}\n" |
sed -e 's/\..*$//' |
sort |
less --RAW-CONTROL-CHARS --no-init
while true; do
echo -e -n "\nType the keyboard layout you want to set and press [ENTER]: "
read -r user_keyboard_layout
if [[ -z "$user_keyboard_layout" ]] || ! loadkeys "$user_keyboard_layout" 2>/dev/null; then
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
else
sed -i "/#KEYMAP=/s/.*/KEYMAP=\"$user_keyboard_layout\"/" /etc/rc.conf
echo -e -n "\nKeyboard layout set to: ${BLUE_LIGHT}$user_keyboard_layout${NORMAL}.\n"
echo -e -n "\nSetting keymap in dracut configuration and regenerating initramfs...\n\n"
echo -e "i18n_vars=\"/etc/rc.conf:KEYMAP\"\ni18n_install_all=\"no\"" >>/etc/dracut.conf.d/i18n.conf
press_any_key_to_continue
echo
dracut --regenerate-all --force --hostonly
echo
press_any_key_to_continue
clear
break
fi
done
fi
# Set hostname
while true; do
header_ic
echo -e -n "\nSelect a ${BLUE_LIGHT}hostname${NORMAL} for your system: "
read -r hostname
if [[ -z "$hostname" ]]; then
echo -e -n "\n${RED_LIGHT}Please enter a valid hostname.${NORMAL}\n\n"
press_any_key_to_continue
clear
else
while true; do
echo -e -n "\nYou entered: ${BLUE_LIGHT}$hostname${NORMAL}.\n\n"
read -r -p "Is this the desired hostname? (y/n): " yn
if [[ "$yn" == "y" ]] || [[ "$yn" == "Y" ]]; then
set +o noclobber
echo "$hostname" >/etc/hostname
set -o noclobber
echo -e -n "\n${GREEN_LIGHT}Hostname successfully set.${NORMAL}\n\n"
press_any_key_to_continue
clear
break 2
elif [[ "$yn" == "n" ]] || [[ "$yn" == "N" ]]; then
echo -e -n "\n${RED_LIGHT}Please select another hostname.${NORMAL}\n\n"
press_any_key_to_continue
clear
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
fi
done
fi
done
# Set locales for x86_64
if [[ "$ARCH" == "x86_64" ]]; then
header_ic
echo -e -n "\nSetting the ${BLUE_LIGHT}locale${NORMAL} in /etc/default/libc-locales."
echo -e -n "\n\nPress any key to print all the available locales.\n\nPlease remember the ${BLUE_LIGHT}line number${NORMAL} corresponding to the locale you want to enable.\n"
echo -e -n "\nMove with arrow keys and press \"q\" to exit the list."
read -n 1 -r _key
echo
less --LINE-NUMBERS --RAW-CONTROL-CHARS --no-init /etc/default/libc-locales
while true; do
echo -e -n "\nPlease type the ${BLUE_LIGHT}line number${NORMAL} corresponding to the locale you want to enable and press [ENTER]: "
read -r user_locale_line_number
if [[ -z "$user_locale_line_number" ]] || [[ "$user_locale_line_number" -lt "11" ]] || [[ "$user_locale_line_number" -gt "499" ]]; then
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
else
while true; do
user_locale_pre=$(sed -n "${user_locale_line_number}"p /etc/default/libc-locales)
user_locale_uncommented=$(echo "${user_locale_pre//#/}")
user_locale=$(echo "${user_locale_uncommented%%[[:space:]]*}")
echo -e -n "\nYou choose line ${BLUE_LIGHT}$user_locale_line_number${NORMAL} that cointains locale ${BLUE_LIGHT}$user_locale${NORMAL}.\n\n"
read -r -p "Is this correct? (y/n): " yn
if [[ $yn =~ $regex_YES ]]; then
echo -e -n "\nUncommenting line ${BLUE_LIGHT}$user_locale_line_number${NORMAL} that contains locale ${BLUE_LIGHT}$user_locale${NORMAL}...\n"
sed -i "$user_locale_line_number s/^#//" /etc/default/libc-locales
echo -e -n "\nWriting locale ${BLUE_LIGHT}$user_locale${NORMAL} to /etc/locale.conf...\n\n"
sed -i "/LANG=/s/.*/LANG=$user_locale/" /etc/locale.conf
press_any_key_to_continue
clear
break 2
elif [[ $yn =~ $regex_NO ]]; then
echo -e -n "\n${RED_LIGHT}Please select another locale.${NORMAL}\n\n"
press_any_key_to_continue
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
fi
done
fi
done
fi
}
function header_ib {
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}# VLI #${NORMAL} ${GREEN_LIGHT}Chroot${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######${NORMAL} ${GREEN_LIGHT}Bootloader installation${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
}
function install_bootloader {
while true; do
if [[ "$luks_ot" == "2" ]]; then
header_ib
echo -e -n "\nLUKS version $luks_ot was previously selected.\n${BLUE_LIGHT}EFISTUB${NORMAL} will be used as bootloader.\n\n"
bootloader="EFISTUB"
press_any_key_to_continue
echo
else
header_ib
echo -e -n "\nSelect which ${BLUE_LIGHT}bootloader${NORMAL} do you want to use (EFISTUB, GRUB2): "
read -r bootloader
fi
if [[ $bootloader =~ $regex_EFISTUB ]]; then
echo -e -n "\nBootloader selected: ${BLUE_LIGHT}$bootloader${NORMAL}.\n"
echo -e -n "\nMounting $boot_partition to /boot...\n"
mkdir /TEMPBOOT
cp -pr /boot/* /TEMPBOOT/
rm -rf /boot/*
mount -o rw,noatime "$boot_partition" /boot
cp -pr /TEMPBOOT/* /boot/
rm -rf /TEMPBOOT
echo -e -n "\nSetting correct options in /etc/default/efibootmgr-kernel-hook...\n"
sed -i "/MODIFY_EFI_ENTRIES=0/s/0/1/" /etc/default/efibootmgr-kernel-hook
if [[ $encryption_yn =~ $regex_YES ]]; then
sed -i "/# OPTIONS=/s/.*/OPTIONS=\"loglevel=4 fbcon=nodefer rd.auto=1 rd.luks.name=$LUKS_UUID=$encrypted_name\"/" /etc/default/efibootmgr-kernel-hook
if [[ "$hdd_ssd" == "ssd" ]]; then
sed -i "/OPTIONS=/s/\"$/ rd.luks.allow-discards=$LUKS_UUID&/" /etc/default/efibootmgr-kernel-hook
fi
elif { [[ $encryption_yn =~ $regex_NO ]]; } && { [[ $lvm_yn =~ $regex_YES ]]; }; then
sed -i "/# OPTIONS=/s/.*/OPTIONS=\"loglevel=4 fbcon=nodefer rd.auto=1\"/" /etc/default/efibootmgr-kernel-hook
else
sed -i "/# OPTIONS=/s/.*/OPTIONS=\"loglevel=4 fbcon=nodefer\"/" /etc/default/efibootmgr-kernel-hook
fi
sed -i "/# DISK=/s|.*|DISK=\"\$(lsblk -pd -no pkname \$(findmnt -enr -o SOURCE -M /boot))\"|" /etc/default/efibootmgr-kernel-hook
sed -i "/# PART=/s_.*_PART=\"\$(lsblk -pd -no pkname \$(findmnt -enr -o SOURCE -M /boot) | grep --color=never -Eo \\\\\"[0-9]+\$\\\\\")\"_" /etc/default/efibootmgr-kernel-hook
echo -e -n "\nModifying /etc/kernel.d/post-install/50-efibootmgr to keep EFI entry after reboot...\n"
sed -i "/efibootmgr -qo \$bootorder/s/^/#/" /etc/kernel.d/post-install/50-efibootmgr
echo -e -n "\n${RED_LIGHT}Keep in mind that to keep the new EFI entry after each reboot,${NORMAL}\n"
echo -e -n "${RED_LIGHT}the last line of /etc/kernel.d/post-install/50-efibootmgr has been commented.${NORMAL}\n"
echo -e -n "${RED_LIGHT}Probably you will have to comment the same line after each efibootmgr update.${NORMAL}\n\n"
break
elif [[ $bootloader =~ $regex_GRUB2 ]]; then
echo -e -n "\nBootloader selected: ${BLUE_LIGHT}$bootloader${NORMAL}.\n"
# Fix kdfontop.c error
# https://github.com/torvalds/linux/blob/master/Documentation/fb/fbcon.rst
sed -i "/GRUB_CMDLINE_LINUX_DEFAULT=/s/\"$/ fbcon=nodefer&/" /etc/default/grub
if [[ $encryption_yn =~ $regex_YES ]]; then
echo -e -n "\nEnabling CRYPTODISK in GRUB...\n"
echo -e -n "\nGRUB_ENABLE_CRYPTODISK=y\n" >>/etc/default/grub
sed -i "/GRUB_CMDLINE_LINUX_DEFAULT=/s/\"$/ rd.auto=1 rd.luks.name=$LUKS_UUID=$encrypted_name&/" /etc/default/grub
if [[ "$hdd_ssd" == "ssd" ]]; then
sed -i "/GRUB_CMDLINE_LINUX_DEFAULT=/s/\"$/ rd.luks.allow-discards=$LUKS_UUID&/" /etc/default/grub
fi
elif { [[ $encryption_yn =~ $regex_NO ]]; } && { [[ $lvm_yn =~ $regex_YES ]]; }; then
sed -i "/GRUB_CMDLINE_LINUX_DEFAULT=/s/\"$/ rd.auto=1&/" /etc/default/grub
fi
if ! grep -q efivar /proc/mounts; then
echo -e -n "\nMounting efivarfs...\n"
mount -t efivarfs efivarfs /sys/firmware/efi/efivars/
fi
while true; do
echo -e -n "\nSelect a ${BLUE_LIGHT}bootloader-id${NORMAL} that will be used for grub install: "
read -r bootloader_id
if [[ -z "$bootloader_id" ]]; then
echo -e -n "\n${RED_LIGHT}Please enter a valid bootloader-id.${NORMAL}\n\n"
press_any_key_to_continue
else
while true; do
echo -e -n "\nYou entered: ${BLUE_LIGHT}$bootloader_id${NORMAL}.\n\n"
read -r -p "Is this the desired bootloader-id? (y/n): " yn
if [[ $yn =~ $regex_YES ]]; then
if [[ $encryption_yn =~ $regex_YES ]]; then
echo -e -n "\nGenerating random key to avoid typing password twice at boot...\n\n"
dd bs=512 count=4 if=/dev/random of=/boot/volume.key
echo -e -n "\nRandom key generated, unlocking the encrypted partition...\n\n"
if ! cryptsetup luksAddKey "$root_partition" /boot/volume.key; then
echo -e -n "\n${RED_LIGHT}Something went wrong, killing script...${NORMAL}\n\n"
kill_script
else
chmod 000 /boot/volume.key
chmod -R g-rwx,o-rwx /boot
echo -e -n "\nAdding random key to /etc/crypttab...\n"
echo -e "\n$encrypted_name UUID=$LUKS_UUID /boot/volume.key luks\n" >>/etc/crypttab
echo -e -n "\nAdding random key to dracut configuration files...\n"
echo -e "install_items+=\" /boot/volume.key /etc/crypttab \"" >>/etc/dracut.conf.d/10-crypt.conf
echo -e -n "\nGenerating new dracut initramfs...\n\n"
press_any_key_to_continue
echo
dracut --regenerate-all --force --hostonly
fi
fi
echo -e -n "\nInstalling GRUB on ${BLUE_LIGHT}/boot/efi${NORMAL} partition with ${BLUE_LIGHT}$bootloader_id${NORMAL} as bootloader-id...\n\n"
mkdir -p /boot/efi
mount -o rw,noatime "$boot_partition" /boot/efi/
grub-install --target=x86_64-efi --boot-directory=/boot --efi-directory=/boot/efi --bootloader-id="$bootloader_id" --recheck
echo -e -n "\nEnabling grub snapshot service at first boot...\n"
ln -s /etc/sv/grub-btrfs /etc/runit/runsvdir/default/
break 3
elif [[ $yn =~ $regex_NO ]]; then
echo -e -n "\n${RED_LIGHT}Please select another bootloader-id.${NORMAL}\n\n"
press_any_key_to_continue
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
fi
done
fi
done
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
fi
done
if [[ $lvm_yn =~ $regex_YES ]] && [[ "$hdd_ssd" == "ssd" ]]; then
echo -e -n "\nEnabling SSD trim for LVM...\n"
sed -i 's/issue_discards = 0/issue_discards = 1/' /etc/lvm/lvm.conf
fi
export UEFI_UUID=$(blkid -s UUID -o value "$boot_partition")
echo -e -n "\nWriting EFI partition to /etc/fstab...\n"
if [[ $bootloader =~ $regex_EFISTUB ]]; then
echo -e "\n# EFI partition\nUUID=$UEFI_UUID /boot $(blkid --match-tag TYPE --output value "$boot_partition") defaults,noatime 0 2" >>/etc/fstab
elif [[ $bootloader =~ $regex_GRUB2 ]]; then
echo -e "\n# EFI partition\nUUID=$UEFI_UUID /boot/efi $(blkid --match-tag TYPE --output value "$boot_partition") defaults,noatime 0 2" >>/etc/fstab
fi
echo -e -n "\nBootloader ${BLUE_LIGHT}$bootloader${NORMAL} successfully installed.\n\n"
press_any_key_to_continue
clear
header_ib
if [[ $bootloader =~ $regex_GRUB2 ]]; then
while true; do
echo -e -n "\nDo you want to set ${BLUE_LIGHT}${user_keyboard_layout}${NORMAL} keyboard layout also for GRUB2? (y/n): "
read -r yn
if [[ $yn =~ $regex_YES ]]; then
if [[ $lvm_yn =~ $regex_YES ]]; then
if [[ $encryption_yn =~ $regex_YES ]]; then
root_line=$(echo -e -n "cryptomount -u ${LUKS_UUID//-/}\nset root=(lvm/"$vg_name"-"$lv_root_name")\n")
else
root_line="set root=(lvm/$vg_name-$lv_root_name)"
fi
else
if [[ $encryption_yn =~ $regex_YES ]]; then
root_line=$(echo -e -n "cryptomount -u ${LUKS_UUID//-/}\nset root=(cryptouuid/${LUKS_UUID//-/})\n")
else
disk=$(blkid -s UUID -o value $final_drive)
root_line=$(echo -e -n "search --no-floppy --fs-uuid $disk --set pre_root\nset root=(\\\$pre_root)\n")
fi
fi
echo -e -n "\nCreating /etc/kernel.d/post-install/51-grub_ckb...\n"
cat <<End >>/etc/kernel.d/post-install/51-grub_ckb
#! /bin/sh
#
# Create grubx64.efi containing custom keyboard layout
# Requires: ckbcomp, grub2, xkeyboard-config
#
if [ ! -f /boot/efi/EFI/$bootloader_id/ORIG_grubx64.efi_ORIG ] ; then
if [ ! -f /boot/efi/EFI/$bootloader_id/grubx64.efi ] ; then
echo -e -n "\nFIle /boot/efi/EFI/$bootloader_id/grubx64.efi not found, install GRUB2 first!\n"
exit 1
else
mv /boot/efi/EFI/$bootloader_id/grubx64.efi /boot/efi/EFI/$bootloader_id/ORIG_grubx64.efi_ORIG
fi
fi
for file in $user_keyboard_layout.gkb early-grub.cfg grubx64_ckb.efi memdisk_ckb.tar ; do
if [ -f /boot/grub/\$file ] ; then
rm -f /boot/grub/\$file
fi
done
grub-kbdcomp --output=/boot/grub/$user_keyboard_layout.gkb $user_keyboard_layout 2> /dev/null
tar --create --file=/boot/grub/memdisk_ckb.tar --directory=/boot/grub/ $user_keyboard_layout.gkb 2> /dev/null
cat << EndOfGrubConf >> /boot/grub/early-grub.cfg
set gfxpayload=keep
loadfont=unicode
terminal_output gfxterm
terminal_input at_keyboard
keymap (memdisk)/$user_keyboard_layout.gkb
${root_line}/@
set prefix=\\\$root/boot/grub
configfile \\\$prefix/grub.cfg
EndOfGrubConf
grub-mkimage --config=/boot/grub/early-grub.cfg --output=/boot/grub/grubx64_ckb.efi --format=x86_64-efi --memdisk=/boot/grub/memdisk_ckb.tar diskfilter gcry_rijndael gcry_sha256 ext2 memdisk tar at_keyboard keylayouts configfile gzio part_gpt all_video efi_gop efi_uga video_bochs video_cirrus echo linux font gfxterm gettext gfxmenu help reboot terminal test search search_fs_file search_fs_uuid search_label cryptodisk luks lvm btrfs
if [ -f /boot/efi/EFI/$bootloader_id/grubx64.efi ] ; then
rm -f /boot/efi/EFI/$bootloader_id/grubx64.efi
fi
cp /boot/grub/grubx64_ckb.efi /boot/efi/EFI/$bootloader_id/grubx64.efi
End
chmod +x /etc/kernel.d/post-install/51-grub_ckb
echo -e -n "\nReconfiguring kernel...\n\n"
kernelver_pre=$(ls /lib/modules/)
kernelver="${kernelver_pre%.*}"
xbps-reconfigure -f linux"$kernelver"
break
elif [[ $yn =~ $regex_NO ]]; then
clear
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
fi
done
fi
echo -e -n "\nConfiguring AppArmor and setting it to enforce...\n"
sed -i "/APPARMOR=/s/.*/APPARMOR=enforce/" /etc/default/apparmor
sed -i "/#write-cache/s/^#//" /etc/apparmor/parser.conf
sed -i "/#show_notifications/s/^#//" /etc/apparmor/notify.conf
if [[ $bootloader =~ $regex_EFISTUB ]]; then
sed -i "/OPTIONS=/s/\"$/ apparmor=1 security=apparmor&/" /etc/default/efibootmgr-kernel-hook
echo -e -n "\nReconfiguring kernel...\n\n"
kernelver_pre=$(ls /lib/modules/)
kernelver=$(echo ${kernelver_pre%.*})
xbps-reconfigure -f linux"$kernelver"
elif [[ $bootloader =~ $regex_GRUB2 ]]; then
sed -i "/GRUB_CMDLINE_LINUX_DEFAULT=/s/\"$/ apparmor=1 security=apparmor&/" /etc/default/grub
echo -e -n "\nUpdating grub...\n\n"
update-grub
fi
echo
press_any_key_to_continue
clear
}
function header_cs {
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}# VLI #${NORMAL} ${GREEN_LIGHT}Chroot${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######${NORMAL} ${GREEN_LIGHT}SwapFile creation${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
}
function create_swapfile {
while true; do
header_cs
echo -e -n "\nDo you want to create a ${BLUE_LIGHT}swapfile${NORMAL} in ${BLUE_LIGHT}/var/swap/${NORMAL} btrfs subvolume?\nThis will also enable ${BLUE_LIGHT}zswap${NORMAL}, a cache in RAM for swap.\nA swapfile is needed if you plan to use hibernation (y/n): "
read -r yn
if [[ $yn =~ $regex_YES ]]; then
ram_size=$(free -g --si | awk -F " " 'FNR == 2 {print $2}')
while true; do
clear
header_cs
echo -e -n "\nYour system has ${BLUE_LIGHT}${ram_size}GB${NORMAL} of RAM.\n"
echo -e -n "\nPress [ENTER] to create a swapfile of the same dimensions or choose the desired size in GB (numbers only): "
read -r swap_size
if [[ -z "$swap_size" ]] || [[ "$swap_size" -gt "0" ]]; then
if [[ -z "$swap_size" ]]; then
swap_size=$ram_size
fi
echo -e -n "\nA swapfile of ${BLUE_LIGHT}${swap_size}GB${NORMAL} will be created in ${BLUE_LIGHT}/swap/${NORMAL} btrfs subvolume...\n\n"
btrfs filesystem mkswapfile /swap/swapfile --size "${swap_size}"G
mkswap --label SwapFile /swap/swapfile
swapon /swap/swapfile
RESUME_UUID=$(findmnt -no UUID -T /swap/swapfile)
RESUME_OFFSET=$(btrfs inspect-internal map-swapfile -r /swap/swapfile)
if [[ $bootloader =~ $regex_EFISTUB ]]; then
sed -i "/OPTIONS=/s/\"$/ resume=UUID=$RESUME_UUID resume_offset=$RESUME_OFFSET&/" /etc/default/efibootmgr-kernel-hook
elif [[ $bootloader =~ $regex_GRUB2 ]]; then
sed -i "/GRUB_CMDLINE_LINUX_DEFAULT=/s/\"$/ resume=UUID=$RESUME_UUID resume_offset=$RESUME_OFFSET&/" /etc/default/grub
fi
echo -e -n "\n# Swap Subvolume\nUUID=$ROOT_UUID /swap $(blkid --match-tag TYPE --output value "$final_drive") $BTRFS_OPT,subvol=@swap 0 2\n" >>/etc/fstab
echo -e -n "\n# SwapFile\n/swap/swapfile none swap sw 0 0\n" >>/etc/fstab
echo -e -n "\nEnabling zswap...\n"
echo "add_drivers+=\" lz4hc lz4hc_compress z3fold \"" >>/etc/dracut.conf.d/40-add_zswap_drivers.conf
echo -e -n "\nRegenerating dracut initramfs...\n\n"
press_any_key_to_continue
echo
dracut --regenerate-all --force --hostonly
if [[ $bootloader =~ $regex_EFISTUB ]]; then
sed -i "/OPTIONS=/s/\"$/ zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4hc zswap.zpool=z3fold&/" /etc/default/efibootmgr-kernel-hook
echo -e -n "\nReconfiguring kernel...\n\n"
kernelver_pre=$(ls /lib/modules/)
kernelver=$(echo ${kernelver_pre%.*})
xbps-reconfigure -f linux"$kernelver"
elif [[ $bootloader =~ $regex_GRUB2 ]]; then
sed -i "/GRUB_CMDLINE_LINUX_DEFAULT=/s/\"$/ zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4hc zswap.zpool=z3fold&/" /etc/default/grub
echo -e -n "\nUpdating grub...\n\n"
update-grub
fi
swapoff --all
echo -e -n "\n${GREEN_LIGHT}Swapfile successfully created and zswap successfully enabled.${NORMAL}\n\n"
press_any_key_to_continue
clear
break 2
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
fi
done
elif [[ $yn =~ $regex_NO ]]; then
echo -e -n "\n${RED_LIGHT}Swapfile will not be created.${NORMAL}\n\n"
press_any_key_to_continue
clear
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
fi
done
}
function header_cu {
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}# VLI #${NORMAL} ${GREEN_LIGHT}Chroot${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######${NORMAL} ${GREEN_LIGHT}Create new users${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
}
function create_user {
while true; do
header_cu
echo -e -n "\nDo you want to ${BLUE_LIGHT}add${NORMAL} any ${BLUE_LIGHT}new user${NORMAL}?"
echo -e -n "\nOnly non-root users can later configure Void Packages (y/n): "
read -r yn
if [[ $yn =~ $regex_YES ]]; then
while true; do
clear
header_cu
echo -e -n "\nPlease select a ${BLUE_LIGHT}name${NORMAL} for your new user (i.e. MyNewUser): "
read -r newuser
if [[ -z "$newuser" ]] || [[ $newuser =~ $regex_ROOT ]]; then
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
elif getent passwd "$newuser" &>/dev/null; then
echo -e -n "\n${RED_LIGHT}User ${newuser} already exists.\nPlease select another username.${NORMAL}\n\n"
press_any_key_to_continue
clear
break
else
while true; do
echo -e -n "\nIs username ${BLUE_LIGHT}$newuser${NORMAL} okay? (y/n): "
read -r yn
if [[ $yn =~ $regex_NO ]]; then
echo -e -n "\n${RED_LIGHT}Aborting, please select another name.${NORMAL}\n\n"
press_any_key_to_continue
clear
break 2
elif [[ $yn =~ $regex_YES ]]; then
echo -e -n "\nAdding new user ${BLUE_LIGHT}$newuser${NORMAL} and giving access to groups:\n"
echo -e -n "kmem, wheel, tty, tape, daemon, floppy, disk, lp, dialout, audio, video,"
echo -e -n "\nutmp, cdrom, optical, mail, storage, scanner, kvm, input, plugdev, users.\n"
useradd --create-home --groups kmem,wheel,tty,tape,daemon,floppy,disk,lp,dialout,audio,video,utmp,cdrom,optical,mail,storage,scanner,kvm,input,plugdev,users "$newuser"
echo -e -n "\n${GREEN_LIGHT}User ${newuser} successfully created.${NORMAL}\n\n"
press_any_key_to_continue
newuser_yn="y"
break 3
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
fi
done
fi
done
elif [[ $yn =~ $regex_NO ]]; then
if [[ -z "$newuser_yn" ]]; then
newuser_yn="n"
fi
clear
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
fi
done
}
function header_cup {
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}# VLI #${NORMAL} ${GREEN_LIGHT}Chroot${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######${NORMAL} ${GREEN_LIGHT}Change users password${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
}
function change_user_password {
while true; do
header_cup
echo -e -n "\nDo you want to change users ${BLUE_LIGHT}password${NORMAL}? (y/n): "
read -r yn
if [[ $yn =~ $regex_YES ]]; then
clear
while true; do
header_cup
echo -e -n "\nListing all users:\n"
awk -F':' '{print $1}' /etc/passwd
echo -e -n "\nPlease select a valid user: "
read -r user_change_password
if grep -qw "$user_change_password" /etc/passwd; then
while true; do
echo
if passwd "$user_change_password"; then
echo -e -n "\n${GREEN_LIGHT}Password successfully changed for user ${user_change_password}.${NORMAL}\n\n"
press_any_key_to_continue
break 3
else
echo -e -n "\n${RED_LIGHT}Something went wrong, please try again.${NORMAL}\n\n"
press_any_key_to_continue
clear
break 2
fi
done
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
fi
done
elif [[ $yn =~ $regex_NO ]]; then
clear
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
fi
done
}
function header_cus {
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}# VLI #${NORMAL} ${GREEN_LIGHT}Chroot${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######${NORMAL} ${GREEN_LIGHT}Change user shell${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
}
function change_user_shell {
while true; do
header_cup
echo -e -n "\nDo you want to change users default ${BLUE_LIGHT}shell${NORMAL}? (y/n): "
read -r yn
if [[ $yn =~ $regex_YES ]]; then
clear
while true; do
header_cup
echo -e -n "\nListing all users found in /etc/passwd:\n"
awk -F':' '{print $1}' /etc/passwd
echo -e -n "\nPlease select a valid user: "
read -r user_change_shell
if grep -q "$user_change_shell" /etc/passwd; then
clear
header_cus
echo -e -n "\nListing all the available shells:\n\n"
chsh --list-shells
echo -e -n "\nWhich ${BLUE_LIGHT}shell${NORMAL} do you want to set for user ${BLUE_LIGHT}$user_change_shell${NORMAL}?"
echo -e -n "\nPlease enter the full shell path (i.e. /bin/sh): "
read -r set_user_shell
if [[ ! -x "$set_user_shell" ]]; then
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
else
echo
if chsh --shell "$set_user_shell" "$user_change_shell"; then
echo -e -n "\n${GREEN_LIGHT}Default shell successfully changed.${NORMAL}\n\n"
press_any_key_to_continue
else
echo -e -n "\n${RED_LIGHT}Something went wrong, please try again.${NORMAL}\n\n"
press_any_key_to_continue
fi
clear
break 3
fi
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
break 2
fi
done
elif [[ $yn =~ $regex_NO ]]; then
clear
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
fi
done
}
function header_up {
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}# VLI #${NORMAL} ${GREEN_LIGHT}Chroot${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######${NORMAL} ${GREEN_LIGHT}Uninstall package${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
}
function uninstall_packages {
while true; do
header_up
echo -e -n "\nDo you want to ${BLUE_LIGHT}uninstall${NORMAL} any package? (y/n): "
read -r yn
if [[ $yn =~ $regex_YES ]]; then
clear
while true; do
header_up
echo -e -n "\nListing all installed packages."
echo -e -n "\nPress any key to continue and then press \"q\" to exit the list.\n\n"
press_any_key_to_continue
xpkg -m | less --RAW-CONTROL-CHARS --no-init
echo -e -n "\nPlease enter all the packages you want to uninstall separated by spaces: "
read -r user_uninstall_packages
if xbps-remove $user_uninstall_packages; then
echo -e -n "\n${GREEN_LIGHT}Packages were successfully uninstalled.${NORMAL}\n\n"
press_any_key_to_continue
else
echo -e -n "\n${RED_LIGHT}Something went wrong, please try again.${NORMAL}\n\n"
press_any_key_to_continue
fi
clear
break 2
done
elif [[ $yn =~ $regex_NO ]]; then
clear
break
else
echo -e -n "\n${RED_LIGHT}Not a valid input.${NORMAL}\n\n"
press_any_key_to_continue
clear
fi
done
}
function header_eds {
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}# VLI #${NORMAL} ${GREEN_LIGHT}Chroot${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######${NORMAL} ${GREEN_LIGHT}Enable/disable services${NORMAL} ${GREEN_DARK}#${NORMAL}\n"
echo -e -n "${GREEN_DARK}#######################################${NORMAL}\n"
}
function enable_disable_services {
while true; do
clear
header_eds
echo -e -n "\nDo you want to enable or disable any service?\n\n"
select user_arch in Enable Disable back; do
case "$user_arch" in
Enable)
clear