added protection for duplicaton

This commit is contained in:
mfgbhatti 2022-01-28 17:45:16 +00:00
parent 3ada041b6a
commit 99e648635e
1 changed files with 30 additions and 14 deletions

View File

@ -81,7 +81,7 @@ set_btrfs () {
# Used -a to get more than one argument # Used -a to get more than one argument
echo "Please enter your btrfs subvolumes separated by space" echo "Please enter your btrfs subvolumes separated by space"
echo "usualy they start with @ like @home, @temp etc." echo "usualy they start with @ like @home, @temp etc."
echo "Defaults are @, @home, @var, @tmp, @.snapshots" echo "Defaults are @home, @var, @tmp, @.snapshots"
echo " " echo " "
read -r -p "press enter to use default: " -a ARR read -r -p "press enter to use default: " -a ARR
if [[ -z "${ARR[*]}" ]]; then if [[ -z "${ARR[*]}" ]]; then
@ -90,6 +90,7 @@ set_btrfs () {
# An array is a list of values. # An array is a list of values.
NAMES=(@) NAMES=(@)
for i in "${ARR[@]}"; do for i in "${ARR[@]}"; do
# Check for user input for @
if [[ $i =~ [@] ]]; then if [[ $i =~ [@] ]]; then
# push values to array # push values to array
NAMES+=("$i") NAMES+=("$i")
@ -97,8 +98,10 @@ set_btrfs () {
NAMES+=(@"${i}") NAMES+=(@"${i}")
fi fi
done done
# Check for duplicates
IFS=" " read -r -a SUBS <<< "$(tr ' ' '\n' <<< "${NAMES[@]}" | sort -u | tr '\n' ' ')"
# Set to config file # Set to config file
set_option "SUBVOLUMES" "(${NAMES[*]})" set_option "SUBVOLUMES" "${SUBS[*]}"
fi fi
} }
@ -131,7 +134,7 @@ set_password() {
title () { title () {
echo -ne "\n" echo -ne "\n"
echo -ne "------------------------------------------------------------------------\n" echo -ne "------------------------------------------------------------------------\n"
echo -ne "\t\t\t\"$1\"\n" echo -ne "\t\t\"$1\"\n"
echo -ne "------------------------------------------------------------------------\n" echo -ne "------------------------------------------------------------------------\n"
} }
@ -143,7 +146,7 @@ cat << EOF > "$CONFIG_FILE"
title () { title () {
echo -ne "\n" echo -ne "\n"
echo -ne "------------------------------------------------------------------------\n" echo -ne "------------------------------------------------------------------------\n"
echo -ne "\t\t\t\$1\n" echo -ne "\t\t\$1\n"
echo -ne "------------------------------------------------------------------------\n" echo -ne "------------------------------------------------------------------------\n"
} }
@ -198,6 +201,7 @@ background_check () {
echo -ne "ERROR! There seems to be no internet connection.\n" echo -ne "ERROR! There seems to be no internet connection.\n"
exit 1 exit 1
fi fi
set_option "SCRIPT_DIR" "$SCRIPT_DIR"
check_arch check_arch
efi_check efi_check
check_root check_root
@ -402,27 +406,27 @@ set_desktop() {
case "$REPLY" in case "$REPLY" in
1) 1)
# More packages can be added here # More packages can be added here
set_option "DE" "('plasma')" set_option "DE" "plasma"
set_option "DM" "sddm" set_option "DM" "sddm"
break break
;; ;;
2) 2)
set_option "DE" "('gnome')" set_option "DE" "gnome"
set_option "DM" "gdm" set_option "DM" "gdm"
break break
;; ;;
3) 3)
set_option "DE" "('xfce4')" set_option "DE" "xfce4"
set_option "DM" "lightdm" set_option "DM" "lightdm"
break break
;; ;;
4) 4)
set_option "DE" "('mate')" set_option "DE" "mate"
set_option "DM" "lightdm" set_option "DM" "lightdm"
break break
;; ;;
5) 5)
set_option "DE" "('lxqt')" set_option "DE" "lxqt"
set_option "DM" "lightdm" set_option "DM" "lightdm"
break break
;; ;;
@ -488,19 +492,32 @@ make_choice () {
clear clear
set_locale set_locale
clear clear
ssd_drive set_timezone
set_keymap set_keymap
ssd_drive
set_btrfs set_btrfs
set_option "FS" "btrfs" set_option "FS" "btrfs"
set_option "DE" "('plasma')" set_option "DE" "plasma"
set_option "DM" "sddm" set_option "DM" "sddm"
set_option "LAYOUT" 1 set_option "LAYOUT" 1
break break
;; ;;
2) 2)
clear
logo logo
# more option needed user_info
disk_selection
clear
set_locale
clear
set_timezone
set_keymap
ssd_drive
# Advance options
set_partion_layout
set_filesystem
set_desktop
break break
;; ;;
*) echo "Wrong option. Try again" *) echo "Wrong option. Try again"
@ -513,9 +530,8 @@ make_choice () {
fi fi
done done
} }
# background_check background_check
# write_to_config # write_to_config
clear clear
logo logo
# title "Automated Arch Linux Installer"
make_choice make_choice