samhuri.net/bin/publish

54 lines
829 B
Bash
Executable file

#!/bin/bash
# exit on errors
set -e
PUBLISH_HOST="samhuri.net"
PUBLISH_DIR="samhuri.net/public"
ECHO=0
RSYNC_OPTS=""
BREAK_WHILE=0
while [[ $# > 0 ]]; do
ARG="$1"
case "$ARG" in
-b|--beta)
PUBLISH_DIR="beta.samhuri.net"
shift
;;
-t|--test)
ECHO=1
RSYNC_OPTS="$RSYNC_OPTS --dry-run"
shift
;;
-d|--delete)
RSYNC_OPTS="$RSYNC_OPTS --delete"
shift
;;
# we're at the paths, no more options
*)
BREAK_WHILE=1
break
;;
esac
[[ $BREAK_WHILE -eq 1 ]] && break
done
declare -a CMD
if [[ $# -eq 0 ]]; then
CMD=(rsync -aKv -e "ssh -4" $RSYNC_OPTS www/ $PUBLISH_HOST:$PUBLISH_DIR)
else
CMD=(rsync -aKv -e "ssh -4" $RSYNC_OPTS $@ $PUBLISH_HOST:$PUBLISH_DIR)
fi
if [[ $ECHO -eq 1 ]]; then
echo "${CMD[@]}"
fi
"${CMD[@]}"