File submit-ip.spec of Package submit-ip

#
# spec file for package submit-ip
#
# This file and all modifications and additions to the pristine
# package are under the same license as the package itself.
#

%define         submit_ip_user %name
%define         submit_ip_group %name
Name:           submit-ip
Version:        0.2
Release:        1
License:        GPL-2.0-or-later
Summary:        Submit your own IP Address to a remote server via SSH
Url:            http://unknown.org
Group:          System/Monitoring
Source0:        submit-ip.sh
Source1:        submit-ip.sysconfig
Source2:        receive-ip.sh
Source4:        README.SUSE
Source5:        %{name}.timer
Source6:        %{name}.service
Source10:       submit-ip-rpmlintrc
PreReq:         %fillup_prereq
Requires:       bash
Requires:       wget
Recommends:     logrotate
Recommends:     netcfg
Requires(pre):  shadow
%if 0%{?suse_version} >= 1500
BuildRequires:  systemd
%{?systemd_requires}
%else
Requires(pre):  aaa_base
Requires:       cron
Source3:        submit-ip-crontab
%endif
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch
#Compat macro for new _fillupdir macro introduced in Nov 2017
%if ! %{defined _fillupdir}
  %define _fillupdir %{_localstatedir}/adm/fillup-templates
%endif


%description
This script is useful if you like to submit the (external) IP Address of your system
to another machine via SSH.

%prep

%build

%install
install -Dm755 %{SOURCE0} %{buildroot}%{_bindir}/submit-ip
install -Dm644 %{SOURCE1} %{buildroot}%{_fillupdir}/sysconfig.%{name}
install -Dm755 %{SOURCE2} %{buildroot}%{_bindir}/receive-ip
install -Dm644 %{SOURCE4} %{buildroot}%{_defaultdocdir}/%{name}/README.SUSE
%if 0%{?suse_version} < 1500
install -Dm644 %{SOURCE3} %{buildroot}%{_sysconfdir}/cron.d/%{name}
%else
install -D -m 0644 %{SOURCE5} %{buildroot}%{_unitdir}/%{name}.timer
install -D -m 0644 %{SOURCE6} %{buildroot}%{_unitdir}/%{name}.service
%endif
mkdir -p %{buildroot}/var/log/%{name}

%clean
rm -rf %{buildroot}

%pre
%service_add_pre %{name}.timer %{name}.service
if [ ${1:-0} -eq 1 ]; then
  # Create user and group on the system if necessary
  /usr/sbin/groupadd -r %{submit_ip_group} 2>/dev/null || :
  /usr/sbin/useradd  -r -g %{submit_ip_group} -M -d /var/log/%{name} -s /bin/false -c "User to submit IP to remote server" %{submit_ip_user} 2>/dev/null || :
fi

%preun
%service_del_preun %{name}.timer %{name}.service

%post
%service_add_post %{name}.timer %{name}.service
%{fillup_only}

%postun
%service_del_postun  %{name}.timer %{name}.service

%files
%defattr(-,root,root)
%doc %{_defaultdocdir}/%{name}/README.SUSE
%dir %{_defaultdocdir}/%{name}
%{_bindir}/*
%{_fillupdir}/sysconfig.%{name}
%if 0%{?suse_version} < 1500
%config(noreplace) %{_sysconfdir}/cron.d/%{name}
%else
%{_unitdir}/%{name}.service
%{_unitdir}/%{name}.timer
%endif
%dir %attr(-,%{submit_ip_user},%{submit_ip_group}) /var/log/%{name}

%changelog
openSUSE Build Service is sponsored by