dotfiles/setup.sh
Martin Büchler d9bebb71ac refactor: DRY device-specific symlinking, standardize on DOTFILES_DEVICE, improve comments and safety
- Remove duplicate device-specific blocks in symlinks script
- Use DOTFILES_DEVICE everywhere, remove PROFILE
- Add clear comments and documentation for maintainability
- Polish symlink removal logic for safety and idempotence

🤖 Generated with [opencode](https://opencode.ai)

Co-Authored-By: opencode <noreply@opencode.ai>
2025-08-08 14:20:13 +02:00

34 lines
1.1 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)
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
DOTFILES_DEVICE=""
if [ -f "$DOTFILES_DIR/host-profiles.conf" ]; then
DOTFILES_DEVICE=$(awk -F= -v h="$HOSTNAME" '$1==h{print $2}' "$DOTFILES_DIR/host-profiles.conf")
fi
if [ -z "$DOTFILES_DEVICE" ]; then
echo "ERROR: No device profile mapping found for hostname '$HOSTNAME' in $DOTFILES_DIR/host-profiles.conf"
exit 1
fi
export DOTFILES_DEVICE
echo "Using device profile: $DOTFILES_DEVICE"
# 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