Code updates for AUR package
This commit is contained in:
parent
e02d54322c
commit
3f22c99f77
|
@ -0,0 +1,20 @@
|
|||
pkgbase = porkbun-dynamic-dns-python-git
|
||||
pkgdesc = Our minimalist dynamic DNS client written in Python
|
||||
pkgver = r14.e02d543
|
||||
pkgrel = 1
|
||||
url = https://github.com/Ta180m/porkbun-dynamic-dns-python
|
||||
arch = any
|
||||
license = MIT
|
||||
depends = python
|
||||
depends = python-requests
|
||||
backup = etc/porkbun-ddns.json
|
||||
source = porkbun-ddns.py
|
||||
source = config.json.example
|
||||
source = systemd.service
|
||||
source = systemd.timer
|
||||
sha256sums = SKIP
|
||||
sha256sums = SKIP
|
||||
sha256sums = SKIP
|
||||
sha256sums = SKIP
|
||||
|
||||
pkgname = porkbun-dynamic-dns-python-git
|
|
@ -0,0 +1,30 @@
|
|||
# Maintainer: Anthony Wang <ta180m@pm.me>
|
||||
_pkgname=porkbun-dynamic-dns-python
|
||||
pkgname=${_pkgname}-git
|
||||
pkgver=r14.e02d543
|
||||
pkgrel=1
|
||||
pkgdesc="Our minimalist dynamic DNS client written in Python"
|
||||
arch=(any)
|
||||
url="https://github.com/Ta180m/porkbun-dynamic-dns-python"
|
||||
license=('MIT')
|
||||
depends=('python' 'python-requests')
|
||||
backup=('etc/porkbun-ddns.json')
|
||||
source=("porkbun-ddns.py"
|
||||
"config.json.example"
|
||||
"systemd.service"
|
||||
"systemd.timer")
|
||||
sha256sums=(SKIP
|
||||
SKIP
|
||||
SKIP
|
||||
SKIP)
|
||||
|
||||
pkgver() {
|
||||
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
package() {
|
||||
install -vDm755 porkbun-ddns.py "$pkgdir/usr/bin/porkbun-ddns"
|
||||
install -vDm600 config.json.example "$pkgdir/etc/porkbun-ddns.json"
|
||||
install -vDm644 systemd.service "$pkgdir/usr/lib/systemd/system/porkbun-ddns.service"
|
||||
install -vDm644 systemd.timer "$pkgdir/usr/lib/systemd/system/porkbun-ddns.timer"
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
{ "endpoint":"https://api-ipv4.porkbun.com/api/json/v3",
|
||||
{
|
||||
"domain": "",
|
||||
"apikey": "",
|
||||
"secretapikey": ""
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ def main(args):
|
|||
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
|
||||
)
|
||||
parser.add_argument("config", nargs=1, help="path to config file")
|
||||
parser.add_argument("domain", nargs=1, help="domain to be updated")
|
||||
parser.add_argument("domain", nargs="?", default="", help="domain to be updated")
|
||||
parser.add_argument("subdomain", nargs="?", default="", help="optional subdomain")
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
|
@ -70,19 +70,30 @@ def main(args):
|
|||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
args.domain, args.config = args.domain[0], args.config[0]
|
||||
args.fqdn = "{}.{}".format(args.subdomain, args.domain).strip(".")
|
||||
args.config = args.config[0]
|
||||
|
||||
try:
|
||||
with sys.stdin if args.config == "-" else open(args.config) as file_:
|
||||
args.cfg = json.load(file_)
|
||||
except Exception as e:
|
||||
err(e)
|
||||
|
||||
# Load domain from JSON config file if not specified as an arg
|
||||
if args.domain == "":
|
||||
args.domain = args.cfg["domain"]
|
||||
if args.subdomain == "" and "subdomain" in args.cfg:
|
||||
args.subdomain = args.cfg["subdomain"]
|
||||
|
||||
args.fqdn = "{}.{}".format(args.subdomain, args.domain).strip(".")
|
||||
|
||||
required = ["secretapikey", "apikey"]
|
||||
if any(x not in args.cfg for x in required) or not isinstance(args.cfg, dict):
|
||||
err("all of the following are required in '{}': {}", args.config, required)
|
||||
args.cfg.setdefault("endpoint", "https://porkbun.com/api/json/v3/")
|
||||
|
||||
if not args.public_ip and "public_ip" in args.cfg:
|
||||
args.public_ip = args.cfg["public_ip"]
|
||||
|
||||
if not args.public_ip:
|
||||
args.public_ip = api(args, "/ping/")["yourIp"]
|
||||
args.public_ip = ipaddress.ip_address(args.public_ip)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[Unit]
|
||||
Description=Detect external IP address and create/update a corresponding DNS record
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/porkbun-ddns /etc/porkbun-ddns.json
|
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Detect external IP address and create/update a corresponding DNS record every 15 minutes
|
||||
|
||||
[Timer]
|
||||
OnBootSec=15min
|
||||
OnUnitActiveSec=15min
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Reference in New Issue