bin/publish
2010-11-23 20:22:36 -08:00

33 lines
681 B
Bash
Executable file

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