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'
相关推荐
竣达技术9 分钟前
就地显示 + 远程上传,铅酸蓄电池在线监测完整解决方案
运维·数据库
Allstar_4323 分钟前
拆解全星APQP系统的六大核心质量工具如何联动——汽车供应链企业专业级研发项目管理系统
运维·服务器
随便写个软件28 分钟前
【新版本】EasyExplorer资源管理器 3.12.0——地址栏重要更新
运维·服务器·前端·everything·资源管理器
2402_8828938633 分钟前
Linux 进程概念详解(下)—— 进程调度、环境变量与虚拟地址空间
linux·进程·虚拟地址空间
虚无的纽扣36 分钟前
【Linux】揭开文件系统神秘的面纱:第四讲:可执行文件的组装车间
linux·运维·服务器
YMWM_37 分钟前
ubuntu系统字体缩放配置
linux·运维·ubuntu
Amelio_Ming42 分钟前
rk3588 pcie驱动分析之二 (pcie设备树节点分析)
linux·嵌入式硬件
数据中心论坛(公众号同名)1 小时前
补水管道巨响抖动|数据中心水箱振动故障拆解(下篇)
大数据·运维
yichengerp1 小时前
电子元件ERP软件哪个好用?易呈云ERP与主流方案对比解析
大数据·运维·人工智能·云计算·制造
励志师code1 小时前
Ansible 批量运维实战:从连通性巡检到灰度变更的完整闭环
运维·ansible