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'
相关推荐
盒子691044 分钟前
图生图大模型对于各种复杂的图片如何做负载均衡呢?
运维·负载均衡
2401_834636993 小时前
Linux 负载均衡全实战:Nginx+HAProxy+LVS 从原理到落地
linux·nginx·负载均衡
鹏大师运维8 小时前
为什么信创电脑装软件总提示“软件包架构不匹配”?
linux·运维·架构·国产化·麒麟·deb·统信uos
007张三丰8 小时前
软件测试专栏(11/20):测试框架开发:pytest深度解析与插件体系
运维·服务器·自动化测试·pytest·测试框架
weixin_604236679 小时前
华三 路由器 极简核心配置
运维·服务器·网络·h3c·h3c路由器
鹤落晴春10 小时前
【Linux复习】管理SELinux安全性
linux·运维·服务器
yz_aiks10 小时前
Linux Jar包配置Systemd自启动实战:从排查到配置全流程
linux·python·jar·自启动·systemd
AI智图坊10 小时前
多件装组合SKU图的批量生产效率分析:从PS手工到AI自动化的工作流改造
大数据·运维·人工智能·gpt·ai作画·自动化·aigc
bjzhang7511 小时前
CentOS下安装MySQL详解
linux·mysql·centos
Jason_chen13 小时前
Linux 6.2 音频机制深度解析:AI驱动的低延迟音频与零信任音频安全架构
linux