add support for publishing to beta.samhuri.net

This commit is contained in:
Sami Samhuri 2014-02-16 23:23:56 -08:00
parent be2b7af74a
commit c83c639b98
2 changed files with 32 additions and 22 deletions

View file

@ -6,6 +6,10 @@ compile:
publish: compile publish: compile
@echo @echo
./bin/publish.sh --delete www/ ./bin/publish.sh --delete
.PHONY: compile publish publish_beta: compile
@echo
./bin/publish.sh --beta --delete
.PHONY: compile publish publish_beta

View file

@ -8,47 +8,53 @@ bail() {
exit 1 exit 1
} }
publish_host="samhuri.net" PUBLISH_HOST="samhuri.net"
publish_dir="samhuri.net/public/" PUBLISH_DIR="samhuri.net/public"
prefix="" ECHO=0
delete="" RSYNC_OPTS=""
RSYNC_DELETE=0
break_while=0 BREAK_WHILE=0
while [[ $# > 1 ]]; do while [[ $# > 1 ]]; do
ARG="$1"
case "$ARG" in
arg="$1" -b|--beta)
PUBLISH_DIR="beta.samhuri.net"
case "$arg" in shift
;;
-t|--test) -t|--test)
prefix=echo ECHO=1
dryrun="--dry-run" RSYNC_OPTS="$RSYNC_OPTS --dry-run"
shift shift
;; ;;
-d|--delete) -d|--delete)
# passed to rsync RSYNC_DELETE=1
delete="--delete" RSYNC_OPTS="$RSYNC_OPTS --delete"
shift shift
;; ;;
# we're at the paths, no more options # we're at the paths, no more options
*) *)
break_while=1 BREAK_WHILE=1
break break
;; ;;
esac esac
[[ $break_while -eq 1 ]] && break [[ $BREAK_WHILE -eq 1 ]] && break
done done
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
if [[ "$delete" != "" ]]; then CMD=rsync -aKv $RSYNC_OPTS www/ "$PUBLISH_HOST":"$PUBLISH_DIR"
bail "no paths given, cowardly refusing to publish everything with --delete"
fi
$prefix rsync -aKv $dryrun $delete www/* "$publish_host":"${publish_dir}"
else else
$prefix rsync -aKv $dryrun $delete "$@" "$publish_host":"${publish_dir}" CMD="rsync -aKv $RSYNC_OPTS $@ $PUBLISH_HOST:$PUBLISH_DIR"
fi fi
if [[ $ECHO -eq 1 ]]; then
echo "$CMD"
fi
$CMD