Files
dotfiles/deploy.sh
2024-10-05 19:14:59 -10:00

51 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
SCRIPT_DIR="$( cd "$( dirname "$BASH_SOURCE[0]" )" && pwd )"
symlinkFile() {
filename="$SCRIPT_DIR/$1"
destination="$HOME/$2/$1"
mkdir -p $(dirname "$destination")
if [ -L "$destination" ]; then
echo "[WARNING] $filename already symlinked"
return
fi
if [ -e "$destination" ]; then
echo "[ERROR] $destination exists but it's not a symlink. Please fix that manually"
exit 1
fi
ln -s "$filename" "$destination"
echo "[OK] $filename -> $destination"
}
deployManifest() {
for row in $(cat $SCRIPT_DIR/$1); do
if [[ "$row" =~ ^#.* ]]; then
continue
fi
filename=$(echo $row | cut -d \| -f 1)
operation=$(echo $row | cut -d \| -f 2)
destination=$(echo $row | cut -d \| -f 3)
case $operation in
symlink)
symlinkFile $filename $destination
;;
*)
echo "[WARNING] Unknown operation $operation. Skipping..."
;;
esac
done
}
echo "--- Common configs ---"
deployManifest MANIFEST
echo "--- Linux configs ---"
deployManifest MANIFEST.linux