2 # This script makes it easy to update the ftp & html directories on the samba.org server.
3 # It expects the 2 *_DEST directories to contain updated files that need to be sent to
4 # the remote server. If these directories don't exist yet, they will be copied from the
5 # remote server (while also making the html dir a git checkout).
7 FTP_SRC
="$HOME/samba-rsync-ftp"
8 HTML_SRC
="$HOME/samba-rsync-html"
10 FTP_DEST
="/home/ftp/pub/rsync"
11 HTML_DEST
="/home/httpd/html/rsync"
13 HTML_GIT
='git.samba.org:/data/git/rsync-web.git'
15 export RSYNC_PARTIAL_DIR
=''
17 case "$RSYNC_SAMBA_HOST" in
20 echo "You must set RSYNC_SAMBA_HOST in your environment to the samba hostname to use." >&2
29 -R|
--reverse) REVERSE
=yes ;;
33 echo "Usage: [-R] [f|ftp|h|html]"
34 echo "-R --reverse Copy the files from the server to the local host."
35 echo " The default is to update the remote files."
36 echo "-h --help Output this help message."
38 echo "The script will prompt if ftp or html is not specified on the command line."
39 echo "Only one category can be copied at a time. When pulling html files, a git"
40 echo "checkout will be either created or updated prior to the rsync copy."
44 echo "Invalid option: $1" >&2
51 while [ ! "$MODE" ]; do
52 if [ "$REVERSE" = yes ]; then
57 echo -n "Copy which files $DIRECTION the server? ftp or html? "
63 *) echo "You must answer f or h to copy the ftp or html data." ;;
67 if [ "$MODE" = ftp ]; then
78 rsync
--dry-run "${@}" |
grep -v 'is uptodate$'
80 echo -n "Run without --dry-run? [n] "
83 y
*) rsync
"${@}" |
grep -v 'is uptodate$' ;;
87 if [ -d "$SRC_DIR" ]; then
88 REVERSE_RSYNC
=do_rsync
90 echo "The directory $SRC_DIR does not exist yet."
91 echo -n "Do you want to create it? [n] "
101 if [ "$REVERSE" = yes ]; then
103 TMP_FILT
="$SRC_DIR/tmp-filt"
104 echo "Copying files from $RSYNC_SAMBA_HOST to $SRC_DIR ..."
105 if [ "$MODE" = html
]; then
106 if [ $REVERSE_RSYNC = rsync
]; then
107 git clone
"$HTML_GIT" "$SRC_DIR" ||
exit 1
109 cd "$SRC_DIR" ||
exit 1
112 sed -n -e 's/[-P]/H/p' "$SRC_DIR/$FILT" >"$TMP_FILT"
113 OPTS
="${OPTS}f._$TMP_FILT"
115 OPTS
="${OPTS}f:_$FILT"
117 $REVERSE_RSYNC "$OPTS" "$RSYNC_SAMBA_HOST:$DEST_DIR/" "$SRC_DIR/"
122 cd "$SRC_DIR" ||
exit 1
123 echo "Copying files from $SRC_DIR to $RSYNC_SAMBA_HOST ..."
124 do_rsync
-aivOHP --del -f._
$FILT .
"$RSYNC_SAMBA_HOST:$DEST_DIR/"