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'
相关推荐
摸鱼仙人~3 分钟前
大模型文章生成的风格个性化与多文体写作:一套可落地的方法论
linux·运维·服务器
xybDIY7 分钟前
亚马逊云 Organizations 组织 Link 账号关联与解绑自动化解决方案
运维·自动化·云计算·aws
煤球王子8 分钟前
浅学文件系统4(页面缓存)
linux
peixiuhui12 分钟前
Iotgateway技术手册-1. 项目概述
linux·网关·iot·modbus·数据采集网关·iotgateway·采集软件
wdfk_prog13 分钟前
[Linux]学习笔记系列 -- [fs]sysfs
linux·笔记·学习
慕容雪_14 分钟前
运维笔记-网络【属性】-【共享】中没有【家庭网络连接(H)】的选项
运维·网络·共享
AllFiles23 分钟前
Linux 网络故障排查:如何诊断与解决 ARP 缓存溢出问题
linux·后端
AC赳赳老秦42 分钟前
Shell 脚本批量生成:DeepSeek 辅助编写服务器运维自动化指令
运维·服务器·前端·vue.js·数据分析·自动化·deepseek
pps-key1 小时前
Afrog漏洞扫描器:从入门到入狱......边缘的摇摆记录(pps-key黑化版)
linux·计算机网络·安全·网络安全
学Linux的语莫1 小时前
linux的root目录缓存清理
linux·运维·服务器