45 lines
2.2 KiB
PowerShell
45 lines
2.2 KiB
PowerShell
# Telegram Expiry Notifier — Deploy ke somewhere
|
|
# Jalankan script ini. Masukkan password SSH player@somewhere ketika diminta.
|
|
|
|
$server = "player@somewhere"
|
|
$remoteDir = "/home/player/telegram-notif"
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
|
|
Write-Host "=== Deploy Telegram Notifier ke $server ===" -ForegroundColor Cyan
|
|
Write-Host ""
|
|
|
|
# 1. Buat remote directory via SSH
|
|
Write-Host "[1/4] Membuat remote directory..." -ForegroundColor Yellow
|
|
Start-Process -Wait -WindowStyle Normal -FilePath "ssh" -ArgumentList "-t $server mkdir -p $remoteDir"
|
|
Write-Host ""
|
|
|
|
# 2. Copy files via SCP
|
|
Write-Host "[2/4] Copy files via SCP..." -ForegroundColor Yellow
|
|
Start-Process -Wait -WindowStyle Normal -FilePath "scp" -ArgumentList "$scriptDir\notify-expire.php $scriptDir\telegram-cb.php $scriptDir\routeros_api.class.php $scriptDir\setup.sh ${server}:${remoteDir}/"
|
|
Write-Host ""
|
|
|
|
# 3. Run setup via SSH
|
|
Write-Host "[3/4] Run remote setup..." -ForegroundColor Yellow
|
|
Write-Host " (akan menginstall PHP + membuat systemd service)" -ForegroundColor Gray
|
|
Start-Process -Wait -WindowStyle Normal -FilePath "ssh" -ArgumentList "-t $server cd $remoteDir && chmod +x setup.sh && ./setup.sh"
|
|
Write-Host ""
|
|
|
|
# 4. Test
|
|
Write-Host "[4/4] Test..." -ForegroundColor Yellow
|
|
Start-Process -Wait -WindowStyle Normal -FilePath "ssh" -ArgumentList "-t $server curl -s 'http://localhost:8080/notify-expire.php?key=msr-2026-reset&name=test_deploy'"
|
|
Write-Host ""
|
|
|
|
Write-Host "=== Done ===" -ForegroundColor Green
|
|
Write-Host ""
|
|
Write-Host "Update RouterOS scheduler:"
|
|
Write-Host " Family on-event:"
|
|
Write-Host ' /tool fetch url=("http://100.100.31.46:8080/notify-expire.php?key=msr-2026-reset&name=" . $name) http-method=get keep-result=no'
|
|
Write-Host ""
|
|
Write-Host " Tambah scheduler:"
|
|
Write-Host ' /system scheduler add name=tg-cb-poll interval=00:01:00 start-time=startup on-event=":delay 10s;/tool fetch url=\"http://100.100.31.46:8080/telegram-cb.php?key=msr-2026-reset\" http-method=get keep-result=no" disabled=no'
|
|
Write-Host ""
|
|
Write-Host "Remote management:"
|
|
Write-Host " ssh $server"
|
|
Write-Host " sudo systemctl status telegram-notif"
|
|
Write-Host " sudo journalctl -u telegram-notif -f"
|