Files
dots-hyprland/setup
T
2025-10-26 23:13:49 +08:00

101 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/env bash
cd "$(dirname "$0")"
# Use REPO_ROOT instead of base - when scripts are sourced they do not need export to inherit vars
REPO_ROOT="$(pwd)"
source ./sdata/lib/environment-variables.sh
source ./sdata/lib/functions.sh
source ./sdata/lib/package-installers.sh
prevent_sudo_or_root
set -e
#####################################################################################
showhelp_global(){
printf "[$0]: Handle setup for illogical-impulse.
Syntax:
$0 <subcommand> [OPTIONS]...
Subcommands:
install (Default) Install/Reinstall/Update illogical-impulse.
install-deps Run the install step \"1. Install dependencies\"
install-setups Run the install step \"2. Setup for permissions/services etc\"
install-files Run the install step \"3. Copying config files\"
exp-uninstall (Experimental) Uninstall illogical-impulse.
exp-update (Experimental) Update illogical-impulse without fully reinstall.
exp-update-old (Experimental) exp-update but use behaves like old version.
help Show this help message.
For each <subcommand>, use -h for details:
$0 <subcommand> -h
"
}
case $1 in
# Global help
help|--help|-h)showhelp_global;exit;;
# Correct subcommand
install|exp-uninstall|exp-update|exp-update-old)
SUBCMD_NAME=$1
SUBCMD_DIR=./sdata/subcmd-$1
shift;;
# Correct subcommand but not using ./sdata/subcmd-$1
install-deps|install-setups|install-files)
SUBCMD_NAME=$1
SUBCMD_DIR=./sdata/subcmd-install
shift;;
# No subcommand, default to install
-*|"")
SUBCMD_NAME=install
SUBCMD_DIR=./sdata/subcmd-install
;;
# Wrong subcommand
*)printf "${STY_RED}Unknown subcommand \"$1\".${STY_RST}\n";showhelp_global;exit 1;;
esac
#####################################################################################
if [[ -f "${SUBCMD_DIR}/options.sh" ]];
then source "${SUBCMD_DIR}/options.sh"
fi
case ${SUBCMD_NAME} in
install)
if [[ "${SKIP_ALLGREETING}" != true ]]; then
source ${SUBCMD_DIR}/0.greeting.sh
fi
if [[ "${SKIP_ALLDEPS}" != true ]]; then
source ${SUBCMD_DIR}/1.deps-selector.sh
fi
if [[ "${SKIP_ALLSETUPS}" != true ]]; then
source ${SUBCMD_DIR}/2.setups-selector.sh
fi
if [[ "${SKIP_ALLFILES}" != true ]]; then
if [[ "${EXPERIMENTAL_FILES_SCRIPT}" == true ]]; then
source ${SUBCMD_DIR}/3.files-exp.sh
else
source ${SUBCMD_DIR}/3.files.sh
fi
fi
;;
install-deps)
if [[ "${SKIP_ALLDEPS}" != true ]]; then
source ${SUBCMD_DIR}/1.deps-selector.sh
fi
;;
install-setups)
if [[ "${SKIP_ALLSETUPS}" != true ]]; then
source ${SUBCMD_DIR}/2.setups-selector.sh
fi
;;
install-files)
if [[ "${SKIP_ALLFILES}" != true ]]; then
if [[ "${EXPERIMENTAL_FILES_SCRIPT}" == true ]]; then
source ${SUBCMD_DIR}/3.files-exp.sh
else
source ${SUBCMD_DIR}/3.files.sh
fi
fi
;;
exp-*)
source ${SUBCMD_DIR}/0.run.sh
exit
;;
esac