deploy.sh (974B)
1 #!/bin/sh 2 3 # forked from: https://github.com/rexim/dotfiles/blob/master/deploy.sh 4 5 SCRIPT_DIR="$( cd "$( dirname "$BASH_SOURCE[0]" )" && pwd )" 6 7 symlink_file() { 8 filename="$SCRIPT_DIR/$1" 9 destination="$HOME/$2/$1" 10 11 mkdir -p $(dirname "$destination") 12 13 if [ ! -L "$destination" ]; then 14 if [ -e "$destination" ]; then 15 echo "[ERROR] $destination exists but it's not a symlink. Please fix that manually" && exit 1 16 else 17 ln -s "$filename" "$destination" 18 echo "[OK] $filename -> $destination" 19 fi 20 else 21 echo "[WARNING] $filename already symlinked" 22 fi 23 } 24 25 deploy_manifest() { 26 for row in $(cat $SCRIPT_DIR/$1); do 27 filename=$(echo $row | cut -d \| -f 1) 28 operation=$(echo $row | cut -d \| -f 2) 29 destination=$(echo $row | cut -d \| -f 3) 30 31 case $operation in 32 symlink) 33 symlink_file $filename $destination 34 ;; 35 36 *) 37 echo "[WARNING] Unknown operation $operation. Skipping..." 38 ;; 39 esac 40 done 41 } 42 43 echo "--- Configs ---" 44 deploy_manifest MANIFEST