init: workspace opencode sync
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "=== Telegram Expiry Notifier — Setup ==="
|
||||
|
||||
DIR="/home/player/telegram-notif"
|
||||
PORT=8080
|
||||
SERVICE="telegram-notif"
|
||||
|
||||
# 1. Install PHP + curl
|
||||
echo "[1/4] Installing PHP + php-curl..."
|
||||
sudo apt update -qq
|
||||
sudo apt install -y -qq php-cli php-curl curl 2>/dev/null
|
||||
|
||||
# 2. Create directory
|
||||
echo "[2/4] Creating directory..."
|
||||
mkdir -p "$DIR"
|
||||
|
||||
# 3. Copy files (run this script from the same dir as the PHP files)
|
||||
echo "[3/4] Copying files..."
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
cp "$SCRIPT_DIR/notify-expire.php" "$DIR/"
|
||||
cp "$SCRIPT_DIR/telegram-cb.php" "$DIR/"
|
||||
|
||||
# 4. Create systemd service
|
||||
echo "[4/4] Creating systemd service..."
|
||||
sudo tee /etc/systemd/system/$SERVICE.service > /dev/null <<EOF
|
||||
[Unit]
|
||||
Description=Telegram Expiry Notifier
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/php -S 0.0.0.0:$PORT -t $DIR
|
||||
WorkingDirectory=$DIR
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
User=player
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable $SERVICE
|
||||
sudo systemctl restart $SERVICE
|
||||
|
||||
echo "=== Done ==="
|
||||
echo "Service: sudo systemctl status $SERVICE"
|
||||
echo "Test: curl http://localhost:$PORT/notify-expire.php?key=msr-2026-reset&name=test"
|
||||
echo "Logs: sudo journalctl -u $SERVICE -f"
|
||||
Reference in New Issue
Block a user