Update README.md

This commit is contained in:
Ramon Caballero 2026-04-07 11:38:09 +01:00
parent 915393a4c8
commit 7162d3aad8
1 changed files with 58 additions and 19 deletions

View File

@ -2,43 +2,82 @@
Script in PHP to update DNS type A records on porkbun.com using their API. Script in PHP to update DNS type A records on porkbun.com using their API.
This can easily be modified to a different programming or scripting language and domain registrar. This can easily be adapted to other registrars or scripting languages.
## Prerequisites ## Prerequisites
- At least one domain in porkbun.com with DNS type A records already pointing to your dynamic IP address. - At least one domain in porkbun.com with DNS type A records already pointing to your dynamic IP address.
- Access to Porkbun API. - Access to the Porkbun API (API key + secret key).
## Installation & Deployment
### 1. Clone the repository
```bash
git clone https://gitea.ramoncaballero.dev/mon/pb-dydns.git
cd pb-dydns
```
### 2. Deploy the script
Run the provided deployment script:
```bash
./deploy.sh
```
This creates a directory:
```
$HOME/pb-dydns-live
```
Inside it you will find:
- pb-dydns.php (the script you run)
- PorkbunAPI.php
- UpdateDnsCommand.php
- Config.php
- Logger.php
- pb-dydns.json (your configuration file)
- pb-dydns.log (log file)
### 3. Configure it
Edit the configuration file `$HOME/pb-dydns-live/pb-dydns.json`
Fill in:
- the Porkbun API endpoint (usually https://api.porkbun.com/api/json/v3/)
- your Porkbun API key
- your secret key
## How to use it ## How to use it
### from command line ### From the command line
``` ```
$ php /path/to/pb-dydns.php domain_name $ php /path/to/pb-dydns-live/pb-dydns.php yourdomain.com
``` ```
### as a cron job ### As a cron job
``` Edit your crontab:
$ crontab -e
```bash
crontab -e
``` ```
Modify this line to fit your needs, and add it as many times as domains you want to automatically update: Add a line like:
``` ```
*/10 * * * * php /path/to/pb-dydns.php domain_name > /dev/null */10 * * * * php /path/to/pb-dydns-live/pb-dydns.php yourdomain.com > /dev/null
``` ```
That will run the script every 10 minutes. This runs the updater every 10 minutes.
Then restart cron (I'm not sure if this is necessary): ## Logs
``` DNS updates are written to `/path/to/pb-dydns-live/pb-dydns.log`
$ sudo systemctl restart cron
```
Entries to `pb-dydns.log` will be added, to view it you can: Runs where nothing changes do not produce log entries.
```
$ cat /path/to/pb-dydns.log
```