add install targets

This commit is contained in:
Andrejus
2020-03-25 19:57:24 +00:00
parent 826cc598b9
commit ae4fc2832c
19 changed files with 111 additions and 196 deletions

View File

@@ -1,9 +1,8 @@
#!/usr/bin/env bash
#
# Invokes all install scripts.
#
set -euo pipefail
source "$dotfiles_dir/utils.sh"
export install_dir="$dotfiles_dir/install"
source "$install_dir/utils.sh"
printf "\nInstalling ${C_CYAN}$REPOSITORY${C_NC}"
printf " as ${C_YELLOW}$USER${C_NC}\n"
@@ -21,24 +20,26 @@ if [ -f "$install_lock_file" ]; then
printf "Please wait for script to exit or ${C_YELLOW}make clean${C_NC}\n"
exit 1
fi
touch "$install_lock_file" # Requires clean
touch "$install_lock_file"
# Run all install scripts
export install_dir="$dotfiles_dir/install"
readonly script_filter="$install_dir/*.sh" # Don't escape to unwrap glob
for script in $script_filter; do
[ -e "$script" ] || continue
# Install all scripts by default
if [ -z "$TARGET" ]; then
TARGET="all"
fi
# Get script name, split by dash
script_name="$(basename "$script" ".sh")"
IFS='-' read -a script_fields <<< "$script_name"
if [ "$TARGET" == "all" ]; then
scripts=($install_dir/*.sh)
else
scripts=($install_dir/*-{apt,bash,$TARGET}.sh)
fi
for script in "${scripts[@]}"; do
script_name="$(basename $script .sh)"
IFS='-' read -a script_fields <<<"$script_name"
script_number=${script_fields[0]}
script_target=${script_fields[1]}
# Log execution
printf "\nRunning #$script_number ${C_YELLOW}$script_target${C_NC}...\n${C_DGRAY}"
# Run and indent output
chmod +x "$script"
source "$HOME/.bashrc" && "$script" | indent
printf "${C_NC}"
@@ -46,7 +47,6 @@ for script in $script_filter; do
# Clean up if fails
done || make clean
# Clean up and exit
printf "\nDone! Cleaning up...\n${C_DGRAY}"
make clean
printf "${C_NC}\n"