# Maintainer: Chris Severance aur.severach aATt spamgourmet dott com # Contributor: Matt Parnell # BUG: So far as I can tell updating multiple hosts with a single request is no longer supported by the DNS-O-Matic service. # The code could be updated to put out a separate request for each host. This is a bit more than sed can do. # Future BUG: When multiple hosts is implemented, don't wait for IP to change when new hosts are added. # Until this is fixed server connections are not attempted when multiple hosts are specified. # FIXED: The interactive stuff in the old PKGBUILD has been moved to install # FIXED: Connections are not be attempted for default user = userid or password = password # FIXED: Launches with cron as root or systemd timer as user nobody # TODO: Implement IP change log # TODO: Implement all Dynamic DNS services including DNS-O-Matic. # TODO: Add version to config so we can discard it on same version upgrades and installs. # TODO: Add settings promotion to new config files. # TODO: Better variable detection in config (I suspect blank lines aren't handled well) # If upgrading from an old version you might get a file conflict # update-dnsomatic: /etc/update-dnsomatic/myip exists in filesystem # To solve # sudo mv /etc/update-dnsomatic/myip /etc/update-dnsomatic/myip.pacsave # Starting out it's hard to tell what to put in for myhost. In your DNS-O-Matic account screen you see # Service # username :: myhost # For OpenDNS myhost is just a phrase like Home, Office, or Gramma set -u pkgname='update-dnsomatic' pkgver='0.2.1' pkgrel='1' pkgdesc='A perl utility that updates OpenDNS DNS-O-Matic, and is simpler than inyadn' arch=('i686' 'x86_64') #url='https://github.com/rivy/update-dnsomatic' #url='http://prawnuk.blogspot.com/2008/11/dnsomatic-updater.html' # Seán Doher url='https://code.google.com/archive/p/update-dnsomatic/downloads' license=('GPL') depends=('perl' 'perl-libwww' 'perl-crypt-ssleay' 'perl-lwp-protocol-https') optdepends=('cron: use cron instead of systemd timers') backup=('etc/update-dnsomatic/config') install="${pkgname}.install" #source=("http://update-dnsomatic.googlecode.com/files/${pkgname}-${pkgver}.tar.gz") source=("https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/update-dnsomatic/update-dnsomatic-${pkgver}.tar.gz") md5sums=('3710f7a927e79d0d35bc5b4fcc03b31b') sha256sums=('e4b44ffc8caf1114464ca2ae7a925ca06b632379befa88ac39e36c09253a4715') package() { set -u cd "${pkgname}-${pkgver}" install -Dpm640 'config' -t "${pkgdir}/etc/update-dnsomatic/" chmod 775 "${pkgdir}/etc/update-dnsomatic/" # This lets pacman -Qo show us as the owner of this file. It also lets pacman delete this file. install -Dm664 /dev/null "${pkgdir}/etc/update-dnsomatic/myip" install -Dpm754 'update-dnsomatic' -t "${pkgdir}/usr/bin/" local _codedouble=' use Getopt::Long; my $arg_daemon=0; if (!GetOptions ( "daemon" => \$arg_daemon ) or @ARGV > 0) { die("$0: Invalid command line options: @ARGV\n"); }' _codedouble="$(echo "${_codedouble}" | sed -e 's:\\:\\\\:g' | tr '\n' '\r' | sed -e 's:\r:\\n:g')" # escape \n for sed replacement # Fix permissions sed -i -e '# Fix permissions on new file creation for systemd to run as nobody' \ -e 's:^sub write_new_ip {$:&\n umask 0002;:g' \ -e '# Fix some horrible spacing' \ -e 's:\s\+$::g' \ -e '# Block unsupported multiple hosts rather than spam the servers' \ -e '# Prevent spamming servers with blank or default userid:password' \ -e 's:^\(\s\+\)close(CONFIG);$:&\n\1if (index($config{myhost}, ",") >= 0) {\n\1\1write_log("err", "Multiple myhost is not supported by DNS-O-Matic. Fix /etc/update-dnsomatic/config");\n\1\1exit(1);\n\1}\n\1if (!$config{user} or !$config{pass} or $config{user} eq "userid" or $config{pass} eq "password") {\n\1\1write_log("err", "User and pass must be set in /etc/update-dnsomatic/config");\n\1\1exit(1);\n\1}:g' \ -e '# getopts code for doubled log entries in systemctl status update-dnsomatic.service' \ -e 's/^use Sys::Syslog;$'"/&${_codedouble}/g" \ -e '# Stop doubled log entries' \ -e 's:^\(\s\+print "\$msg\\n"\);$:\1 if (!$arg_daemon);:g' \ "${pkgdir}/usr/bin/update-dnsomatic" unset _codedouble install -Dm644 <(cat << EOF # Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR # https://aur.archlinux.org/ [Unit] Description=OpenDNS DNS-O-Matic updater ${pkgname} [Timer] OnBootSec=5min OnCalendar=*:0/10 Persistent=true [Install] WantedBy=multi-user.target EOF ) "${pkgdir}/usr/lib/systemd/system/${pkgname}.timer" install -Dm644 <(cat << EOF # Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR # https://aur.archlinux.org/ [Unit] Description=OpenDNS DNS-O-Matic updater ${pkgname} [Service] Type=oneshot ExecStart=/usr/bin/update-dnsomatic --daemon Nice=19 IOSchedulingClass=best-effort IOSchedulingPriority=7 User=nobody Group=nobody EOF ) "${pkgdir}/usr/lib/systemd/system/${pkgname}.service" set +u } set +u