From a4a3c3269d60960a3cabeb78c4f9c5bf2116843d Mon Sep 17 00:00:00 2001 From: Patrick Laughton Date: Aug 08 2011 21:21:55 +0000 Subject: Applied Jóhann's patch, minor cleanup * Thu Jul 26 2011 Jóhann B. Guðmundsson - 2.52-3 - Introduce systemd unit file, drop SysV support --- diff --git a/dnsmasq.init b/dnsmasq.init deleted file mode 100644 index 81364f7..0000000 --- a/dnsmasq.init +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/sh -# -# Startup script for the DNS caching server -# -# chkconfig: - 49 50 -# description: This script starts your DNS caching server -# processname: dnsmasq -# pidfile: /var/run/dnsmasq.pid - -# Source function library. -. /etc/rc.d/init.d/functions - -# Source networking configuration. -. /etc/sysconfig/network - -# Check that networking is up. -[ ${NETWORKING} = "no" ] && exit 0 - -dnsmasq=/usr/sbin/dnsmasq -[ -f $dnsmasq ] || exit 0 - -DOMAIN_SUFFIX=`dnsdomainname` -if [ ! -z "${DOMAIN_SUFFIX}" ]; then - OPTIONS="-s $DOMAIN_SUFFIX" -fi - -pidfile=${PIDFILE-/var/run/dnsmasq.pid} -lockfile=${LOCKFILE-/var/lock/subsys/dnsmasq} - - -RETVAL=0 - -# See how we were called. -case "$1" in - start) - echo -n "Starting dnsmasq: " - daemon $dnsmasq $OPTIONS - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && touch ${lockfile} - ;; - stop) - echo -n "Shutting down dnsmasq: " - killproc -p ${pidfile} ${dnsmasq} - RETVAL=$? - echo - [ $RETVAL -eq 0 ] && rm -f ${lockfile} ${pidfile} - ;; - status) - status dnsmasq - RETVAL=$? - ;; - reload) - echo -n "Reloading dnsmasq: " - killproc -p ${pidfile} ${dnsmasq} -HUP - RETVAL=$? - echo - ;; - restart) - $0 stop - $0 start - RETVAL=$? - ;; - condrestart) - if test "x`pidfileofproc dnsmasq`" != x; then - $0 stop - $0 start - RETVAL=$? - fi - ;; - *) - echo "Usage: $0 {start|stop|restart|reload|condrestart|status}" - exit 1 -esac - -exit $RETVAL - diff --git a/dnsmasq.spec b/dnsmasq.spec index 7fb794d..e5b50e7 100644 --- a/dnsmasq.spec +++ b/dnsmasq.spec @@ -11,24 +11,24 @@ Name: dnsmasq Version: 2.52 -Release: 2%{?extraversion}%{?dist} +Release: 3%{?extraversion}%{?dist} Summary: A lightweight DHCP/caching DNS server Group: System Environment/Daemons License: GPLv2 or GPLv3 URL: http://www.thekelleys.org.uk/dnsmasq/ Source0: http://www.thekelleys.org.uk/dnsmasq/%{?extrapath}%{name}-%{version}%{?extraversion}.tar.lzma -Source1: %{name}.init +Source1: %{name}.service BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: dbus-devel BuildRequires: pkgconfig -Requires(post): chkconfig -Requires(preun): chkconfig -# This is for /sbin/service -Requires(preun): initscripts -Requires(post): initscripts +BuildRequires: systemd-units +Requires(post): systemd-units systemd-sysv chkconfig +Requires(preun): systemd-units +Requires(postun): systemd-units + %description Dnsmasq is lightweight, easy to configure DNS forwarder and DHCP server. @@ -71,40 +71,40 @@ mkdir -p $RPM_BUILD_ROOT%{_sbindir} \ install src/dnsmasq $RPM_BUILD_ROOT%{_sbindir}/dnsmasq install dnsmasq.conf.example $RPM_BUILD_ROOT%{_sysconfdir}/dnsmasq.conf install dbus/dnsmasq.conf $RPM_BUILD_ROOT%{_sysconfdir}/dbus-1/system.d/ -install -Dp -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/dnsmasq install -m 644 man/dnsmasq.8 $RPM_BUILD_ROOT%{_mandir}/man8/ +# Systemd +mkdir -p %{buildroot}%{_unitdir} +install -m644 %{SOURCE1} %{buildroot}%{_unitdir} +rm -rf %{buildroot}%{_initrddir} + %clean rm -rf $RPM_BUILD_ROOT %post -if [ "$1" = "2" ]; then # if we're being upgraded - # if using the old leases location, move the file to the new one - # but only if we're not clobbering another file - # - if [ -f /var/lib/misc/dnsmasq.leases -a ! -f /var/lib/dnsmasq/dnsmasq.leases ]; then - # causes rpmlint to report dangerous-command-in-post, - # but that's the price of selinux compliance :-( - mv -f /var/lib/misc/dnsmasq.leases /var/lib/dnsmasq/dnsmasq.leases || : - fi - # ugly, but kind of necessary - if [ ! `grep -q dhcp-leasefile=/var/lib/misc/dnsmasq.leases %{_sysconfdir}/dnsmasq.conf` ]; then - cp %{_sysconfdir}/dnsmasq.conf %{_sysconfdir}/dnsmasq.conf.tmp || : - sed -e 's/var\/lib\/misc/var\/lib\/dnsmasq/' < %{_sysconfdir}/dnsmasq.conf.tmp > %{_sysconfdir}/dnsmasq.conf || : - rm -f %{_sysconfdir}/dnsmasq.conf.tmp || : - fi - /sbin/service dnsmasq condrestart >/dev/null 2>&1 || : -else # if we're being installed - /sbin/chkconfig --add dnsmasq +if [ $1 -eq 1 ] ; then + /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi %preun -if [ "$1" = "0" ]; then # execute this only if we are NOT doing an upgrade - /sbin/service dnsmasq stop >/dev/null 2>&1 || : - /sbin/chkconfig --del dnsmasq +if [ $1 -eq 0 ]; then + /bin/systemctl --no-reload dnsmasq.service > /dev/null 2>&1 || : + /bin/systemctl stop dnsmasq.service > /dev/null 2>&1 || : fi +%postun +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ] ; then + /bin/systemctl try-restart dnsmasq.service >/dev/null 2>&1 || : +fi + +%triggerun -- dnsmasq < 2.52-3 +%{_bindir}/systemd-sysv-convert --save dnsmasq >/dev/null 2>&1 ||: +/bin/systemctl enable dnsmasq.service >/dev/null 2>&1 +/sbin/chkconfig --del dnsmasq >/dev/null 2>&1 || : +/bin/systemctl try-restart dnsmasq.service >/dev/null 2>&1 || : + %files %defattr(-,root,root,-) %doc CHANGELOG COPYING FAQ doc.html setup.html dbus/DBus-interface @@ -112,12 +112,18 @@ fi %dir /etc/dnsmasq.d %dir %{_var}/lib/dnsmasq %config(noreplace) %attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/dnsmasq.conf -%{_initrddir}/dnsmasq +%{_unitdir}/%{name}.service %{_sbindir}/dnsmasq %{_mandir}/man8/dnsmasq* %changelog +* Mon Aug 08 2011 Patrick "Jima" Laughton - 2.52-3 +- Applied Jóhann's patch, minor cleanup + +* Thu Jul 26 2011 Jóhann B. Guðmundsson - 2.52-3 +- Introduce systemd unit file, drop SysV support + * Tue Feb 08 2011 Fedora Release Engineering - 2.52-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild