Webhook 配置备忘

本文地址:blog.lucien.ink/archives/552

将下列代码保存为 install.sh,然后 bash install.sh

shell 复制代码
#!/usr/bin/env bash
set -e
wget 'https://github.mirrors.lucien.ink/https://github.com/adnanh/webhook/releases/download/2.8.2/webhook-linux-amd64.tar.gz'
tar -xzvf webhook-linux-amd64.tar.gz
mv webhook-linux-amd64 /usr/local/
cat << EOF > /etc/systemd/system/webhook.service
[Unit]
Description=Webhook server
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/webhook-linux-amd64/webhook \
  -nopanic \
  -hooks /etc/webhook/hooks.yaml \
  -hotreload \
  -logfile /var/log/webhook/webhook.log \
  -port 9000
Restart=on-failure
User=root
Group=root

[Install]
WantedBy=multi-user.target
EOF
systemctl enable webhook
mkdir -p /etc/webhook/scripts
cat << EOF > /etc/webhook/hooks.yaml
- id: test
  execute-command: "/etc/webhook/scripts/test.sh"
  command-working-directory: "/root/"
  trigger-rule:
    match:
      type: value
      value: Bearer change-this
      parameter:
        source: header
        name: Authorization
EOF
cat << EOF > /etc/webhook/scripts/test.sh
#!/usr/bin/env sh
echo foo > bar
EOF
chmod +x /etc/webhook/scripts/test.sh
mkdir -p /var/log/webhook
systemctl start webhook
curl 'http://localhost:9000/hooks/test' -H 'Authorization: Bearer change-this'
相关推荐
Ankie Wan10 小时前
cgroup(Control Group)是 Linux 内核提供的一种机制,用来“控制、限制、隔离、统计”进程对系统资源的使用。
linux·容器·cgroup·lxc
skywalk816310 小时前
尝试在openi启智社区的dcu环境安装ollama最新版0.15.2(失败)
linux·运维·服务器·ollama
MMME~11 小时前
Ansible模块速查指南:高效定位与实战技巧
大数据·运维·数据库
zhengfei61111 小时前
AutoPentestX – Linux 自动化渗透测试和漏洞报告工具
linux·运维·自动化
我材不敲代码11 小时前
在Linux系统上安装MySQL
linux·运维·服务器
obboda11 小时前
CICD 部署与使用
运维
yuezhilangniao11 小时前
阿里云服务器Alibaba Cloud Linux 3 安装Python3.11简明指南
linux·运维·python3.11
程序 代码狂人11 小时前
CentOS7初始化配置操作
linux·运维·开发语言·php
lcx_defender11 小时前
【Docker】Docker部署运行nacos
运维·docker·容器
历程里程碑11 小时前
Linux15 进程二
linux·运维·服务器·开发语言·数据结构·c++·笔记