Improve website upload script.

This commit is contained in:
Mike Pope 2019-12-24 18:55:09 +10:30
parent 8778bf4ebe
commit f1c4bb051a
1 changed files with 39 additions and 7 deletions

View File

@ -1,14 +1,46 @@
#! /bin/sh
# Upload what has changed in the web directory to the web site.
# Upload the website
#
# Default is to upload what changed recently, with -g from a specific commit.
# -a just uploads all of it.
#
set -xv
MODE=prev
while test "x$1" != "x" ; do
case "x$1" in
"x-a")
MODE=all
;;
"x-g")
shift
MODE="$1"
;;
*)
USERNAME="$1"
;;
esac
shift
done
if test "x$USERNAME" = "x" ; then
echo "set USERNAME" >&2
echo "usage: $0 [-a|-g <commit>] <USERNAME>" >&2
exit 1
fi
WEBDIR=www.freecol.org
PREV=`git log --pretty=oneline "$WEBDIR" | sed -n -e '2s/^\([^ ]*\).*$/\1/p'`
{
echo "cd /home/project-web/freecol/htdocs"
git diff --name-only "$PREV" HEAD -- "$WEBDIR" | sed -e 's|^[^/]*/\(.*\)$|put \1 \1|p'
} | (cd "$WEBDIR" ; sftp $USERNAME,freecol@web.sf.net)
if test "x$MODE" = "xall" ; then
{
echo "cd /home/project-web/freecol/htdocs"
find www.freecol.org -type f -print \
| sed -e 's|^www.freecol.org/\(.*\)$|put \1 \1|'
} | (cd "$WEBDIR" ; sftp $USERNAME,freecol@web.sf.net)
else
if test "x$MODE" = "xprev" ; then
PREV=`git log --pretty=oneline "$WEBDIR" | sed -n -e '2s/^\([^ ]*\).*$/\1/p'`
else
PREV="$MODE"
fi
{
echo "cd /home/project-web/freecol/htdocs"
git diff --name-only "$PREV" HEAD -- "$WEBDIR" | sed -e 's|^[^/]*/\(.*\)$|put \1 \1|p'
} | (cd "$WEBDIR" ; sftp $USERNAME,freecol@web.sf.net)
fi