-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add new refactored install script
Trying out a single install script instead of the separate scripts for profiles and standalone in an attempt to simplify it and add some additional functionality afterwards.
- Loading branch information
1 parent
0e8ad98
commit 0c0d4ca
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env zsh | ||
|
||
# Constants | ||
BASE_CONFIG="base.yaml" | ||
META_DIR="meta" | ||
CONFIG_DIR="configs" | ||
PROFILES_DIR="profiles" | ||
DOTBOT_DIR="dotbot" | ||
DOTBOT_BIN="bin/dotbot" | ||
|
||
# Get the directory of the script | ||
BASE_DIR="$(cd "$(dirname "${(%):-%N}")" && pwd)" | ||
cd "${BASE_DIR}" | ||
|
||
# Sync submodule URLs | ||
git submodule sync --quiet --recursive | ||
|
||
# Initialize and update submodules | ||
git submodule update --init --recursive | ||
|
||
# Fetch and pull the latest changes for submodules | ||
git submodule foreach --recursive git fetch --quiet | ||
git submodule foreach --recursive git pull --quiet origin main | ||
|
||
# Function to combine base and specific config files and run Dotbot | ||
run_dotbot() { | ||
local config="$1" | ||
echo -e "\nConfigure $config" | ||
local base_config="${BASE_DIR}/${META_DIR}/${BASE_CONFIG}" | ||
local config_file="${BASE_DIR}/${META_DIR}/${CONFIG_DIR}/${config}.yaml" | ||
local combined_config | ||
|
||
combined_config=$(mktemp) | ||
cat "$base_config" "$config_file" > "$combined_config" | ||
"${BASE_DIR}/${META_DIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASE_DIR}" -c "$combined_config" | ||
rm -f "$combined_config" | ||
} | ||
|
||
# Main logic | ||
if [[ -f "${META_DIR}/${PROFILES_DIR}/$1" ]]; then | ||
# Profile mode | ||
PROFILE_FILE="${META_DIR}/${PROFILES_DIR}/$1" | ||
shift | ||
CONFIGS=("${(@f)$(<"$PROFILE_FILE")}") | ||
for config in "${CONFIGS[@]}" "$@"; do | ||
run_dotbot "$config" | ||
done | ||
else | ||
# Standalone mode | ||
for config in "$@"; do | ||
run_dotbot "$config" | ||
done | ||
fi | ||
|
||
# vim: ft=zsh |