nextcloud: Fix subfolder sync
authorStefan Huber <shuber@sthu.org>
Wed, 9 Feb 2022 12:25:07 +0000 (13:25 +0100)
committerStefan Huber <shuber@sthu.org>
Wed, 9 Feb 2022 12:25:07 +0000 (13:25 +0100)
Newer nextcloudcmd only allows passing base url as server. Subfolders
have to be passed via a --path argument.

nextcloud/nextcloud-inotify-sync
nextcloud/nextcloud-vimwiki-sync.service

index e310352443ef34996c8b20bc61b0bf961c1fe2e9..d1249048cbb35390f375ad00c7a8f304967608b4 100755 (executable)
@@ -21,7 +21,7 @@ after some period, whatever happens first. The nextcloudcmd is called with
 netrc for login.
 
 Usage:
- $0 [OPTIONS] source_dir server_url
+ $0 [OPTIONS] source_dir server_url [ARGS...]
  $0 -h
 
 OPTIONS:
@@ -30,9 +30,10 @@ OPTIONS:
   -s        Silent, be less verbose
   -t SECS   Sync period if nothing changed locally.
             Default: 180
+  ARGS      Passed to nextcloudcmd
 
 EXAMPLE
-    $0 ~/.vimwiki https://cloud.example.com/remote.php/webdav/vimwiki
+    $0 ~/.vimwiki https://cloud.example.com --path vimwiki
 EOF
 }
 
@@ -41,7 +42,7 @@ IWAIT_OPTS=""
 
 SILENT=0
 ONESHOT=0
-PERIOD=180
+PERIOD=600
 
 while getopts "host:" OPTION; do
        case "${OPTION}" in
@@ -70,6 +71,8 @@ shift $((OPTIND-1))
 
 SOURCE_DIR=$1
 SERVER_URL=$2
+shift
+shift
 
 if [ -z "${SOURCE_DIR}" ] ; then
        echo "No source directory given."
@@ -83,7 +86,7 @@ if [ -z "${SERVER_URL}" ] ; then
        exit 1
 fi
 
-NCC_OPTS="${NCC_OPTS} ${SOURCE_DIR} ${SERVER_URL}"
+NCC_OPTS="${NCC_OPTS} $@ ${SOURCE_DIR} ${SERVER_URL}"
 
 while true; do
        echo "About to sync..."
index 8233141bebdb715d6df8fff26c7bd2bd1dc18e05..d20b2b822617e9deb150310debd2fd3aa9f3708a 100644 (file)
@@ -4,7 +4,7 @@ Wants=network-online.target
 After=network-online.target
 
 [Service]
-ExecStart=%h/.local/bin/nextcloud-inotify-sync %h/.vimwiki "https://cloud.example.org/remote.php/webdav/vimwiki"
+ExecStart=%h/.local/bin/nextcloud-inotify-sync %h/.vimwiki "https://cloud.example.com" --path vimwiki
 Restart=always
 RestartSec=10min