chore(setup): unify device profile detection and symlink logic via PROFILE env var
🤖 Generated with opencode.ai
Co-Authored-By: opencode <noreply@opencode.ai>
34 lines
1.0 KiB
Bash
Executable File
34 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Dotfiles setup script for Arch Linux using paru
|
|
set -e
|
|
|
|
#!/usr/bin/env bash
|
|
# Dotfiles setup script for Arch Linux using paru
|
|
set -e
|
|
|
|
# Device profile detection (unified via host-profiles.conf)
|
|
HOSTNAME=$(hostname)
|
|
PROFILE=""
|
|
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
if [ -f "$DOTFILES_DIR/host-profiles.conf" ]; then
|
|
PROFILE=$(awk -F= -v h="$HOSTNAME" '$1==h{print $2}' "$DOTFILES_DIR/host-profiles.conf")
|
|
fi
|
|
if [ -z "$PROFILE" ]; then
|
|
echo "ERROR: No profile mapping found for hostname '$HOSTNAME' in $DOTFILES_DIR/host-profiles.conf"
|
|
exit 1
|
|
fi
|
|
export PROFILE
|
|
echo "Using device profile: $PROFILE"
|
|
|
|
# Find, sort, and run all modules in the modules directory
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
MODULES=( $(find "$SCRIPT_DIR/modules" -maxdepth 1 -type f -name "*.sh" | sort) )
|
|
COUNT=${#MODULES[@]}
|
|
for i in "${!MODULES[@]}"; do
|
|
MODULE="${MODULES[$i]}"
|
|
STEP=$((i+1))
|
|
BASENAME=$(basename "$MODULE")
|
|
echo "[$STEP/$COUNT] Running $BASENAME..."
|
|
source "$MODULE"
|
|
done
|