summaryrefslogtreecommitdiff
path: root/www/webhook/files
diff options
context:
space:
mode:
Diffstat (limited to 'www/webhook/files')
-rw-r--r--www/webhook/files/webhook.in39
-rw-r--r--www/webhook/files/webhook.yaml66
2 files changed, 105 insertions, 0 deletions
diff --git a/www/webhook/files/webhook.in b/www/webhook/files/webhook.in
new file mode 100644
index 000000000000..dc0ade3e2199
--- /dev/null
+++ b/www/webhook/files/webhook.in
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# $FreeBSD$
+
+# PROVIDE: webhook
+# REQUIRE: NETWORKING SYSLOG
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf to enable webhook:
+#
+# webhook_enable="YES"
+
+. /etc/rc.subr
+
+desc="webhook daemon"
+name=webhook
+rcvar=webhook_enable
+
+load_rc_config $name
+
+: ${webhook_conf:=%%PREFIX%%/etc/webhook.yaml}
+: ${webhook_enable:=NO}
+: ${webhook_facility:=daemon}
+: ${webhook_priority:=debug}
+: ${webhook_user:=nobody}
+
+pidfile=/var/run/${name}.pid
+extra_commands=reload
+sig_reload=USR1
+
+procname=%%PREFIX%%/sbin/${name}
+command=/usr/sbin/daemon
+command_args="%%DAEMONARGS%% -p ${pidfile} ${procname} \
+ -hooks ${webhook_conf} ${webhook_options}"
+
+start_precmd="install -o ${webhook_user} /dev/null ${pidfile}"
+reload_cmd="pkill -SIGUSR1-U ${webhook_user} -F {pidfile} ${procname}"
+
+run_rc_command "$1"
diff --git a/www/webhook/files/webhook.yaml b/www/webhook/files/webhook.yaml
new file mode 100644
index 000000000000..c3de043b97e6
--- /dev/null
+++ b/www/webhook/files/webhook.yaml
@@ -0,0 +1,66 @@
+---
+# See https://github.com/adnanh/webhook/wiki for further information on this
+# file and its options. Instead of YAML, you can also define your
+# configuration as JSON. We've picked YAML for these examples because it
+# supports comments, whereas JSON does not.
+#
+# In the default configuration, webhook runs as user nobody. Depending on
+# the actions you want your webhooks to take, you might want to run it as
+# user root. Set the rc.conf(5) variable webhook_user to the desired user,
+# and restart webhook.
+
+# An example for a simple webhook you can call from a browser or with
+# wget(1) or curl(1):
+# curl -v 'localhost:9000/hooks/samplewebhook?secret=geheim'
+- id: samplewebhook
+ execute-command: /usr/bin/logger
+ pass-arguments-to-command:
+ - source: string
+ name: '-p'
+ - source: string
+ name: 'daemon.notice'
+ - source: string
+ name: '-t'
+ - source: string
+ name: 'samplewebhook'
+ - source: string
+ name: 'Sample webhook has been invoked. User Agent:'
+ - source: header
+ name: 'user-agent'
+ response-message: |
+ Example webhook executed
+ trigger-rule-mismatch-http-response-code: 400
+ trigger-rule:
+ match:
+ type: value
+ value: geheim
+ parameter:
+ source: url
+ name: secret
+
+# Running an Ansible playbook on pushing to Github, courtesy of Dave
+# Cottlehuber.
+- id: ansible
+ execute-command: "/home/ansible/src/ansible/deploy.sh"
+ command-working-directory: "/home/ansible/src/ansible"
+ pass-arguments-to-command:
+ - source: payload
+ name: head_commit.id
+ - source: payload
+ name: pusher.name
+ - source: payload
+ name: pusher.email
+ trigger-rule:
+ and:
+ - match:
+ type: payload-hash-sha1
+ secret: .....
+ parameter:
+ source: header
+ name: X-Hub-Signature
+ - match:
+ type: value
+ value: refs/heads/master
+ parameter:
+ source: payload
+ name: ref