Skip to content

Commit

Permalink
bin/deploy.sh: updated
Browse files Browse the repository at this point in the history
- Fix shellcheck warnings
- Add port switch to enable remote updates
- Add progress
  • Loading branch information
martinbosma committed Oct 24, 2023
1 parent 3051fba commit 9820642
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

if [ -z "$1" ]; then
echo "Host not set. Usage: $0 <host ip>"
exit -1
exit 1
fi

BUILD=false
MKPATH=false
PORT=22
POSITIONAL=()
while [[ $# -gt 0 ]]; do
key="$1"

case $key in
-u|--username)
USERNAME="$2"
Expand All @@ -25,6 +26,11 @@ while [[ $# -gt 0 ]]; do
MKPATH=true
shift # past argument
;;
-p|--port)
PORT="$2"
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
Expand All @@ -45,7 +51,7 @@ echo "Uploading dist/* to ${USERNAME}@${HOST}:/data/www/app/"

if $MKPATH; then
echo "mkdir -p /data/www/app/"
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${USERNAME}@${HOST} "mkdir -p /data/www/app/"
ssh -p "${PORT}" -oStrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null "${USERNAME}"@"${HOST}" "mkdir -p /data/www/app/"
fi

rsync --delete -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -r dist/* ${USERNAME}@${HOST}:/data/www/app/
rsync --delete --info=progress2 -e "ssh -p ${PORT} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" -r dist/* "${USERNAME}"@"${HOST}":/data/www/app/

0 comments on commit 9820642

Please sign in to comment.