feat(preset):add preset for quick installlation

check var exist before ask

remove var

add preset file

add a question to check should use preset

patch custom question

fix blacklist nouveau name not clear

fix input group var not clear

fix pokemon var not clear

add comment for preset var

use preset env var before excute script

add preset to script

print preset info
This commit is contained in:
PostCyberPunk
2024-01-04 20:28:31 +08:00
parent 9c80e88985
commit 33f538966f
8 changed files with 116 additions and 25 deletions

View File

@@ -25,12 +25,17 @@ echo "$(tput setaf 3)NOTE: If you are installing on a VM, ensure to enable 3D ac
echo
read -p "$(tput setaf 6)Would you like to proceed? (y/n): $(tput sgr0)" proceed
read -p "$(tput setaf 6)Would you like to preset? (y/n): $(tput sgr0)" use_preset
if [ "$proceed" != "y" ]; then
echo "Installation aborted."
exit 1
fi
if [[ $use_preset = [Yy] ]]; then
source ./preset.sh
fi
# Create Directory for Install Logs
if [ ! -d Install-Logs ]; then
@@ -59,22 +64,32 @@ colorize_prompt() {
LOG="install-$(date +%d-%H%M%S).log"
# Initialize variables to store user responses
aur_helper=""
bluetooth=""
dots=""
gtk_themes=""
nvidia=""
rog=""
sddm=""
thunar=""
xdph=""
zsh=""
# aur_helper=""
# bluetooth=""
# dots=""
# gtk_themes=""
# nvidia=""
# rog=""
# sddm=""
# thunar=""
# xdph=""
# zsh=""
# Define the directory where your scripts are located
script_directory=install-scripts
# Function to ask a yes/no question and set the response in a variable
ask_yes_no() {
if [[ ! -z "${!2}" ]]; then
echo "$(colorize_prompt "$CAT" "$1 (Preset): ${!2}")"
if [[ "${!2}" = [Yy] ]]; then
return 0
else
return 1
fi
else
eval "$2=''"
fi
while true; do
read -p "$(colorize_prompt "$CAT" "$1 (y/n): ")" choice
case "$choice" in
@@ -91,6 +106,12 @@ ask_custom_option() {
local valid_options="$2"
local response_var="$3"
if [[ ! -z "${!3}" ]]; then
return 0
else
eval "$3=''"
fi
while true; do
read -p "$(colorize_prompt "$CAT" "$prompt ($valid_options): ")" choice
if [[ " $valid_options " == *" $choice "* ]]; then
@@ -108,7 +129,7 @@ execute_script() {
if [ -f "$script_path" ]; then
chmod +x "$script_path"
if [ -x "$script_path" ]; then
"$script_path"
env USE_PRESET=$use_preset "$script_path"
else
echo "Failed to make script '$script' executable."
fi
@@ -129,8 +150,6 @@ ask_yes_no "-Do you want to configure Bluetooth?" bluetooth
printf "\n"
ask_yes_no "-Do you want to install Thunar file manager?" thunar
printf "\n"
ask_yes_no "-Install & configure SDDM log-in Manager w/ (Optional) SDDM Theme?" sddm
printf "\n"
ask_yes_no "-Install XDG-DESKTOP-PORTAL-HYPRLAND? (For proper Screen Share ie OBS)" xdph
printf "\n"
ask_yes_no "-Install zsh, oh-my-zsh & (Optional) pokemon-colorscripts?" zsh