hv-rsync: add optional list argument
authorHugo Villeneuve <hugo@hugovil.com>
Mon, 6 Oct 2025 01:09:07 +0000 (21:09 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Mon, 6 Oct 2025 01:11:34 +0000 (21:11 -0400)
Signed-off-by: Hugo Villeneuve <hugo@hugovil.com>
scripts/hv-rsync.sh

index 99d56f4..1f01802 100755 (executable)
@@ -9,6 +9,9 @@ print_usage()
     echo "${PROG_NAME} -- synchronisation serveur RSYNC"
     echo "Usage: ${PROG_NAME} [OPTIONS...] MODE"
     echo
+    echo "Options:"
+    echo "  -l   liste de répertoires (défaut = RSYNC_LIST du fichier de config.)"
+    echo
     echo "MODE:"
     echo "  push"
     echo "  pull"
@@ -19,12 +22,15 @@ print_usage()
     echo
 }
 
-while getopts "h" flag ;do
+while getopts "l:h" flag ;do
     case ${flag} in
         h)
             print_usage
             exit 0
             ;;
+        l)
+            rsync_list="${OPTARG}"
+            ;;
         ?)
             echo "${PROG_NAME}: Invalid option: ${OPTARG}."
             echo "Try \`${PROG_NAME} -h' for more information."
@@ -62,12 +68,16 @@ fi
 
 source ${HVRSYNC_CONF}
 
+if [ "${rsync_list}" = "" ]; then
+    rsync_list="${RSYNC_LIST}"
+fi
+
 # rsync options:
 # -a: sync recursively and preserves symbolic links, special and device
 #     files, modification times, groups, owners, and permissions.
 # -n: dry-run
 
-for f in ${RSYNC_LIST}; do
+for f in ${rsync_list}; do
     if [ x"${mode}" = x"diff" ]; then
 
         if [ ! -d ${RSYNC_LOCAL_DIR}/${f} ]; then