Commit ee9086ff authored by picodotdev's avatar picodotdev

Sanitize configuration variables

parent 0b91ad04
......@@ -3,8 +3,7 @@ KEYS="es"
LOG="false"
# partition
DEVICE="/dev/sda" # sata
#DEVICE="/dev/nvme0n1" # nvme
DEVICE="!/dev/sda !/dev/nvme0n1" # sata nvme
LVM="true"
PARTITION_ROOT_ENCRYPTION_PASSWORD="archlinux"
FILE_SYSTEM_TYPE="ext4" # ext4 btrfs xfs
......@@ -22,11 +21,6 @@ PACMAN_MIRROR="https://mirrors.kernel.org/archlinux/\$repo/os/\$arch"
KERNELS="!linux-lts !linux-lts-headers !linux-hardened !linux-hardened-headers !linux-zen !linux-zen-headers"
KERNELS_COMPRESSION="!gzip !bzip2 !lzma !xz !lzop !lz4"
KERNELS=$(echo $KERNELS | sed "s/![^ ]*//g") # remove disabled packages
KERNELS=$(echo $KERNELS | sed "s/ {2,}/ /g") # remove white spaces
KERNELS_COMPRESSION=$(echo $KERNELS_COMPRESSION | sed "s/![^ ]*//g")
KERNELS_COMPRESSION=$(echo $KERNELS_COMPRESSION | sed "s/ {2,}/ /g")
# config
TIMEZONE="/usr/share/zoneinfo/Europe/Madrid"
LOCALE="es_ES.UTF-8 UTF-8"
......@@ -56,13 +50,6 @@ VULKAN="false"
DISPLAY_DRIVER_HARDWARE_ACCELERATION="false"
DISPLAY_DRIVER_HARDWARE_ACCELERATION_INTEL="!intel-media-driver !libva-intel-driver"
DESKTOP_ENVIRONMENT=$(echo $DESKTOP_ENVIRONMENT | sed "s/![^ ]*//g") # remove disabled packages
DESKTOP_ENVIRONMENT=$(echo $DESKTOP_ENVIRONMENT | sed "s/ {2,}/ /g") # remove white spaces
DISPLAY_DRIVER=$(echo $DISPLAY_DRIVER | sed "s/![^ ]*//g")
DISPLAY_DRIVER=$(echo $DISPLAY_DRIVER | sed "s/ {2,}/ /g")
DISPLAY_DRIVER_HARDWARE_ACCELERATION_INTEL=$(echo $DISPLAY_DRIVER_HARDWARE_ACCELERATION_INTEL | sed "s/![^ ]*//g")
DISPLAY_DRIVER_HARDWARE_ACCELERATION_INTEL=$(echo $DISPLAY_DRIVER_HARDWARE_ACCELERATION_INTEL | sed "s/ {2,}/ /g")
# packages (precede package name with ! for not install)
PACKAGES_PACMAN_INTERNET="!firefox !chromium !apache !nginx !curl !wget !filezilla !sshfs !openssh !transmission-gtk !transmission-qt !amule !geary !thunderbird !empathy !kopete !polari !konversation !liferea !hugo !gnome-boxes"
PACKAGES_PACMAN_MULTIMEDIA="!gthumb !gimp !imagemagick !krita !inkscape !blender !cmus !vlc !easytag !ardour !audacity !ffmpeg !gnome-phone-manager !kdeconnect !gstreamer !gst-plugins-good !gst-plugins-bad !gst-plugins-ugly !bluez !bluez-utils"
......@@ -89,12 +76,5 @@ PACKAGES_AUR_CUSTOM=""
PACKAGES_PACMAN="$PACKAGES_PACMAN_INTERNET $PACKAGES_PACMAN_MULTIMEDIA $PACKAGES_PACMAN_UTILITIES $PACKAGES_PACMAN_DOCUMENTS_AND_TEXT $PACKAGES_PACMAN_SECURITY $PACKAGES_PACMAN_SCIENCE $PACKAGES_PACMAN_OTHERS $PACKAGES_PACMAN_DEVELOPER $PACKAGES_PACMAN_CUSTOM"
PACKAGES_AUR="$PACKAGES_AUR_INTERNET $PACKAGES_AUR_MULTIMEDIA $PACKAGES_AUR_UTILITIES $PACKAGES_AUR_DOCUMENTS_AND_TEXT $PACKAGES_AUR_SECURITY $PACKAGES_AUR_SCIENCE $PACKAGES_AUR_OTHERS $PACKAGES_AUR_DEVELOPER $PACKAGES_AUR_CUSTOM"
PACKAGES_PACMAN=$(echo $PACKAGES_PACMAN | sed "s/![^ ]*//g") # remove disabled packages
PACKAGES_PACMAN=$(echo $PACKAGES_PACMAN | sed "s/ {2,}/ /g") # remove white spaces
AUR=$(echo $AUR | sed "s/![^ ]*//g")
AUR=$(echo $AUR | sed "s/ {2,}/ /g")
PACKAGES_AUR=$(echo $PACKAGES_AUR | sed "s/![^ ]*//g")
PACKAGES_AUR=$(echo $PACKAGES_AUR | sed "s/ {2,}/ /g")
#reboot
REBOOT="true"
......@@ -78,6 +78,27 @@ function configuration_install() {
ADDITIONAL_USER_PASSWORDS_ARRAY=($ADDITIONAL_USER_PASSWORDS)
}
function sanitize_variables() {
DEVICE=$(sanitize_variable "$DEVICE")
KERNELS=$(sanitize_variable "$KERNELS")
KERNELS_COMPRESSION=$(sanitize_variable "$KERNELS_COMPRESSION")
DESKTOP_ENVIRONMENT=$(sanitize_variable "$DESKTOP_ENVIRONMENT")
DISPLAY_DRIVER=$(sanitize_variable "$DISPLAY_DRIVER")
DISPLAY_DRIVER_HARDWARE_ACCELERATION_INTEL=$(sanitize_variable "$DISPLAY_DRIVER_HARDWARE_ACCELERATION_INTEL")
PACKAGES_PACMAN=$(sanitize_variable "$PACKAGES_PACMAN")
AUR=$(sanitize_variable "$AUR")
PACKAGES_AUR=$(sanitize_variable "$PACKAGES_AUR")
}
function sanitize_variable() {
VARIABLE=$1
VARIABLE=$(echo $VARIABLE | sed "s/![^ ]*//g") # remove disabled packages
VARIABLE=$(echo $VARIABLE | sed "s/ {2,}/ /g") # remove innecesary white spaces
VARIABLE=$(echo $VARIABLE | sed 's/^[[:space:]]*//') # trim leading
VARIABLE=$(echo $VARIABLE | sed 's/[[:space:]]*$//') # trim trailing
echo "$VARIABLE"
}
function check_variables() {
check_variables_value "KEYS" "$KEYS"
check_variables_boolean "LOG" "$LOG"
......@@ -995,6 +1016,7 @@ function aur_install() {
function main() {
configuration_install
sanitize_variables
check_variables
warning
init
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment