nextcloud / workflow_script

Rule based processing of files through specified external scripts
https://apps.nextcloud.com/apps/workflow_script
GNU Affero General Public License v3.0
72 stars 19 forks source link

Run_script never triggered on file change or other trigger #90

Open MacLemon opened 3 years ago

MacLemon commented 3 years ago

Steps to reproduce

  1. Create any shell script you want to trigger with this workflow. eg.

    #!/bin/sh
    printenv >> /tmp/nextcloud_script_trigger

    Save it in a location where nextcloud can access it and make it executable.

  2. As nextcloud admin create a new run_script workflow that triggers on pretty much any event.

Nextcloud-run_script-trigger

  1. Save the workflow.
  2. Create a file named foo.txt.
  3. Change the contents of the file by editing via nextcloud webinterface.
  4. Change the contents of the file by locally editing the file via sync-client.
  5. Assign a tag to foo.txt
  6. touch the file on a synched client.
  7. Delete foo.txt via Webinterface or sync-client

Test with different regular expressions, make sure to only use lower-case ASCII characters in filenames so we can be sure that nextcloud doesn't trip over any “special characters”.

Expected behaviour

Upon change of a file named foo.txt the run_script flow should be triggered and successfully executed.

Actual behaviour

Nothing.

Workflow Script app

Workflow Script app version: (see apps admin page: /index.php/settings/apps) Multiple Nextcloud 20.0.9.1: Workflow external scripts: 1.5.1 Nextcloud 21.0.1: Workflow external scripts: 1.5.0

To be honest, we never go this to work at all since run_script was introduced. So this is not a recent regression from our point of view, it never worked.

Server configuration

Operating system: FreeBSD 12.2-RELEASE-p6 Debian 10 (Buster)

Web server: Apache/Nginx nginx 1.20.0 nginx 1.19.x nginx 1.18.x nginx 1.14.2

Database: MySQL/Maria/SQLite/PostgreSQL MySQL 5.7.33 Postgres 13.2 MariaDB 10.3.27

PHP version: PHP 7.4.18 PHP 7.4.16 PHP 7.3.27-1~deb10u1 PHP 7.3.x PHP 7.2.x

Nextcloud Version: (see admin page) Versions prior to Nextcloud 17 not relevant anymore, but didn't work there as well. 18.x.y 19.x.y 20.0.3-20.0.0 21.0.0-21.0.1

Where did you install Nextcloud from: Debian package FreeBSD package Source

Signing status:

Login as admin user into your Nextcloud and access
http://example.com/index.php/settings/integrity/failed
paste the results here.

Result on all Instances this was tested on: No errors have been found.

List of activated apps:

``` If you have access to your command line run e.g.: sudo -u www-data php occ app:list from within your server installation folder ``` Nextcloud 20.0.9 ``` - accessibility: 1.6.0 - activity: 2.13.4 - analytics: 3.4.1 - calendar: 2.2.1 - cloud_federation_api: 1.3.0 - comments: 1.10.0 - contacts: 3.5.1 - contactsinteraction: 1.1.0 - cookbook: 0.8.4 - dashboard: 7.0.0 - dav: 1.16.2 - deck: 1.2.7 - event_update_notification: 1.2.0 - external: 3.7.2 - federatedfilesharing: 1.10.2 - federation: 1.10.1 - files: 1.15.0 - files_accesscontrol: 1.10.2 - files_automatedtagging: 1.10.1 - files_fulltextsearch_tesseract: 20.0.1 - files_pdfviewer: 2.0.1 - files_retention: 1.9.0 - files_rightclick: 0.17.0 - files_sharing: 1.12.2 - files_trashbin: 1.10.1 - files_versions: 1.13.0 - files_videoplayer: 1.9.0 - firstrunwizard: 2.9.0 - flow_notifications: 1.0.3 - groupfolders: 8.2.1 - integration_discourse: 1.0.0 - integration_github: 1.0.0 - integration_gitlab: 1.0.0 - integration_zammad: 1.0.0 - logreader: 2.5.0 - lookup_server_connector: 1.8.0 - nextcloud_announcements: 1.9.0 - notifications: 2.8.0 - oauth2: 1.8.0 - password_policy: 1.10.1 - photos: 1.2.3 - polls: 1.8.3 - privacy: 1.4.0 - provisioning_api: 1.10.0 - quota_warning: 1.9.1 - ransomware_protection: 1.10.0 - recommendations: 0.8.0 - serverinfo: 1.10.0 - settings: 1.2.0 - sharebymail: 1.10.0 - socialsharing_email: 2.2.0 - spreed: 10.0.7 - systemtags: 1.10.0 - tasks: 0.13.6 - terms_of_service: 1.6.1 - text: 3.1.0 - theming: 1.11.0 - twofactor_backupcodes: 1.9.0 - twofactor_gateway: 0.17.0 - twofactor_totp: 5.0.0 - twofactor_u2f: 6.1.0 - updatenotification: 1.10.0 - user_status: 1.0.1 - user_usage_report: 1.4.2 - viewer: 1.4.0 - weather_status: 1.0.0 - workflow_ocr: 1.20.2 - workflow_script: 1.5.1 - workflowengine: 2.2.0 ``` Nextcloud 21.0.1 ``` - accessibility: 1.7.0 - activity: 2.14.3 - bruteforcesettings: 2.1.0 - calendar: 2.2.1 - cloud_federation_api: 1.4.0 - comments: 1.11.0 - contacts: 3.5.1 - contactsinteraction: 1.2.0 - dashboard: 7.1.0 - dav: 1.17.1 - federatedfilesharing: 1.11.0 - federation: 1.11.0 - files: 1.16.0 - files_accesscontrol: 1.11.0 - files_automatedtagging: 1.11.0 - files_pdfviewer: 2.1.0 - files_rightclick: 1.0.0 - files_sharing: 1.13.1 - files_trashbin: 1.11.0 - files_versions: 1.14.0 - files_videoplayer: 1.10.0 - firstrunwizard: 2.10.0 - flow_notifications: 1.1.0 - groupfolders: 9.0.1 - logreader: 2.6.0 - lookup_server_connector: 1.9.0 - nextcloud_announcements: 1.10.0 - notifications: 2.9.0 - oauth2: 1.9.0 - password_policy: 1.11.0 - photos: 1.3.0 - privacy: 1.5.0 - provisioning_api: 1.11.0 - quota_warning: 1.10.0 - recommendations: 1.0.0 - serverinfo: 1.11.0 - settings: 1.3.0 - sharebymail: 1.11.0 - systemtags: 1.11.0 - text: 3.2.0 - theming: 1.12.0 - twofactor_backupcodes: 1.10.0 - twofactor_totp: 6.0.0 - twofactor_u2f: 6.1.0 - updatenotification: 1.11.0 - user_status: 1.1.1 - viewer: 1.5.0 - weather_status: 1.1.0 - workflow_ocr: 1.21.0 - workflow_script: 1.6.0 - workflowengine: 2.3.0 ``` Nextcloud 20.0.9.1 ``` - accessibility: 1.6.0 - activity: 2.13.4 - admin_audit: 1.10.0 - bruteforcesettings: 2.1.0 - calendar: 2.2.1 - cloud_federation_api: 1.3.0 - cms_pico: 1.0.15 - comments: 1.10.0 - contactsinteraction: 1.1.0 - dashboard: 7.0.0 - data_request: 1.7.0 - dav: 1.16.2 - deck: 1.2.7 - event_update_notification: 1.2.0 - external: 3.7.2 - federatedfilesharing: 1.10.2 - federation: 1.10.1 - files: 1.15.0 - files_automatedtagging: 1.10.1 - files_markdown: 2.3.3 - files_pdfviewer: 2.0.1 - files_rightclick: 0.17.0 - files_sharing: 1.12.2 - files_texteditor: 2.14.0 - files_trashbin: 1.10.1 - files_versions: 1.13.0 - firstrunwizard: 2.9.0 - flow_notifications: 1.0.3 - forms: 2.2.4 - groupfolders: 8.2.1 - integration_zammad: 1.0.0 - logreader: 2.5.0 - lookup_server_connector: 1.8.0 - nextcloud_announcements: 1.9.0 - notifications: 2.8.0 - oauth2: 1.8.0 - password_policy: 1.10.1 - photos: 1.2.3 - privacy: 1.4.0 - provisioning_api: 1.10.0 - ransomware_protection: 1.10.0 - recommendations: 0.8.0 - serverinfo: 1.10.0 - settings: 1.2.0 - sharebymail: 1.10.0 - systemtags: 1.10.0 - tasks: 0.13.6 - text: 3.1.0 - theming: 1.11.0 - twofactor_backupcodes: 1.9.0 - twofactor_totp: 5.0.0 - twofactor_u2f: 6.1.0 - updatenotification: 1.10.0 - user_status: 1.0.1 - viewer: 1.4.0 - weather_status: 1.0.0 - workflow_script: 1.5.1 - workflowengine: 2.2.0 ```

Nextcloud configuration:

``` If you have access to your command line run e.g.: sudo -u www-data php occ config:list system from within your Nextcloud installation folder or Insert your config.php content here Make sure to remove all sensitive content such as passwords. (e.g. database password, passwordsalt, secret, smtp password, …) ``` Nextcloud 21.0.1 ``` { "system": { "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "nextcloud.example.com" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "dbtype": "mysql", "version": "21.0.1.1", "overwrite.cli.url": "https:\/\/nextcloud.example.com", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "mysql.utf8mb4": true, "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "app_install_overwrite": [ "bruteforcesettings" ], "filelocking.enabled": true, "memcache.locking": "\\OC\\Memcache\\Redis", "redis": { "host": "***REMOVED SENSITIVE VALUE***", "port": 6379, "timeout": 0, "password": "***REMOVED SENSITIVE VALUE***" }, "memcache.local": "\\OC\\Memcache\\APCu", "mail_smtpmode": "smtp", "mail_smtpsecure": "tls", "mail_sendmailmode": "smtp", "mail_from_address": "***REMOVED SENSITIVE VALUE***", "mail_domain": "***REMOVED SENSITIVE VALUE***", "mail_smtpauthtype": "PLAIN", "mail_smtpauth": 1, "mail_smtpport": "587", "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "mail_smtpname": "***REMOVED SENSITIVE VALUE***", "mail_smtppassword": "***REMOVED SENSITIVE VALUE***", "default_phone_region": "AT", "maintenance": false, "theme": "", "loglevel": 2 } } ``` Nextcloud 20.0.9.1 ``` { "system": { "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "nextcloud.example.org" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "dbtype": "pgsql", "version": "20.0.9.1", "overwrite.cli.url": "http:\/\/localhost", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "instanceid": "***REMOVED SENSITIVE VALUE***", "updater.release.channel": "stable", "memcache.local": "\\OC\\Memcache\\APCu", "filelocking.enabled": true, "memcache.locking": "\\OC\\Memcache\\Redis", "redis": { "host": "***REMOVED SENSITIVE VALUE***", "port": 6379, "timeout": 0, "password": "***REMOVED SENSITIVE VALUE***" }, "log_type": "owncloud", "logfile": "\/usr\/local\/www\/nextcloud_data\/nextcloud.log", "loglevel": "3", "logdateformat": "c", "theme": "", "mail_smtpmode": "smtp", "mail_smtpsecure": "tls", "mail_smtpauthtype": "PLAIN", "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "mail_smtpport": "587", "mail_domain": "***REMOVED SENSITIVE VALUE***", "mail_from_address": "***REMOVED SENSITIVE VALUE***", "maintenance": false, "twofactor_enforced": "false", "twofactor_enforced_groups": [], "twofactor_enforced_excluded_groups": [], "mail_sendmailmode": "smtp", "mail_smtpauth": 1, "mail_smtpname": "***REMOVED SENSITIVE VALUE***", "mail_smtppassword": "***REMOVED SENSITIVE VALUE***", "preview_max_scale_factor": 1, "app_install_overwrite": [ "joplin" ] } } ``` Another Nextcloud 20.0.9.1 ``` { "system": { "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "trusted_domains": [ "nextcloud.example.net" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "overwrite.cli.url": "http:\/\/localhost", "dbtype": "pgsql", "version": "20.0.9.1", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "maintenance": false, "memcache.local": "\\OC\\Memcache\\APCu", "mail_smtpmode": "smtp", "mail_smtpauthtype": "PLAIN", "mail_smtpsecure": "ssl", "mail_from_address": "***REMOVED SENSITIVE VALUE***", "mail_domain": "***REMOVED SENSITIVE VALUE***", "mail_smtpauth": 1, "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "mail_smtpport": "465", "mail_smtpname": "***REMOVED SENSITIVE VALUE***", "mail_smtppassword": "***REMOVED SENSITIVE VALUE***", "filelocking.enabled": true, "memcache.locking": "\\OC\\Memcache\\Redis", "redis": { "host": "***REMOVED SENSITIVE VALUE***", "port": 6379, "timeout": 0, "password": "***REMOVED SENSITIVE VALUE***" }, "log_type": "owncloud", "logfile": "\/usr\/local\/www\/nextcloud_data\/nextcloud.log", "loglevel": "3", "logdateformat": "c", "theme": "", "updater.release.channel": "stable", "mail_sendmailmode": "smtp" } } ```

Are you using external storage, if yes which one: local/smb/sftp/... Local storage only.

Are you using encryption: yes/no Nextcloud E2EE: No. TLS: Yes

Server log (data/nextcloud.log)

nextcloud.log doesn't log any events. flow.log is constantly at 0 bytes no matter if flows are triggered (for example the “Automated tagging” flow) or run_script doesn't trigger.

Additional remarks

I've made sure that the script to be executed is not located within a group folder because of #38.

Testing the flow trigger system with “Automated tagging” does work to auto-add a tag upon change of a file. So we're really certain that all of these nextcloud installations are generally ok and they've been working fine otherwise.

Edit

  1. Added info on nextcloud.log and flow.log.
  2. Added another PHP version
  3. Clarified trigger configurations for filename matches and filename is.
blizzz commented 3 years ago

How do you run your background jobs? Via cron or other? Did you double-check they were running after making the changes?

Your loglevel is too high to log the flow events, IIRC it should be set to 1 for this.

MacLemon commented 3 years ago

Background jobs are run via cron(8) have been and are working perfectly fine. There have been no changes to the cron(8) jobs at all. I've tried loglevels from 3 to 6. I'll check if setting it to 1 makes any difference.

dariodsa commented 3 years ago

It seems like cronJob over WebCron calling doesn't run flow scripts, only calling this those, so you need to switch to system cron.

sudo -u www-data php cron.php