From ef7c1605a027b52bbff1b01ea693b60f53fa3a71 Mon Sep 17 00:00:00 2001 From: yuzu-eva Date: Thu, 8 May 2025 14:01:37 +0200 Subject: initial commit --- deploy.sh | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 deploy.sh (limited to 'deploy.sh') diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..17fc4ad --- /dev/null +++ b/deploy.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +set -e + +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 +} + +# Only useful if you want to have multiple MANIFESTS, +# otherwise just hardcode it +# +#if [ -z "$@" ]; then +# echo "Usage: $0" +# echo "ERROR: no MANIFEST file is provided" +# exit 1 +#fi + +deployManifest "./MANIFEST" + -- cgit v1.2.3