Initial commit — porkbun DDNS for carloselugo.com
Credentials sourced from .ddns-env (gitignored, chmod 600).
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
# porkbun-ddns — DDNS automático para carloselugo.com
|
||||
|
||||
Actualiza registros DNS tipo A en Porkbun cuando cambia la IP pública, y envía una notificación via ntfy.
|
||||
|
||||
## Archivos
|
||||
|
||||
| Archivo | Ruta |
|
||||
|---|---|
|
||||
| Script principal | `/opt/ddns/ddns_porkbun.sh` |
|
||||
| Credenciales | `/opt/ddns/.ddns-env` |
|
||||
| State file | `/home/netintel/.porkbun-ddns.last-ip` |
|
||||
| Log | `/home/netintel/.porkbun-ddns.log` |
|
||||
|
||||
## Credenciales
|
||||
|
||||
Las credenciales sensibles están separadas del script en `/opt/ddns/.ddns-env` con permisos `600`:
|
||||
|
||||
```bash
|
||||
# /opt/ddns/.ddns-env
|
||||
API_KEY="..."
|
||||
SECRET_KEY="..."
|
||||
NTFY_PASS="..."
|
||||
```
|
||||
|
||||
El script hace `source /opt/ddns/.ddns-env` al inicio para cargarlas.
|
||||
|
||||
> Si el proyecto se versiona con git, agregar `.ddns-env` al `.gitignore`.
|
||||
|
||||
## Configuración del script
|
||||
|
||||
Estas variables se configuran directamente en `ddns_porkbun.sh`:
|
||||
|
||||
| Variable | Descripción |
|
||||
|---|---|
|
||||
| `DOMAIN` | Dominio principal |
|
||||
| `SUBDOMAINS` | Array de subdominios a actualizar (`"@"` = root) |
|
||||
| `STATE_FILE` | Ruta donde se guarda la última IP conocida |
|
||||
| `LOG_FILE` | Ruta del archivo de log |
|
||||
| `NTFY_URL` | URL del canal ntfy |
|
||||
| `NTFY_USER` | Usuario ntfy |
|
||||
| `DRYRUN` | `1` = simula updates y envía notificación real sin tocar DNS ni state |
|
||||
|
||||
## Instalación
|
||||
|
||||
```bash
|
||||
# Dar permisos de ejecución
|
||||
chmod +x /opt/ddns/ddns_porkbun.sh
|
||||
|
||||
# Verificar permisos del env
|
||||
chmod 600 /opt/ddns/.ddns-env
|
||||
```
|
||||
|
||||
## Cron (cada 5 minutos)
|
||||
|
||||
```bash
|
||||
crontab -e
|
||||
```
|
||||
|
||||
```
|
||||
*/5 * * * * /opt/ddns/ddns_porkbun.sh
|
||||
```
|
||||
|
||||
## Verificar funcionamiento
|
||||
|
||||
```bash
|
||||
# Ejecución normal
|
||||
bash /opt/ddns/ddns_porkbun.sh
|
||||
|
||||
# Dry run — simula todos los updates y envía notificación real sin modificar DNS ni state
|
||||
DRYRUN=1 bash /opt/ddns/ddns_porkbun.sh
|
||||
|
||||
# Ver log en tiempo real
|
||||
tail -f /home/netintel/.porkbun-ddns.log
|
||||
```
|
||||
Reference in New Issue
Block a user