add test mode to publish

This commit is contained in:
Sami Samhuri 2010-11-08 20:28:01 -08:00
parent e6833ab0ea
commit 067eeebafb

24
publish
View file

@ -5,21 +5,29 @@ bail() {
exit 1 exit 1
} }
# test
if [[ "$1" = "-t" ]]; then
prefix=echo
shift
fi
[[ "$PUBLISH_HOST" != "" ]] && [[ "$publish_host" = "" ]] && publish_host="$PUBLISH_HOST" [[ "$PUBLISH_HOST" != "" ]] && [[ "$publish_host" = "" ]] && publish_host="$PUBLISH_HOST"
[[ "$PUBLISH_DIR" != "" ]] && [[ "$publish_dir" = "" ]] && publish_dir="$PUBLISH_DIR" [[ "$PUBLISH_DIR" != "" ]] && [[ "$publish_dir" = "" ]] && publish_dir="$PUBLISH_DIR"
orig_pwd="$PWD" orig_pwd="$PWD"
while ! [[ -f .publish ]]; do if [[ ! -f .publish ]]; then
[[ "$PWD" = "/" ]] && bail "no .publish file found" while ! [[ -f .publish ]]; do
cd .. [[ "$PWD" = "/" ]] && bail "no .publish file found"
done cd ..
subdir="${PWD#$orig_pwd}" done
subdir="${orig_pwd#$PWD/}"
fi
source .publish source .publish
cd "$orig_pwd"
cd $orig_pwd
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
scp -r * "$publish_host":"${publish_dir}${subdir}" $prefix scp -r * "$publish_host":"${publish_dir}${subdir}"
else else
scp "$@" "$publish_host":"${publish_dir}${subdir}" $prefix scp -r "$@" "$publish_host":"${publish_dir}${subdir}"
fi fi