]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Add helper script for updating samba files.
authorWayne Davison <wayne@opencoder.net>
Tue, 5 Nov 2024 20:42:42 +0000 (12:42 -0800)
committerWayne Davison <wayne@opencoder.net>
Tue, 5 Nov 2024 20:42:42 +0000 (12:42 -0800)
Makefile.in
packaging/samba-rsync [new file with mode: 0755]

index d5fefe0456b25b2563247cf393263feebb9bc50c..7c75c26176df53745a5c23b212bbc43761e44d28 100644 (file)
@@ -358,4 +358,4 @@ doxygen:
 .PHONY: doxygen-upload
 doxygen-upload:
        rsync -avzv $(srcdir)/dox/html/ --delete \
-       $${SAMBA_HOST-samba.org}:/home/httpd/html/rsync/doxygen/head/
+       $${RSYNC_SAMBA_HOST-samba.org}:/home/httpd/html/rsync/doxygen/head/
diff --git a/packaging/samba-rsync b/packaging/samba-rsync
new file mode 100755 (executable)
index 0000000..c36bf41
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/sh
+# This script makes it easy to update the ftp & html directories on the samba.org server.
+# It expects the 2 *_DEST directories to contain updated files that need to be sent to
+# the remote server. If these directories don't exist yet, they will be copied from the
+# remote server (while also making the html dir a git checkout).
+
+FTP_SRC="$HOME/samba-rsync-ftp"
+HTML_SRC="$HOME/samba-rsync-html"
+
+FTP_DEST="/home/ftp/pub/rsync"
+HTML_DEST="/home/httpd/html/rsync"
+
+HTML_GIT='git.samba.org:/data/git/rsync-web.git'
+
+export RSYNC_PARTIAL_DIR=''
+
+case "$RSYNC_SAMBA_HOST" in
+    *.samba.org) ;;
+    *)
+       echo "You must set RSYNC_SAMBA_HOST in your environment to the samba hostname to use." >&2
+       exit 1
+       ;;
+esac
+
+case "$1" in
+    f|-f|ftp|--ftp) MODE=ftp ;;
+    h|-h|html|--html) MODE=html ;;
+    '')
+       echo -n "Update ftp or html? "
+       read ans
+       case "$ans" in
+           f*) MODE=ftp ;;
+           h*) MODE=html ;;
+           *)
+               echo "Invalid answer." >&2
+               exit 1
+               ;;
+       esac
+       ;;
+    *)
+       echo "Invalid option: $1" >&2
+       exit 1
+       ;;
+esac
+
+if [ "$MODE" = ftp ]; then
+    SRC_DIR="$FTP_SRC"
+    DEST_DIR="$FTP_DEST"
+    FILT=".filt"
+else
+    SRC_DIR="$HTML_SRC"
+    DEST_DIR="$HTML_DEST"
+    FILT="filt"
+fi
+
+if [ ! -d "$SRC_DIR" ]; then
+    echo "The directory $SRC_DIR does not exist yet."
+    echo -n "Do you want to create it? [n] "
+    read ans
+    case "$ans" in
+       y*) ;;
+       *) exit 1 ;;
+    esac
+    OPTS='-aiv'
+    TMP_FILT="$SRC_DIR/tmp-filt"
+    if [ "$MODE" = html ]; then
+       git clone "$HTML_GIT" "$SRC_DIR"
+       sed -n -e 's/[-P]/H/p' "$SRC_DIR/$FILT" >"$TMP_FILT"
+       OPTS="${OPTS}f._$TMP_FILT"
+    fi
+    rsync "$OPTS" "$RSYNC_SAMBA_HOST:$DEST_DIR/" "$SRC_DIR/"
+    rm -f "$TMP_FILT"
+    exit
+fi
+
+cd "$SRC_DIR" || exit 1
+set -- -aivOHP --del -f._$FILT . "$RSYNC_SAMBA_HOST:$DEST_DIR/"
+
+rsync --dry-run "${@}" | grep -v 'is uptodate$'
+echo ''
+echo -n "Run without --dry-run? [n] "
+read ans
+case "$ans" in
+    y*) rsync "${@}" | grep -v 'is uptodate$' ;;
+esac