From c7d5220cabb6b67862e1bfa188c07e0d3821a294 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Tue, 7 Aug 2012 14:44:50 -0500 Subject: dnsmasq 2.62 --- abs/extra/dnsmasq/PKGBUILD | 58 +++++++++++++++++++++++---------------- abs/extra/dnsmasq/dnsmasq.confd | 9 ++++++ abs/extra/dnsmasq/dnsmasq.install | 21 ++++++++++++++ abs/extra/dnsmasq/dnsmasq.service | 13 +++++++++ abs/extra/dnsmasq/rc.dnsmasq | 58 +++++++++++++++++++++++++++++---------- 5 files changed, 120 insertions(+), 39 deletions(-) create mode 100644 abs/extra/dnsmasq/dnsmasq.confd create mode 100644 abs/extra/dnsmasq/dnsmasq.install create mode 100644 abs/extra/dnsmasq/dnsmasq.service diff --git a/abs/extra/dnsmasq/PKGBUILD b/abs/extra/dnsmasq/PKGBUILD index f888ccd..1fd617d 100644 --- a/abs/extra/dnsmasq/PKGBUILD +++ b/abs/extra/dnsmasq/PKGBUILD @@ -1,41 +1,51 @@ -# $Id: PKGBUILD 66607 2010-02-01 01:42:17Z giovanni $ -# Maintainer: Paul Mattal +# $Id: PKGBUILD 160917 2012-06-07 00:05:24Z dreisner $ +# Maintainer: Dave Reisner +# Contributor: Paul Mattal # Contributor: Tom Newsom pkgname=dnsmasq -pkgver=2.55 +pkgver=2.62 pkgrel=1 pkgdesc="Lightweight, easy to configure DNS forwarder and DHCP server" url="http://www.thekelleys.org.uk/dnsmasq/doc.html" arch=('i686' 'x86_64') license=('GPL') -depends=('glibc' 'bash') -makedepends=('libcap>=2.16') -backup=('etc/dnsmasq.conf') -install= -source=("http://www.thekelleys.org.uk/$pkgname/$pkgname-$pkgver.tar.gz" - 'rc.dnsmasq') +depends=('glibc' 'dbus-core') +install=$pkgname.install +backup=('etc/dnsmasq.conf' + 'etc/conf.d/dnsmasq') +source=("http://www.thekelleys.org.uk/$pkgname/$pkgname-$pkgver.tar.gz" + 'dnsmasq.confd' + 'rc.dnsmasq' + 'dnsmasq.service') +md5sums=('f47e5cb8f5bac6343f24b2dbe317ab40' + '66479e99123faeab83ebaed709ef95b5' + '819fbdf6440d710616e6df5f8ca9cdba' + '631d8349acbed1b01d4e11d9f42fdb7d') build() { - cd $srcdir/$pkgname-$pkgver + cd "$pkgname-$pkgver" - # Build - make || return 1 + # link against dbus. this ugliness is needed to ensure that the + # compile time opts report properly on startup. yuck. + sed -i '/^#ifdef DNSMASQ_COMPILE_OPTS/ { + i#define HAVE_DBUS + }' src/config.h - # Install - install -d $pkgdir/etc/rc.d || return 1 - make PREFIX=/usr DESTDIR=$pkgdir install || return 1 + make +} + +package() { + cd "$pkgname-$pkgver" + + make BINDIR=/usr/bin PREFIX=/usr DESTDIR="$pkgdir" install - install -D -m755 \ - $srcdir/rc.dnsmasq $pkgdir/etc/rc.d/dnsmasq || return 1 - install -D -m644 \ - dnsmasq.conf.example $pkgdir/etc/dnsmasq.conf || return 1 + install -Dm755 "$srcdir"/rc.dnsmasq "$pkgdir"/etc/rc.d/dnsmasq + install -Dm644 "$srcdir"/dnsmasq.confd "$pkgdir/etc/conf.d/dnsmasq" - # Make the Required Directories for DHCP Server Default Directories - install -d $pkgdir/var/db || return 1 - install -d $pkgdir/var/lib/misc || return 1 + install -Dm644 "dbus/dnsmasq.conf" "$pkgdir"/etc/dbus-1/system.d/dnsmasq.conf + install -Dm644 "dnsmasq.conf.example" "$pkgdir"/etc/dnsmasq.conf + install -Dm644 "$srcdir/dnsmasq.service" "$pkgdir"/usr/lib/systemd/system/dnsmasq.service } # vim: ts=2 sw=2 et ft=sh -md5sums=('b093d7c6bc7f97ae6fd35d048529232a' - 'e956eee1ec24212a3254d2b168187495') diff --git a/abs/extra/dnsmasq/dnsmasq.confd b/abs/extra/dnsmasq/dnsmasq.confd new file mode 100644 index 0000000..933b928 --- /dev/null +++ b/abs/extra/dnsmasq/dnsmasq.confd @@ -0,0 +1,9 @@ +# +# runtime config for dnsmasq +# + +# if unset, dnsmasq will run as nobody. +DNSMASQ_USER=dnsmasq + +# other runtime options. treated as an array. +DNSMASQ_OPTS=() diff --git a/abs/extra/dnsmasq/dnsmasq.install b/abs/extra/dnsmasq/dnsmasq.install new file mode 100644 index 0000000..c2edb7d --- /dev/null +++ b/abs/extra/dnsmasq/dnsmasq.install @@ -0,0 +1,21 @@ +#!/bin/sh + +add_dnsmasq_user() { + if ! getent passwd dnsmasq >/dev/null; then + useradd -r -d / -c 'dnsmasq daemon' -s /sbin/nologin dnsmasq + fi +} + +post_install() { + add_dnsmasq_user +} + +post_upgrade() { + add_dnsmasq_user +} + +post_remove() { + if getent passwd dnsmasq >/dev/null; then + userdel dnsmasq + fi +} diff --git a/abs/extra/dnsmasq/dnsmasq.service b/abs/extra/dnsmasq/dnsmasq.service new file mode 100644 index 0000000..05a1f0b --- /dev/null +++ b/abs/extra/dnsmasq/dnsmasq.service @@ -0,0 +1,13 @@ +[Unit] +Description=A lightweight DHCP and caching DNS server + +[Service] +Type=dbus +BusName=uk.org.thekelleys.dnsmasq +ExecStartPre=/usr/bin/dnsmasq --test +ExecStart=/usr/bin/dnsmasq -k --enable-dbus --user=dnsmasq --pid-file +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target +Alias=dbus-uk.org.thekelleys.dnsmasq diff --git a/abs/extra/dnsmasq/rc.dnsmasq b/abs/extra/dnsmasq/rc.dnsmasq index 1676072..4030c28 100755 --- a/abs/extra/dnsmasq/rc.dnsmasq +++ b/abs/extra/dnsmasq/rc.dnsmasq @@ -2,35 +2,63 @@ . /etc/rc.conf . /etc/rc.d/functions +. /etc/conf.d/dnsmasq -PID=`pidof -o %PPID /usr/sbin/dnsmasq` -case "$1" in +checkconfig() { + local testout + + if ! testout=$(/usr/bin/dnsmasq --test 2>&1); then + echo "$testout" + return 1 + fi + + return 0 +} + +pidfile=/run/dnsmasq.pid +if [[ -r $pidfile ]]; then + read -r PID < "$pidfile" + if [[ ! -d /proc/$PID ]]; then + # stale pidfile + unset PID + rm -f "$pidfile" + fi +fi + +case $1 in start) stat_busy "Starting DNS/DHCP daemon" - [ -z "$PID" ] && /usr/sbin/dnsmasq - if [ $? -gt 0 ] ; then - stat_fail + if [[ -z $PID ]] && checkconfig && + /usr/bin/dnsmasq "--user=${DNSMASQ_USER:-nobody}" \ + "--pid-file=$pidfile" \ + "${DNSMASQ_OPTS[@]}"; then + add_daemon dnsmasq + stat_done else - add_daemon dnsmasq # create the 'state' dir - stat_done + stat_fail fi ;; stop) stat_busy "Stopping DNS/DHCP daemon" - [ "$PID" ] && kill $PID &> /dev/null - if [ $? -gt 0 ]; then - stat_fail - else - rm_daemon dnsmasq # remove the 'state' dir + if [[ $PID ]] && kill "$PID" &> /dev/null; then + # dnsmasq doesn't clean up after itself + rm -f "$pidfile" + rm_daemon dnsmasq stat_done + else + stat_fail fi ;; restart) $0 stop - sleep 5 + sleep 1 $0 start ;; + checkconfig) + # diagnostics will be printed, with zero/non-zero exit + /usr/bin/dnsmasq --test + ;; *) - echo "usage: $0 {start|stop|restart}" + echo "usage: $0 " esac -exit 0 + -- cgit v0.12