diff options
author | Chris Severance | 2015-09-01 19:58:34 -0400 |
---|---|---|
committer | Chris Severance | 2015-09-01 19:58:34 -0400 |
commit | 62f45c160a78577abc2bf53965e83155826029ec (patch) | |
tree | 37ad192ba97d4eae38aa7d6949bb8a43feae84f9 | |
parent | 1f3c04df42806dc0b556b6de3f1383e70d9df2f3 (diff) | |
download | aur-62f45c160a78577abc2bf53965e83155826029ec.tar.gz |
Update to 0.2.1
-rw-r--r-- | .AURINFO | 16 | ||||
-rw-r--r-- | .SRCINFO | 13 | ||||
-rw-r--r--[-rwxr-xr-x] | PKGBUILD | 155 | ||||
-rw-r--r-- | update-dnsomatic.install | 50 |
4 files changed, 165 insertions, 69 deletions
diff --git a/.AURINFO b/.AURINFO deleted file mode 100644 index b2016e2e7d0f..000000000000 --- a/.AURINFO +++ /dev/null @@ -1,16 +0,0 @@ -pkgbase = update-dnsomatic - pkgdesc = A perl based utility that updates OpenDNS via crontab, and is simpler than inyadn - pkgver = 0.2.0 - pkgrel = 3 - url = http://prawnuk.blogspot.com/2008/11/dnsomatic-updater.html - arch = i686 - arch = x86_64 - license = GPL - depends = perl - depends = perl-libwww - depends = perl-crypt-ssleay - depends = perl-lwp-protocol-https - source = http://update-dnsomatic.googlecode.com/files/update-dnsomatic-0.2.0.tar.gz - -pkgname = update-dnsomatic - @@ -1,8 +1,9 @@ pkgbase = update-dnsomatic - pkgdesc = A perl based utility that updates OpenDNS via crontab, and is simpler than inyadn - pkgver = 0.2.0 - pkgrel = 3 + pkgdesc = A perl utility that updates OpenDNS DNS-O-Matic, and is simpler than inyadn + pkgver = 0.2.1 + pkgrel = 1 url = http://prawnuk.blogspot.com/2008/11/dnsomatic-updater.html + install = update-dnsomatic.install arch = i686 arch = x86_64 license = GPL @@ -10,8 +11,10 @@ pkgbase = update-dnsomatic depends = perl-libwww depends = perl-crypt-ssleay depends = perl-lwp-protocol-https - source = http://update-dnsomatic.googlecode.com/files/update-dnsomatic-0.2.0.tar.gz - md5sums = d6688165372ce1a8cc57b879713903a2 + optdepends = cron: use cron instead of systemd timers + backup = etc/update-dnsomatic/config + source = http://update-dnsomatic.googlecode.com/files/update-dnsomatic-0.2.1.tar.gz + sha256sums = e4b44ffc8caf1114464ca2ae7a925ca06b632379befa88ac39e36c09253a4715 pkgname = update-dnsomatic diff --git a/PKGBUILD b/PKGBUILD index c9e5ee4362b2..c97e388080c6 100755..100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,55 +1,114 @@ +# Maintainer: Chris Severance aur.severach aATt spamgourmet dott com # Contributor: Matt Parnell <parwok@gmail.com> -pkgname=update-dnsomatic -pkgver=0.2.0 -pkgrel=3 -pkgdesc="A perl based utility that updates OpenDNS via crontab, and is simpler than inyadn" -arch=(i686 x86_64) -url="http://prawnuk.blogspot.com/2008/11/dnsomatic-updater.html" +# 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 big 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='http://prawnuk.blogspot.com/2008/11/dnsomatic-updater.html' # Seán Doher license=('GPL') -groups=() depends=('perl' 'perl-libwww' 'perl-crypt-ssleay' 'perl-lwp-protocol-https') -makedepends=() -provides=() -conflicts=() -replaces=() -backup=() -source=(http://update-dnsomatic.googlecode.com/files/$pkgname-$pkgver.tar.gz) -noextract=() -md5sums=('d6688165372ce1a8cc57b879713903a2') - -prepare() -{ - cd "$srcdir/$pkgname-$pkgver" - msg "You must insert your OpenDNS username and password. Opening...make sure to save." - - sleep 2 - - # If you don't have either of these you really shouldn't be using linux - if [ -x /usr/bin/vi ] - then vi config || return 1 - else - nano config || return 1 - fi -} +optdepends=('cron: use cron instead of systemd timers') +backup='etc/update-dnsomatic/config' +source=("http://update-dnsomatic.googlecode.com/files/${pkgname}-${pkgver}.tar.gz") +sha256sums=('e4b44ffc8caf1114464ca2ae7a925ca06b632379befa88ac39e36c09253a4715') +install="${pkgname}.install" -build() -{ - return 0 -} +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 +# http://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 +# http://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" -package() -{ - cd "$srcdir/$pkgname-$pkgver" - - mkdir ${pkgdir}/etc - mkdir ${pkgdir}/etc/update-dnsomatic - mkdir ${pkgdir}/usr/ - mkdir ${pkgdir}/usr/bin/ - - install -m600 config ${pkgdir}/etc/update-dnsomatic/config - install -m700 update-dnsomatic ${pkgdir}/usr/bin/update-dnsomatic - - msg "Done!...now just add it to the crontab." - msg "Sample to update every 10 minutes: */10 * * * * /usr/local/bin/update-dnsomatic" + set +u } +set +u diff --git a/update-dnsomatic.install b/update-dnsomatic.install new file mode 100644 index 000000000000..afdf9a07cc34 --- /dev/null +++ b/update-dnsomatic.install @@ -0,0 +1,50 @@ +pre_upgrade() { + local _myip='/etc/update-dnsomatic/myip' + if [ -s "${_myip}" ]; then + mv "${_myip}" "${_myip}.pacsave" + fi +} + +post_upgrade() { + local _myip='/etc/update-dnsomatic/myip' + if [ -s "${_myip}.pacsave" ] && [ ! -s "${_myip}" ]; then + mv "${_myip}.pacsave" "${_myip}" + fi + rm -f "${_myip}.pacsave" + chmod 664 "${_myip}" + systemctl daemon-reload + local _config='/etc/update-dnsomatic/config' + # It would be safer to create our own user but it's easier just to use nobody + chown -R 'root:nobody' "$(dirname "${_config}")" '/usr/bin/update-dnsomatic' + chmod 640 "${_config}" + echo + if [ ! -s "${_config}" ] || grep -q '^user = userid$\|^npass = password$' "${_config}"; then + echo "Add your OpenDNS username and password to ${_config}" + fi + if ! crontab -l 2>/dev/null | grep -q '/usr/bin/update-dnsomatic' && ! systemctl -q is-enabled 'update-dnsomatic.timer'; then + echo 'crontab example to update every 10 minutes:' + echo ' */10 * * * * /usr/bin/update-dnsomatic > /dev/null 2>&1' + echo + echo 'systemd timer example:' + echo 'If desired, change time in usr/lib/systemd/system/update-dnsomatic.timer' + echo " systemctl enable 'update-dnsomatic.timer'" + echo " systemctl start 'update-dnsomatic.timer'" + fi + if systemctl -q is-enabled 'update-dnsomatic.timer'; then + systemctl start 'update-dnsomatic.timer' + fi +} + +post_install() { + post_upgrade +} + +pre_remove() { + if systemctl -q is-enabled 'update-dnsomatic.timer'; then + systemctl stop 'update-dnsomatic.timer' + fi +} + +post_remove() { + systemctl daemon-reload +} |