diff --git a/Packaging/.gitignore b/Packaging/.gitignore new file mode 100644 index 0000000..aa5b27f --- /dev/null +++ b/Packaging/.gitignore @@ -0,0 +1,3 @@ +pkg/ +src/ +example.toml \ No newline at end of file diff --git a/Packaging/PKGBUILD b/Packaging/PKGBUILD new file mode 100644 index 0000000..ad519aa --- /dev/null +++ b/Packaging/PKGBUILD @@ -0,0 +1,51 @@ +# Maintainer: Kaan Genc + +pkgname=gandi-live-dns +pkgver=1.0.1 +pkgrel=1 +pkgdesc="Automatically updates your IP address for Gandi's Live DNS." +_repo_path="SeriousBug/gandi-live-dns-rust" +url="https://github.com/${_repo_path}" +license=('MIT') +install="gandi-live-dns.install" +arch=('x86_64' 'armv6h' 'armv7h' 'aarch64') +backup=("etc/gandi-live-dns/gandi.conf") +depends=() # Dependency free + + +source=( + "https://raw.githubusercontent.com/${_repo_path}/${pkgver}/example.toml" + "gandi-live-dns.service" + "gandi-live-dns.timer" + "gandi-live-dns.sysusers" +) +_source_common="${url}/releases/download/${pkgver}/${pkgname}.${pkgver}.linux" +source_x86_64=("${_source_common}-x86_64.tar.xz") +source_armv6h=("${_source_common}-armv6.tar.xz") +source_armv7h=("${_source_common}-armv7.tar.xz") +source_aarch64=("${_source_common}-arm64.tar.xz") + + +package() { + # Install service files + install -Dm644 gandi-live-dns.service "${pkgdir}/usr/lib/systemd/system/gandi-live-dns.service" + install -Dm644 gandi-live-dns.timer "${pkgdir}/usr/lib/systemd/system/gandi-live-dns.timer" + install -Dm644 gandi-live-dns.sysusers "${pkgdir}/usr/lib/sysusers.d/gandi-live-dns.conf" + + # Add the example config + mkdir -m600 -p "${pkgdir}/etc/gandi-live-dns" + install -Dm600 example.toml "${pkgdir}/etc/gandi-live-dns/example.toml" + + # Install the program itself + install -Dm755 gandi-live-dns "${pkgdir}/usr/bin/gandi-live-dns" +} + + +sha256sums=('4f9dd02e0e03fd838081c3a8dd88b386411204853399f78fa83e8781271a012f' + '7ae1a8fa18e0ef41aa42c94b4a364fdab0a6c9520cbea486f8c9c7f5da22e88f' + 'cd3b1ab682d421e8b9f230d9f44c07a9afe54ce12e55a2990fcbe606e4ccb9a3' + 'a0e652bf8fd879dcbb96488322cac572346fa9a1dbbc2cac08b94b12d9629128') +sha256sums_x86_64=('75afe5409f4e98b91ef5966fbf6e2bfdeaccb299c2ccd35e722606ed0779c9f0') +sha256sums_armv6h=('cc8465bc0a8d1de0bbb1817071d5aadce5a30287e8a7f6f357180559cddbd78d') +sha256sums_armv7h=('95f80dd4fab25b4e6aeb4278e4b19255277000515d1ffacc03189c162b0c3b5c') +sha256sums_aarch64=('df5c93303707ff60a015da4548f80218978247c886152b2f59b8509826245c34') diff --git a/Packaging/gandi-live-dns.install b/Packaging/gandi-live-dns.install new file mode 100644 index 0000000..6f50552 --- /dev/null +++ b/Packaging/gandi-live-dns.install @@ -0,0 +1,4 @@ +post_install() { + systemd-sysusers gandi-live-dns.conf + chown -R gandi-live-dns:gandi-live-dns /etc/gandi-live-dns +} \ No newline at end of file diff --git a/Packaging/gandi-live-dns.service b/Packaging/gandi-live-dns.service new file mode 100644 index 0000000..24c9021 --- /dev/null +++ b/Packaging/gandi-live-dns.service @@ -0,0 +1,14 @@ +[Unit] +Description=Automatically updates your IP adress with Gandi LiveDNS. +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/gandi-live-dns +User=gandi-live-dns +Group=gandi-live-dns +WorkingDirectory=/etc/gandi-live-dns/ + +[Install] +WantedBy=multi-user.target diff --git a/Packaging/gandi-live-dns.sysusers b/Packaging/gandi-live-dns.sysusers new file mode 100644 index 0000000..a0a1ea2 --- /dev/null +++ b/Packaging/gandi-live-dns.sysusers @@ -0,0 +1 @@ +u gandi-live-dns - "Gandi LiveDNS updater" /etc/gandi-live-dns \ No newline at end of file diff --git a/Packaging/gandi-live-dns.timer b/Packaging/gandi-live-dns.timer new file mode 100644 index 0000000..2e8f9ec --- /dev/null +++ b/Packaging/gandi-live-dns.timer @@ -0,0 +1,11 @@ +[Unit] +Description=Automatically updates your IP adress with Gandi LiveDNS. +Wants=network-online.target + +[Timer] +OnBootSec=1s +OnCalendar=daily +RandomizedDelaySec=10s + +[Install] +WantedBy=timers.target diff --git a/Readme.md b/Readme.md index 7e33e87..0a7a835 100644 --- a/Readme.md +++ b/Readme.md @@ -17,12 +17,10 @@ it in Rust as a learning project. ## Usage -> Warning! -> -> This tool does not rate limit itself, or otherwise do anything that limits how -> often it sends changes to Gandi's servers. It's up to you to use the tool -> properly and avoid abusing Gandi's servers. The tool is one-shot, so all you -> have to do is to avoid running it too often. +> This tool doesn't rate limit itself at the moment. If you have more than 30 +> entries that need to be updated, the operation may hit rate the limit of Gandi +> and fail. You can work around this using multiple config files and waiting at +> least 1 minute between runs. ### Prebuilt binaries @@ -55,6 +53,13 @@ Follow the steps below to use these images. > has a full path to the config file (`$(pwd)/gandi.toml` part). Otherwise > Docker will create a directory. +## Automation + +The `Packaging` folder contains a Systemd service and timer, which you can use +to automatically run this tool. By default it will update the IP addresses after +every boot up, and at least once a day. You can adjust the timer to speed this +up, but avoid unnecessarily overloading Gandi's servers. + ## Development ### Local builds diff --git a/make-release.sh b/make-release.sh index 95affb8..a83a294 100755 --- a/make-release.sh +++ b/make-release.sh @@ -7,6 +7,7 @@ # If you have rootless docker set up, remove sudo from this variable. DOCKER="sudo docker" # +shopt -s extglob # Trap errors and interrupts set -Eeuo pipefail function handle_sigint() { @@ -50,12 +51,18 @@ for target in "${!TARGETS[@]}"; do echo Building "${target}" cross build -j $(($(nproc) / 2)) --release --target "${target}" if [[ "${target}" =~ .*"windows".* ]] ; then - 7z a -tzip "gandi-live-dns.${VERSION}.${TARGETS[${target}]}.zip" target/"${target}"/release/gandi-live-dns.exe 1>/dev/null + zip -j "gandi-live-dns.${VERSION}.${TARGETS[${target}]}.zip" target/"${target}"/release/gandi-live-dns.exe 1>/dev/null else - tar -acf "gandi-live-dns.${VERSION}.${TARGETS[${target}]}.tar.xz" target/"${target}"/release/gandi-live-dns + tar -acf "gandi-live-dns.${VERSION}.${TARGETS[${target}]}.tar.xz" -C "target/${target}/release/" "gandi-live-dns" fi done +if [[ "$1" = "--no-docker" ]] ; then + echo "Exiting without releasing to docker" + exit 0 +fi + + # Copy files into place so Docker can get them easily cd Docker echo Building Docker images