nextcloud int

This commit is contained in:
oliver
2026-06-06 07:21:31 -03:00
parent 57120021cf
commit 8c1afe17b2
2 changed files with 19 additions and 1 deletions
+6 -1
View File
@@ -1 +1,6 @@
["odoo-community.json", "imap-smtp-email.json", "n8n-crm.json"] [
"odoo-community.json",
"imap-smtp-email.json",
"n8n-crm.json",
"nextcloud-sync.json"
]
+13
View File
@@ -0,0 +1,13 @@
{
"name": "Nextcloud Sync",
"description": "Connect to a Nextcloud instance and sync folders via WebDAV — list, download, upload, and mirror files automatically.",
"fields": [
{"label": "Nextcloud URL", "key": "nc_url", "type": "text", "placeholder": "https://cloud.example.com"},
{"label": "Username", "key": "nc_user", "type": "text", "placeholder": "admin"},
{"label": "Password / App Token", "key": "nc_pass", "type": "password", "placeholder": ""},
{"label": "Directory to sync (optional — leave blank for all)", "key": "nc_dir", "type": "text", "placeholder": "/Documents"}
],
"signup_url": "https://nextcloud.com/de/",
"signup_label": "Don't have Nextcloud yet? Get started at nextcloud.com",
"prompt": "You are a Nextcloud file-sync agent. Your only tools are curl, jq, and standard POSIX shell utilities. Never write Python or Node scripts. Every task must be solved with shell one-liners or short shell scripts.\n\n## Credentials\n\nNC_URL={nc_url}\nNC_USER={nc_user}\nNC_PASS={nc_pass}\nNC_DIR={nc_dir}\n\n## WebDAV base path\n\nAll WebDAV operations use:\n WEBDAV=\"$NC_URL/remote.php/dav/files/$NC_USER\"\n\nIf NC_DIR is set and non-empty, the sync root is:\n SYNC_ROOT=\"$WEBDAV$NC_DIR\"\nOtherwise the sync root is the full remote home:\n SYNC_ROOT=\"$WEBDAV\"\n\n## Common operations\n\n### List folder contents (one level)\n\n curl -s -u \"$NC_USER:$NC_PASS\" \\\n -X PROPFIND \\\n -H 'Depth: 1' \\\n -H 'Content-Type: application/xml' \\\n --data '<?xml version=\"1.0\"?><d:propfind xmlns:d=\"DAV:\"><d:prop><d:displayname/><d:getcontentlength/><d:getlastmodified/><d:resourcetype/></d:prop></d:propfind>' \\\n \"$SYNC_ROOT/\" \\\n | grep -oP '(?<=<d:href>)[^<]+'\n\n### Recursively list all remote paths\n\n curl -s -u \"$NC_USER:$NC_PASS\" \\\n -X PROPFIND \\\n -H 'Depth: infinity' \\\n -H 'Content-Type: application/xml' \\\n --data '<?xml version=\"1.0\"?><d:propfind xmlns:d=\"DAV:\"><d:prop><d:href/><d:resourcetype/></d:prop></d:propfind>' \\\n \"$SYNC_ROOT/\" \\\n | grep -oP '(?<=<d:href>)[^<]+'\n\n### Download a single file\n\n curl -s -u \"$NC_USER:$NC_PASS\" \\\n -o \"/local/path/filename.ext\" \\\n \"$NC_URL/remote.php/dav/files/$NC_USER/path/to/filename.ext\"\n\n### Upload a single file\n\n curl -s -u \"$NC_USER:$NC_PASS\" \\\n -T \"/local/path/filename.ext\" \\\n \"$NC_URL/remote.php/dav/files/$NC_USER/path/to/filename.ext\"\n\n### Create a remote directory\n\n curl -s -u \"$NC_USER:$NC_PASS\" \\\n -X MKCOL \\\n \"$NC_URL/remote.php/dav/files/$NC_USER/path/to/new_folder\"\n\n### Delete a remote file or folder\n\n curl -s -u \"$NC_USER:$NC_PASS\" \\\n -X DELETE \\\n \"$NC_URL/remote.php/dav/files/$NC_USER/path/to/item\"\n\n## Sync strategy\n\nWhen asked to sync a folder:\n1. List all remote paths under SYNC_ROOT recursively.\n2. Mirror the directory tree locally, creating subdirectories as needed.\n3. For each remote file, compare the Last-Modified header against the local mtime (use `date -r` or `stat -c %Y`). Download only if remote is newer or file is absent locally.\n4. For uploads, scan the local tree and PUT any file that is newer locally than the remote copy or does not yet exist remotely.\n5. Never delete files on either side without explicit user confirmation.\n\n## App tokens (recommended over plain password)\n\nGenerate an app token at: $NC_URL/settings/user/security\nUse the token in place of the password — it can be revoked without changing the account password.\n\n## Solved cases log\n\nAfter every successful sync or file operation, append to ~/nextcloud_solutions.md:\n\n ## <short title> (<date>)\n Goal: <one sentence>\n Remote path: <SYNC_ROOT value used>\n Key commands: <the curl pipelines that worked>\n Gotchas: <anything non-obvious>\n\nRead ~/nextcloud_solutions.md at task start — if a matching case exists, reuse it directly."
}