aboutsummaryrefslogtreecommitdiff
path: root/network
diff options
context:
space:
mode:
authorSergei Fedosoff <eleksir@gmail.com>2019-11-09 08:21:26 +0700
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2019-11-09 08:21:26 +0700
commit52d564781ebe554de0582ceee36215bfabef8ed3 (patch)
tree8aa27f669933b3dcd6de1f8163d9a5d27bf8fdd5 /network
parent5cf7b0b2eec64ea9f3c353ee6e0f356fc9634696 (diff)
network/webhook: Added (WebHook tool).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'network')
-rw-r--r--network/webhook/README24
-rw-r--r--network/webhook/doinst.sh25
-rw-r--r--network/webhook/slack-desc19
-rw-r--r--network/webhook/webhook-wrapper.sh36
-rw-r--r--network/webhook/webhook.SlackBuild85
-rw-r--r--network/webhook/webhook.info10
-rw-r--r--network/webhook/webhook.init69
-rw-r--r--network/webhook/webhook.logrotate6
-rw-r--r--network/webhook/webhook.sysconfig23
9 files changed, 297 insertions, 0 deletions
diff --git a/network/webhook/README b/network/webhook/README
new file mode 100644
index 000000000000..cd7cfb6f5148
--- /dev/null
+++ b/network/webhook/README
@@ -0,0 +1,24 @@
+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.
+
+For example, if you're using Github or Bitbucket, you can use webhook to set
+up a hook that runs a redeploy script for your project on your staging server,
+whenever you push changes to the master branch of your project.
+
+If you use Mattermost or Slack, you can set up an "Outgoing webhook
+integration" or "Slash command" to run various commands on your server, which
+can then report back directly to you or your channels using the "Incoming
+webhook integrations", or the appropriate response body.
+
+webhook aims to do nothing more than it should do, and that is:
+1. receive the request,
+2. parse the headers, payload and query variables,
+3. check if the specified rules for the hook are satisfied,
+4. and finally, pass the specified arguments to the specified command via
+ command line arguments or via environment variables.
+
+Everything else is the responsibility of the command's author.
diff --git a/network/webhook/doinst.sh b/network/webhook/doinst.sh
new file mode 100644
index 000000000000..ae9c074d0d3a
--- /dev/null
+++ b/network/webhook/doinst.sh
@@ -0,0 +1,25 @@
+config() {
+ NEW="$1"
+ OLD="$(dirname $NEW)/$(basename $NEW .new)"
+ if [ ! -r $OLD ]; then
+ mv $NEW $OLD
+ elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
+ rm $NEW
+ fi
+}
+
+preserve_perms() {
+ NEW="$1"
+ OLD="$(dirname $NEW)/$(basename $NEW .new)"
+ if [ -e $OLD ]; then
+ cp -a $OLD ${NEW}.incoming
+ cat $NEW > ${NEW}.incoming
+ mv ${NEW}.incoming $NEW
+ fi
+ config $NEW
+}
+
+preserve_perms /etc/rc.d/rc.webhook.new
+config /etc/webhook/hooks.json.new
+config /etc/default/webhook.new
+config /etc/logrotate.d/webhook.new
diff --git a/network/webhook/slack-desc b/network/webhook/slack-desc
new file mode 100644
index 000000000000..2a1ad2be8575
--- /dev/null
+++ b/network/webhook/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.
+# Line up the first '|' above the ':' following the base package name, and
+# the '|' on the right side marks the last column you can put a character in.
+# You must make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':' except on otherwise blank lines.
+
+ |-----handy-ruler------------------------------------------------------|
+webhook: webhook (Webhook tool)
+webhook:
+webhook: Webhook is a lightweight configurable tool written in Go, that allows
+webhook: you to easily create HTTP endpoints (hooks) on your server, which you
+webhook: can use to execute configured commands. You can also pass data from
+webhook: the HTTP request (such as headers, payload or query variables) to
+webhook: your commands. webhook also allows you to specify rules which have to
+webhook: be satisfied in order for the hook to be triggered.
+webhook: service providing container.
+webhook:
+webhook: Homepage: https://github.com/adnanh/webhook/
diff --git a/network/webhook/webhook-wrapper.sh b/network/webhook/webhook-wrapper.sh
new file mode 100644
index 000000000000..6d69c5911a90
--- /dev/null
+++ b/network/webhook/webhook-wrapper.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+#
+# This is wrapper for webhook. This script required only in order to properly
+# start and stop this daemon, because webhook does not set pid file and unable
+# to run as specific user.
+
+ME=$0
+BINARY=/usr/sbin/webhook
+CONFIG=/etc/default/webhook
+
+source "$CONFIG"
+getent passwd ${USER} >/dev/null 2>&1
+
+if [ $? != 0 ]; then
+ echo "Create user '${USER}' before running ${ME}"
+ exit 1
+fi
+
+if [ -z $URLPREFIX ]; then
+ URLPREFIX=""
+else
+ URLPREFIX="-urlprefix=${URLPREFIX}"
+fi
+
+if [ ! -z $PIDFILE ]; then
+ if [ ! -d "$(dirname ${PIDFILE})" ]; then
+ mkdir -p "$(dirname ${PIDFILE})"
+ fi
+
+ echo "$$" >$PIDFILE
+fi
+
+OPTIONS="-hooks ${HOOKS} -ip ${IPADDR} -port ${PORT} ${URLPREFIX} ${OPTS}"
+exec sudo -u $USER "${BINARY}" $OPTIONS
+
+# vim: ft=sh noet ai ts=4 sw=4 sts=4:
diff --git a/network/webhook/webhook.SlackBuild b/network/webhook/webhook.SlackBuild
new file mode 100644
index 000000000000..fe781a2d37d0
--- /dev/null
+++ b/network/webhook/webhook.SlackBuild
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+# Slackware build script for webhook
+
+# Copyright 2019 Sergei Fedosoff <eleksir@gmail.com>
+# All rights reserved.
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+PRGNAM=webhook
+VERSION=${VERSION:-2.6.10}
+BUILD=${BUILD:-5}
+TAG=${TAG:-_SBo}
+
+if [ -z "$ARCH" ]; then
+ case "$( uname -m )" in
+ i?86) ARCH=i586 ;;
+ arm*) ARCH=arm ;;
+ *) ARCH=$( uname -m ) ;;
+ esac
+fi
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+set -e
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $PRGNAM-$VERSION
+tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
+cd $PRGNAM-$VERSION
+chown -R root:root .
+find -L . \
+ \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
+ -o -perm 511 \) -exec chmod 755 {} \; -o \
+ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
+ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
+
+# Huh, some magic for native go build system
+cd ..
+mv $PRGNAM-$VERSION $PRGNAM
+mkdir -p $PRGNAM-$VERSION/build
+mv $PRGNAM/vendor $PRGNAM-$VERSION/build/src
+mkdir -p $PRGNAM-$VERSION/build/src/github.com/adnanh
+mv $PRGNAM $PRGNAM-$VERSION/build/src/github.com/adnanh
+cd $PRGNAM-$VERSION
+GOPATH=$(pwd)/build go build -o $PKG/usr/sbin/webhook github.com/adnanh/$PRGNAM
+strip -s $PKG/usr/sbin/webhook
+
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cp -a build/src/github.com/adnanh/$PRGNAM/{CONTRIBUTING.md,LICENSE,README.md} $PKG/usr/doc/$PRGNAM-$VERSION
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/docs
+cp -rp build/src/github.com/adnanh/$PRGNAM/docs $PKG/usr/doc/$PRGNAM-$VERSION
+install -Dpm 0755 $CWD/webhook-wrapper.sh $PKG/usr/sbin/webhook-wrapper.sh
+#install -Dpm 0644 $CWD/hooks.json $PKG/etc/webhook/hooks.json.new
+install -Dpm 0644 $CWD/webhook.init $PKG/etc/rc.d/rc.webhook.new
+install -Dpm 0644 $CWD/webhook.sysconfig $PKG/etc/default/webhook.new
+install -Dpm 0644 $CWD/webhook.logrotate $PKG/etc/logrotate.d/webhook.new
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+cat $CWD/doinst.sh > $PKG/install/doinst.sh
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
diff --git a/network/webhook/webhook.info b/network/webhook/webhook.info
new file mode 100644
index 000000000000..dd537026db72
--- /dev/null
+++ b/network/webhook/webhook.info
@@ -0,0 +1,10 @@
+PRGNAM="webhook"
+VERSION="2.6.10"
+HOMEPAGE="https://github.com/adnanh/webhook"
+DOWNLOAD="https://github.com/adnanh/webhook/archive/2.6.10/webhook-2.6.10.tar.gz"
+MD5SUM="d99188ebc028ae51b71a6113b4e92e7d"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES="google-go-lang"
+MAINTAINER="Sergei Fedosoff"
+EMAIL="eleksir@gmail.com"
diff --git a/network/webhook/webhook.init b/network/webhook/webhook.init
new file mode 100644
index 000000000000..7b809260ae44
--- /dev/null
+++ b/network/webhook/webhook.init
@@ -0,0 +1,69 @@
+#!/bin/sh
+# Start/stop/restart webhook.
+
+. /etc/default/webhook
+
+__start() {
+ if [ -z "$PIDFILE" ]; then
+ echo "WebHook will start but please set PIDFILE in /etc/default/webhook"
+ else
+ if [ -f "$PIDFILE" ]; then
+ echo "WebHook daemon is already running as PID $(< ${PIDFILE}) " >&2
+ exit 3
+ fi
+ fi
+
+ if [ -x /usr/sbin/webhook-wrapper.sh ]; then
+ echo "Starting WebHook daemon: /usr/sbin/webhook-wrapper.sh &"
+
+ if [ -z "$LOG" ]; then
+ /usr/sbin/webhook-wrapper.sh > /dev/null 2>&1 &
+ else
+ /usr/sbin/webhook-wrapper.sh >> "$LOG" 2>&1 &
+ fi
+ fi
+}
+
+__stop() {
+ if [ -f "$PIDFILE" ]; then
+ kill "$(< ${PIDFILE})"
+ rm -f "${PIDFILE}"
+ else
+ if [ -z "$PIDFILE" ]; then
+ killall -9 webhook-wrapper.sh
+ killall -9 webhook
+ else
+ echo "Webhook is not running"
+ fi
+ fi
+}
+
+__restart() {
+ __stop
+ if [ -z "$PIDFILE" ]; then
+ sleep 1
+ else
+ while [ -f "$PIDFILE" ]; do
+ sleep 1
+ done
+ fi
+ __start
+}
+
+
+case "$1" in
+ 'start')
+ __start
+ ;;
+ 'stop')
+ __stop
+ ;;
+ 'restart')
+ __restart
+ ;;
+ *)
+ echo "usage $0 start|stop|restart"
+ exit 2
+esac
+
+# vim: ft=sh noet ai ts=4 sw=4 sts=4:
diff --git a/network/webhook/webhook.logrotate b/network/webhook/webhook.logrotate
new file mode 100644
index 000000000000..59e770a22453
--- /dev/null
+++ b/network/webhook/webhook.logrotate
@@ -0,0 +1,6 @@
+/var/log/webhook.log {
+ daily
+ rotate 7
+ compress
+ missingok
+}
diff --git a/network/webhook/webhook.sysconfig b/network/webhook/webhook.sysconfig
new file mode 100644
index 000000000000..5480a856b221
--- /dev/null
+++ b/network/webhook/webhook.sysconfig
@@ -0,0 +1,23 @@
+# Path to webhook config
+HOOKS="/etc/webhook/hooks.json"
+
+# IP Address webhook listen to
+IPADDR="127.0.0.1"
+
+# Port webhook binds to
+PORT="9080"
+
+# where to log stderr and stdout of webhook
+LOG="/var/log/webhook.log"
+
+# webhook wrapper' pidfile
+PIDFILE="/var/run/webhook/webhook.pid"
+
+# effective user
+USER=nobody
+
+# protocol://yourserver:port/PREFIX/:hook-id (default "hooks")
+URLPREFIX="hooks"
+
+# Other options
+OPTS="-hotreload -nopanic -verbose"