summaryrefslogtreecommitdiff
path: root/deploy.sh
diff options
context:
space:
mode:
authorJake Koroman <jake@jakekoroman.com>2025-11-08 00:55:49 -0500
committerJake Koroman <jake@jakekoroman.com>2025-11-08 00:55:49 -0500
commitb68898fa65f064e6befd0cb23067287df65de12b (patch)
tree8ea7b82dd34f693dd2aea5d228cc8518cc77f532 /deploy.sh
parenta00b35a806be0b6c8d963d93a45a502a2b3d7e78 (diff)
update deploy script
Diffstat (limited to 'deploy.sh')
-rwxr-xr-xdeploy.sh47
1 files changed, 26 insertions, 21 deletions
diff --git a/deploy.sh b/deploy.sh
index 75c1b48..43f4a80 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -3,42 +3,47 @@
# forked from: https://github.com/rexim/dotfiles/blob/master/deploy.sh
SCRIPT_DIR="$( cd "$( dirname "$BASH_SOURCE[0]" )" && pwd )"
+MANIFEST_FILE="MANIFEST"
symlink_file() {
filename="$SCRIPT_DIR/$1"
- destination="$HOME/$2/$1"
+ destination=$(echo "$HOME/$2/$1" | sed 's/\/\//\//g')
mkdir -p $(dirname "$destination")
- if [ ! -L "$destination" ]; then
+ if [ -L "$destination" ]; then
+ echo "info: updating $filename symlink"
+ rm -f "$destination" > /dev/null
+ ln -s "$filename" "$destination"
+ else
if [ -e "$destination" ]; then
- echo "[ERROR] $destination exists but it's not a symlink. Please fix that manually" && exit 1
+ echo "error: $destination exists but it's not a symlink. Please fix that manually" && return
else
ln -s "$filename" "$destination"
- echo "[OK] $filename -> $destination"
+ echo "info: $filename -> $destination"
fi
- else
- echo "[WARNING] $filename already symlinked"
fi
}
deploy_manifest() {
- for row in $(cat $SCRIPT_DIR/$1); do
+ echo "--- deploying ---"
+ for row in $(cat "$SCRIPT_DIR/$MANIFEST_FILE"); do
+ filename=$(echo $row | cut -d \| -f 1)
+ destination=$(echo $row | cut -d \| -f 2)
+ symlink_file $filename $destination
+ done
+}
+
+clean() {
+ echo "--- cleaning up ---"
+ for row in $(cat "$SCRIPT_DIR/$MANIFEST_FILE"); do
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)
- symlink_file $filename $destination
- ;;
-
- *)
- echo "[WARNING] Unknown operation $operation. Skipping..."
- ;;
- esac
+ destination=$(echo $row | cut -d \| -f 2)
+ result=$(echo "$HOME/$destination/$filename" | sed 's/\/\//\//g')
+ rm -f "$result" > /dev/null
+ echo "info: removed $result symlink"
done
}
-echo "--- Configs ---"
-deploy_manifest MANIFEST
+[ "$1" = "clean" ] && clean && exit
+deploy_manifest