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'
相关推荐
daad77710 分钟前
bitcoin HD钱包示例 真实使命7
运维·服务器
BestOrNothing_201517 分钟前
Ubuntu 22.04 下调整 VS Code 界面及字体教程
linux·vscode·ubuntu22.04·界面调整
Zero-Talent27 分钟前
TCP/IP协议
运维·服务器·网络
桌面运维家28 分钟前
Windows/Linux云桌面:高校VDisk方案部署指南
linux·运维·windows
Du_chong_huan31 分钟前
1.7 计算机网络和因特网的历史 | 《计算机网络:自顶向下方法》精读版
运维·服务器·网络
ZZZKKKRTSAE40 分钟前
rhel9快速上手Docker
运维·docker·容器
筱顾大牛41 分钟前
Docker安装教程(加汉化!超详细!!!)
运维·docker·容器
没头脑的男大43 分钟前
关于tailscale和ssh那些事儿
运维·服务器·ssh
mzhan0171 小时前
Linux:intel:Cache Allocation tech
linux·cpu
竹之却1 小时前
OpenClaw 接入QQ-Bot + 接入Feishu(飞书)
运维·服务器·飞书·openclaw·qq-bot·opencalw接入qq+飞书