first commit

This commit is contained in:
yo 2024-09-21 11:25:04 +02:00
commit a78a62b180
7 changed files with 151 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
work

43
Makefile Normal file
View File

@ -0,0 +1,43 @@
# Created by: johan <johan@nosd.in>
# net-mgmt/webhook/Makefile 2024-09-21 08:47:42Z
PORTNAME= webhook
PORTVERSION= 2.8.1
CATEGORIES= net-mgmt
MAINTAINER= johan@nosd.in
COMMENT= Easily create HTTP endpoints (hooks) on your server, which you can use to execute configured commands
WWW= https://github.com/adnanh/webhook
LICENSE= MIT
USES= go
USE_GITHUB= yes
GH_ACCOUNT= adnanh
GH_TUPLE= \
clbanning:mxj:v1.8.4:clbanning_mxj/vendor/github.com/clbanning/mxj \
dustin:go-humanize:v1.0.0:dustin_go_humanize/vendor/github.com/dustin/go-humanize \
fsnotify:fsnotify:v1.4.2:fsnotify_fsnotify_1/vendor/gopkg.in/fsnotify.v1 \
fsnotify:fsnotify:v1.4.7:fsnotify_fsnotify/vendor/github.com/fsnotify/fsnotify \
ghodss:yaml:v1.0.0:ghodss_yaml/vendor/github.com/ghodss/yaml \
go-check:check:41f04d3bba15:go_check_check/vendor/gopkg.in/check.v1 \
go-chi:chi:v4.0.2:go_chi_chi/vendor/github.com/go-chi/chi \
go-yaml:yaml:eb3733d160e7:go_yaml_yaml/vendor/gopkg.in/yaml.v2 \
gofrs:uuid:v3.2.0:gofrs_uuid/vendor/github.com/gofrs/uuid \
golang:net:c0dbc17a3553:golang_net/vendor/golang.org/x/net \
golang:sys:04cbcbbfeed8:golang_sys/vendor/golang.org/x/sys \
gorilla:mux:v1.7.3:gorilla_mux/vendor/github.com/gorilla/mux \
kr:pretty:v0.1.0:kr_pretty/vendor/github.com/kr/pretty
GO_PKGNAME= github.com/${GH_ACCOUNT}/${PORTNAME}
USE_RC_SUBR= webhook
ETCDIR= ${PREFIX}/etc/webhook
post-install:
${MKDIR} ${STAGEDIR}${ETCDIR}
${INSTALL_DATA} ${FILESDIR}/webhook.yaml.sample \
${STAGEDIR}${ETCDIR}/webhook.yaml.sample
.include <bsd.port.mk>

29
distinfo Normal file
View File

@ -0,0 +1,29 @@
TIMESTAMP = 1726909797
SHA256 (adnanh-webhook-2.8.1_GH0.tar.gz) = a1e3eb2231e5631ebb374b76a79c3bac9cbdc7010974395e2d5e4e2e62ffd187
SIZE (adnanh-webhook-2.8.1_GH0.tar.gz) = 1657848
SHA256 (clbanning-mxj-v1.8.4_GH0.tar.gz) = 335fa9d17855c8540eca83fd8ecacc5979570fe15be04f7c1154f0b71f2c39c7
SIZE (clbanning-mxj-v1.8.4_GH0.tar.gz) = 1091271
SHA256 (dustin-go-humanize-v1.0.0_GH0.tar.gz) = e4540bd50ac855143b4f2e509313079c50cf5d8774f09cc10dbca5ae9803d8ba
SIZE (dustin-go-humanize-v1.0.0_GH0.tar.gz) = 17260
SHA256 (fsnotify-fsnotify-v1.4.2_GH0.tar.gz) = 4a1fd9beeb0496b9cf6084ac83654ece19188e9b2ffa041652d1071d4b225415
SIZE (fsnotify-fsnotify-v1.4.2_GH0.tar.gz) = 29552
SHA256 (fsnotify-fsnotify-v1.4.7_GH0.tar.gz) = b7530d973d0ab0e58ad8ce1b9a4b963d6f57b3d72f2f9e13d49846976361b1cd
SIZE (fsnotify-fsnotify-v1.4.7_GH0.tar.gz) = 31139
SHA256 (ghodss-yaml-v1.0.0_GH0.tar.gz) = 8a76b47cd171944612aae1cfa08bbb971b63fec16794c839252808392097de44
SIZE (ghodss-yaml-v1.0.0_GH0.tar.gz) = 11772
SHA256 (go-check-check-41f04d3bba15_GH0.tar.gz) = 2d5b1036909b241e44f0d6a7cfa936cf9f875efb4f0af077cd61585c6d0c0432
SIZE (go-check-check-41f04d3bba15_GH0.tar.gz) = 31614
SHA256 (go-chi-chi-v4.0.2_GH0.tar.gz) = 7713a5afd18c440f38e67f853f5ded4f039f08f239dc6a29ed2788be5caaae99
SIZE (go-chi-chi-v4.0.2_GH0.tar.gz) = 67748
SHA256 (go-yaml-yaml-eb3733d160e7_GH0.tar.gz) = af7d1783112db839a6d2719701b1f4965bfd9749dbffe3f0f8ce1cf5e46be201
SIZE (go-yaml-yaml-eb3733d160e7_GH0.tar.gz) = 64708
SHA256 (gofrs-uuid-v3.2.0_GH0.tar.gz) = 77d6e7d793bbc8835e082b590d0512ed177d6eba898bffb202d76ef97db57677
SIZE (gofrs-uuid-v3.2.0_GH0.tar.gz) = 17064
SHA256 (golang-net-c0dbc17a3553_GH0.tar.gz) = 67e59dfe55231f9a28b167c6b77d897ad503e599b60e0eec16a677a0c641bb93
SIZE (golang-net-c0dbc17a3553_GH0.tar.gz) = 1172293
SHA256 (golang-sys-04cbcbbfeed8_GH0.tar.gz) = 8f194ecf5ac4834ba7e3543f38f67a8972ede9fee67e2142eb72644213335824
SIZE (golang-sys-04cbcbbfeed8_GH0.tar.gz) = 1535773
SHA256 (gorilla-mux-v1.7.3_GH0.tar.gz) = 92adb9aea022f8b35686b75be50ba1206c4457c2f8a0e2a9d10d8721f35b3f11
SIZE (gorilla-mux-v1.7.3_GH0.tar.gz) = 42495
SHA256 (kr-pretty-v0.1.0_GH0.tar.gz) = 3aeb5d90b719765781befb9f156d0d0b8e5a7aafbcf15321e9eabbd35df31358
SIZE (kr-pretty-v0.1.0_GH0.tar.gz) = 8550

38
files/webhook.in Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
# 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:=/usr/local/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=/usr/local/sbin/${name}
command=/usr/sbin/daemon
command_args="-S -l ${webhook_facility} -s ${webhook_priority} -t ${name} -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"

28
files/webhook.yaml.sample Normal file
View File

@ -0,0 +1,28 @@
- id: webhook
execute-command: /home/adnan/redeploy-go-webhook.sh
command-working-directory: /home/adnan/go
response-message: I got the payload!
response-headers:
- name: Access-Control-Allow-Origin
value: '*'
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-hmac-sha1
secret: mysecret
parameter:
source: header
name: X-Hub-Signature
- match:
type: value
value: refs/heads/master
parameter:
source: payload
name: ref

9
pkg-descr Normal file
View File

@ -0,0 +1,9 @@
webhook is a lightweight configurable tool written in Go, that allows you to
easily create HTTP endpoints (hooks) on your server, which you can use to
execute configured commands. You can also pass data from the HTTP request
(such as headers, payload or query variables) to your commands.
webhook also allows you to specify rules which have to be satisfied in order
for the hook to be triggered.
WWW: https://github.com/adnanh/webhook

3
pkg-plist Normal file
View File

@ -0,0 +1,3 @@
bin/webhook
@dir %%ETCDIR%%
@sample %%ETCDIR%%/webhook.yaml.sample