diff options
-rw-r--r-- | bin/ncp/CONFIG/nc-scan-auto.sh | 36 | ||||
-rw-r--r-- | etc/ncp-config.d/nc-scan-auto.cfg | 20 |
2 files changed, 45 insertions, 11 deletions
diff --git a/bin/ncp/CONFIG/nc-scan-auto.sh b/bin/ncp/CONFIG/nc-scan-auto.sh index dbb97eba..bbffb1a5 100644 --- a/bin/ncp/CONFIG/nc-scan-auto.sh +++ b/bin/ncp/CONFIG/nc-scan-auto.sh @@ -20,19 +20,35 @@ configure() } # set crontab - local DAYS HOURS MINS - DAYS=$(( SCANINTERVAL / 1440 )) - if [[ "$DAYS" != "0" ]]; then - DAYS="*/$DAYS" HOUR="1" MINS="15" + local days hour mins + days=$(( SCANINTERVAL / 1440 )) + if [[ "$days" != "0" ]]; then + days="*/$days" hour="1" mins="15" else - DAYS="*" - HOUR=$(( SCANINTERVAL / 60 )) - MINS=$(( SCANINTERVAL % 60 )) - MINS="*/$MINS" - [[ $HOUR == 0 ]] && HOUR="*" || { HOUR="*/$HOUR" MINS="15"; } + days="*" + hour=$(( SCANINTERVAL / 60 )) + mins=$(( SCANINTERVAL % 60 )) + mins="*/$mins" + [[ $hour == 0 ]] && hour="*" || { hour="*/$hour" mins="15"; } fi - echo "${MINS} ${HOUR} ${DAYS} * * root /usr/local/bin/ncp-scan" > /etc/cron.d/ncp-scan-auto + cat > /usr/local/bin/ncp-scan-auto <<EOF +#!/bin/bash +( + + echo -e "\n[ nc-scan-auto ]" + + [[ "$PATH1" != "" ]] && ncc files:scan -n -v -p "$PATH1" + [[ "$PATH2" != "" ]] && ncc files:scan -n -v -p "$PATH2" + [[ "$PATH3" != "" ]] && ncc files:scan -n -v -p "$PATH3" + + [[ "${PATH1}${PATH2}${PATH3}" == "" ]] && ncc files:scan -n -v --all + +) 2>&1 >>/var/log/ncp.log +EOF +chmod +x /usr/local/bin/ncp-scan-auto + + echo "${mins} ${hour} ${days} * * root /usr/local/bin/ncp-scan-auto" > /etc/cron.d/ncp-scan-auto chmod 644 /etc/cron.d/ncp-scan-auto service cron restart diff --git a/etc/ncp-config.d/nc-scan-auto.cfg b/etc/ncp-config.d/nc-scan-auto.cfg index a11ed9e8..ed5efd2e 100644 --- a/etc/ncp-config.d/nc-scan-auto.cfg +++ b/etc/ncp-config.d/nc-scan-auto.cfg @@ -3,7 +3,7 @@ "name": "Nc-scan-auto", "title": "nc-scan-auto", "description": "Periodically scan NC for externally modified files", - "info": "Set the time in minutes in Scan Interval.\n\n>>> If there are too many files this can greatly affect performance. <<<", + "info": "Set the time in minutes in Scan Interval. Optionally we can specify up to 3 paths in the form '_user_/files/_path_'\n\n>>> If there are too many files this can greatly affect performance. <<<", "infotitle": "Instructions for auto synchronization", "params": [ { @@ -17,6 +17,24 @@ "name": "Scan Interval", "value": "60", "suggest": "60" + }, + { + "id": "PATH1", + "name": "Path", + "value": "", + "suggest": "/ncp/files/Documents" + }, + { + "id": "PATH2", + "name": "Path", + "value": "", + "suggest": "/family/files/Photos" + }, + { + "id": "PATH3", + "name": "Path", + "value": "", + "suggest": "/family/files/Videos" } ] } |