Переглянути джерело

fix: move the header webhook example to a new argument-free action

The "Ping host" webhook example never worked: it used shell:, which
webhooks reject, and webhooks do not fill arguments from defaults. A new
"Run script on webhook" action shows the header webhook instead, with a
fixed exec: command and no arguments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jamesread 1 день тому
батько
коміт
e82bdaec8c
2 змінених файлів з 17 додано та 6 видалено
  1. 16 5
      config.yaml
  2. 1 1
      docs/modules/ROOT/pages/upgrade/upgrade_notes.adoc

+ 16 - 5
config.yaml

@@ -102,11 +102,6 @@ actions:
     icon: ping
     timeout: 100
     onclick: history
-    # https://docs.olivetin.app/action_execution/onwebhook.html — POST to /webhooks
-    # with header X-OliveTin-Demo: ping-host (path and payload rules are documented).
-    execOnWebhook:
-      - matchHeaders:
-          X-OliveTin-Demo: ping-host
     arguments:
       - name: host
         title: Host
@@ -120,6 +115,22 @@ actions:
         default: 3
         description: How many times to do you want to ping?
 
+  # Actions can be started by a webhook, as well as from the web UI. Webhook
+  # actions must use `exec:`, not `shell:`. This one takes no arguments, so a
+  # webhook request can only start it, not change what it runs. Replace the
+  # command with your own script.
+  #
+  # Docs: https://docs.olivetin.app/action_execution/onwebhook.html
+  # POST to /webhooks with the header X-OliveTin-Demo: run-script
+  - title: Run script on webhook
+    id: run_script_on_webhook
+    icon: '&#128279;'
+    exec: ["echo", "Webhook received. Replace this with your own script."]
+    onclick: execution-dialog
+    execOnWebhook:
+      - matchHeaders:
+          X-OliveTin-Demo: run-script
+
   # OliveTin can control containers - docker is just a command line app.
   #
   # However, if you are running in a container you will need to do some setup,

+ 1 - 1
docs/modules/ROOT/pages/upgrade/upgrade_notes.adoc

@@ -8,7 +8,7 @@ OliveTin releases are published to GitHub, and the release notes are contained t
 [#example-config-guest-actions]
 === The example config only lets guests run harmless demo actions
 
-The example `config.yaml` shipped with OliveTin (including the container image and the macOS example) used to let guests run, see logs for, and kill every example action. It now sets `defaultPermissions` to only let guests view actions. A `guest_actions` ACL lets guests run the harmless demo actions, `admin_acl` gives users in the `admins` usergroup access to every action, and a `system_triggers` ACL lets startup, cron and webhook triggers keep working. The "Setup easy SSH" action no longer has a webhook trigger; the second webhook example is now on "Check disk space".
+The example `config.yaml` shipped with OliveTin (including the container image and the macOS example) used to let guests run, see logs for, and kill every example action. It now sets `defaultPermissions` to only let guests view actions. A `guest_actions` ACL lets guests run the harmless demo actions, `admin_acl` gives users in the `admins` usergroup access to every action, and a `system_triggers` ACL lets startup, cron and webhook triggers keep working. The "Setup easy SSH" and "Ping host" actions no longer have webhook triggers. The webhook examples are now "Check disk space" and a new "Run script on webhook" action, which both use `exec:` and take no arguments.
 
 Upgrading does not change your existing `config.yaml`. If your config started from the example and still has its example actions, review which of them guests can run. This is particularly important for actions that change the system, run scripts, or take a URL or other input from the user, such as "Get OliveTin Theme", "Setup easy SSH", "Delete old backups" and "Restart Docker Container". Either remove the actions you do not use, or set up permissions like the new example config. See xref:security/example_some_admin_actions.adoc[Some actions require admin] and xref:security/acl.adoc#acls-for-triggers[ACLs for triggers].