mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
53 lines
778 B
Bash
Executable file
53 lines
778 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
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
CMD="rsync -aKv $RSYNC_OPTS www/ $PUBLISH_HOST:$PUBLISH_DIR"
|
|
else
|
|
CMD="rsync -aKv $RSYNC_OPTS $@ $PUBLISH_HOST:$PUBLISH_DIR"
|
|
fi
|
|
|
|
if [[ $ECHO -eq 1 ]]; then
|
|
echo "$CMD"
|
|
fi
|
|
|
|
$CMD
|