33800 Docs

← Retour
#!/bin/bash # Install webhook receiver on a Portainer machine # Usage: ./install-webhook.sh <dev|prod> <secret> set -e ENV=$1 SECRET=$2 if [ -z "$ENV" ] || [ -z "$SECRET" ]; then echo "Usage: $0 <dev|prod> <webhook_secret>" exit 1 fi if [ "$ENV" != "dev" ] && [ "$ENV" != "prod" ]; then echo "Environment must be 'dev' or 'prod'" exit 1 fi SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" echo "Installing webhook receiver for $ENV environment..." # Create directory sudo mkdir -p /opt/deploy-webhook sudo chown gouroubleu:gouroubleu /opt/deploy-webhook # Copy script sudo cp "$SCRIPT_DIR/webhook-receiver.py" /opt/deploy-webhook/ sudo chmod +x /opt/deploy-webhook/webhook-receiver.py # Create service file with correct env and secret sudo cp "$SCRIPT_DIR/webhook-receiver.service" /etc/systemd/system/webhook-receiver.service sudo sed -i "s/ENV_PLACEHOLDER/$ENV/g" /etc/systemd/system/webhook-receiver.service sudo sed -i "s/SECRET_PLACEHOLDER/$SECRET/g" /etc/systemd/system/webhook-receiver.service # Create log file sudo touch /var/log/webhook-deploy.log sudo chown gouroubleu:gouroubleu /var/log/webhook-deploy.log # Enable and start service sudo systemctl daemon-reload sudo systemctl enable webhook-receiver sudo systemctl restart webhook-receiver # Check status sleep 2 sudo systemctl status webhook-receiver --no-pager echo "" echo "Installation complete!" echo "Webhook endpoint: http://$(hostname -I | awk '{print $1}'):5500/webhook" echo "Health check: http://$(hostname -I | awk '{print $1}'):5500/health"