File ddclient.spec of Package ddclient

# spec file for package ddclient
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir /var/adm/fillup-templates

Name:           ddclient
Summary:        A Perl Client to Update Dynamic DNS Entries
License:        GPL-2.0+
Group:          Productivity/Networking/DNS/Utilities
Version:        3.8.3
Release:        0
Source1:        %{name}.service
Source2:        %{name}.sysconfig
Source3:        %{name}-tmpfiles.conf
Source4:        rc.%{name}
Patch0:         %{name}-3.8.1-config.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
Requires(pre):  %fillup_prereq
Requires(pre):  pwdutils

%if 0%{?suse_version} >= 1230
BuildRequires:  pkgconfig(systemd)
%define has_systemd 1

Requires:       perl >= 5.004
Recommends:     perl-IO-Socket-SSL

ddclient is a small full-featured client requiring only Perl. Supported
features include daemon operation, manual and automatic updates, static
and dynamic updates, optimized updates for multiple addresses, MX, wild
cards, abuse avoidance, retry for failed updates, and status updates to
syslog and through e-mail. ddclient can obtain the IP address from any
interface, through a Web-based IP detection service, and for multiple
routers using custom FW definitions. It also provides full support for's NIC2 protocol. Support is also included for other dynamic
DNS services. Comes with sample scripts for use with DHCP, PPP, and

rm -f sample-etc_ddclient.conf.orig
chmod a-x sample-*
mkdir examples
mv sample-* examples

# If the package provides automatic testing
#make test
# nothing to do here (yet)

#%{_sbindir}/groupadd -r %{name} 2>/dev/null || :
#%{_sbindir}/useradd -c "DDClient User" -d %{_localstatedir}/cache/%{name} \
#  -g %{name} -r -s /bin/false %{name} 2>/dev/null || :

%{__install} -D -m 755 %{name} %{buildroot}%{_sbindir}/%{name}
%{__install} -D -m 600 examples/sample-etc_ddclient.conf %{buildroot}%{_sysconfdir}/%{name}.conf
%if 0%{?has_systemd}
%{__sed} -i -e "s,/var/run/,/run/%{name}/," %{buildroot}%{_sysconfdir}/%{name}.conf
%{__sed} -i -e "s,/var/run/,/var/run/%{name}/," %{buildroot}%{_sysconfdir}/%{name}.conf
# init script and config file
%if 0%{?has_systemd}
%{__install} -D -m 644 %{SOURCE1} %{buildroot}/%{_unitdir}/%{name}.service
%{__install} -D -m 644 %{SOURCE3} %{buildroot}%{_libexecdir}/tmpfiles.d/%{name}.conf
%{__ln_s} %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
%{__install} -D -m 755 %{SOURCE4} %{buildroot}%{_sysconfdir}/init.d/%{name}
%{__ln_s} %{_sysconfdir}/init.d/%{name} %{buildroot}%{_sbindir}/rc%{name}
%{__install} -d -m 755 %{buildroot}%{_fillupdir}
%{__install} -m 644 %{SOURCE2} %{buildroot}%{_fillupdir}/sysconfig.%{name}
%{__install} -d -m 755 %{buildroot}/var/cache/%{name}
%if 0%{?has_systemd}
%{__install} -d -m 755 %{buildroot}/run/%{name}
%{__install} -d -m 755 %{buildroot}%{_localstatedir}/run/%{name}

if [[ -z $(%{_bindir}/getent group %{name} 2>/dev/null) ]]; then
  %{_sbindir}/groupadd -r %{name} 2>/dev/null
if [[ -z $(%{_bindir}/getent passwd %{name} 2>/dev/null) ]]; then
  %{_sbindir}/useradd -c "DDClient User" -d %{_localstatedir}/cache/%{name} \
    -g %{name} -r -s /bin/false %{name} 2>/dev/null
%if 0%{?has_systemd}
%service_add_pre %{name}.service
%{__install} -d -m 755 -o %{name} -g root /run/%{name}
%{__install} -d -m 755 -o %{name} -g root %{_localstatedir}/run/%{name}

%if 0%{?has_systemd}
%service_add_post %{name}.service

%if 0%{?has_systemd}
%service_del_preun %{name}.service
%stop_on_removal ddclient

%if 0%{?has_systemd}
%service_del_postun %{name}.service
%restart_on_update ddclient

%defattr(-, root, root)
%doc COPY* README* examples
%config(noreplace) %attr(600,%{name},root) %{_sysconfdir}/%{name}.conf
%if 0%{?has_systemd}
%ghost %dir %attr(755,%{name},root) /run/%{name}
%ghost %dir %attr(755,%{name},root) %{_localstatedir}/run/%{name}
%dir %attr(700,%{name},root) %{_localstatedir}/cache/%{name}

openSUSE Build Service is sponsored by