Skip to content

corey-braun/porkbun-api-bash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

porkbun-api-bash

Bash script to automate common tasks using the Porkbun API.

Requires jq 1.6+ for JSON parsing and manipulation.

Commands

update-dns

Updates the DNS A record for a given domain to your current public IPv4 address.

Your current public IPv4 address is obtained using the Porkbun API's ping endpoint. If the A record for the specified domain already matches your public IP it will not be updated.

retrieve-ssl

Retrieves the wildcard SSL cert bundle generated by Porkbun for a given domain. This command writes 5 files to a configured destination folder:

  • <your.fqdn>.fullchain.pem
  • <your.fqdn>.intermediate.pem
  • <your.fqdn>.privatekey.pem
  • <your.fqdn>.publickey.pem
  • <your.fqdn>.p12

ping

Makes an API call to the Porkbun API ping endpoint. Can be helpful for confirming your API credentials are configured correctly and you are able to make API calls.

custom <endpoint> [key=value [...]]

Make a custom API call to a specified endpoint. The endpoint argument should be a string including everything after https://api.porkbun.com/api/json/v3/ in the API endpoint's URI. Any additional arguments should be in the form key=value, and will be added to the JSON POST data sent in the API call.

For example, the following command could be used to create a DNS record:

porkbun-api custom dns/create/example.com type=A content=1.1.1.1 ttl=600

If this command is called with no arguments, an API call can be formulated through an interactive dialog.

Installation

To install the script, add the main executable to a directory in your PATH, then add the .porkbun-apirc configuration file to your home directory:

sudo curl -fsSLO https://raw.githubusercontent.com/corey-braun/porkbun-api-bash/main/porkbun-api --output-dir /usr/local/bin
sudo chmod +x /usr/local/bin/porkbun-api
curl -fsSLO https://raw.githubusercontent.com/corey-braun/porkbun-api-bash/main/.porkbun-apirc --output-dir ~
chmod 600 ~/.porkbun-apirc

After this, the script can be called using the porkbun-api command.

Configuration

All variables can be configured by editing config file ~/.porkbun-apirc. A different config file can be specified with flag -c /path/to/config.

The configuration file will be sourced/executed by the script when called, so it is recommended to restrict access to it as much as possible (i.e. set file permissions to 600). Details on what configurable variables do are documented in the repository's example .porkbun-apirc file.

Some variables can also be set via flags when calling the script. Any variables set via flags will take precedence over variables set in the config file. Usage details for each flag are given when calling the script with the -h (help) flag.

About

Bash script for interacting with the Porkbun API

Resources

License

Stars

7 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages