From 5d2b56b0151a503321c47de3eddd4a24bc4579b0 Mon Sep 17 00:00:00 2001 From: Aleksander Wasaznik Date: Sun, 5 Feb 2017 15:42:47 +0100 Subject: [PATCH] Improve deploy script The script now handles filenames with spaces and such. It also removes any old files from previous deployment. --- deploy.bash | 24 ++++++++++++++++++++++++ deploy.sh | 7 ------- 2 files changed, 24 insertions(+), 7 deletions(-) create mode 100755 deploy.bash delete mode 100755 deploy.sh diff --git a/deploy.bash b/deploy.bash new file mode 100755 index 0000000..ec36215 --- /dev/null +++ b/deploy.bash @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +# My little crappy deploy script +# Uploads all files not ignored by git + +TARGET=brzeczyszczykiewicz.pvv.ntnu.no +TARGET_PATH='grzegorz' + +array=(); while IFS= read -rd '' item; do array+=("$item"); done < \ + <(git status -z --short | grep -z ^? | cut -z -d\ -f2-; git ls-files -z) +files_not_ignored=("${array[@]}") + +ssh -T "grzegorz@$TARGET" " + rm -rf $TARGET_PATH + mkdir -p $TARGET_PATH + " + +tar -c "${files_not_ignored[@]}" | + ssh -T "grzegorz@$TARGET" " + tar -vxC $TARGET_PATH + " +ssh -T "root@$TARGET" " + systemctl restart grzegorz + systemctl status grzegorz + " diff --git a/deploy.sh b/deploy.sh deleted file mode 100755 index 3d8de6d..0000000 --- a/deploy.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -# My little crappy deploy script -# It will upload all files not ignored by git - -files_not_ignored="$(git status --short | grep ^? | cut -d\ -f2- ; git ls-files)" -tar -c $files_not_ignored | ssh grzegorz@brzeczyszczykiewicz.pvv.ntnu.no tar -xC ~grzegorz/grzegorz -ssh root@brzeczyszczykiewicz.pvv.ntnu.no "systemctl restart grzegorz"