From 58e155b9c94fd686dd9f5f0e5e8771c8b619a494d07ab62739849dc9e41cdecb Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 16 Feb 2015 13:23:51 +0000 Subject: [PATCH] Accepting request 286332 from home:posophe:branches:network Systemd support OBS-URL: https://build.opensuse.org/request/show/286332 OBS-URL: https://build.opensuse.org/package/show/network/atftp?expand=0&rev=22 --- atftp.changes | 5 +++++ atftp.spec | 37 +++++++++++++++++++++++++++++++++++-- atftpd.service | 7 +++++++ atftpd.socket | 8 ++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 atftpd.service create mode 100644 atftpd.socket diff --git a/atftp.changes b/atftp.changes index 5f3cfc2..9ac4b26 100644 --- a/atftp.changes +++ b/atftp.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Feb 16 13:06:57 UTC 2015 - p.drouand@gmail.com + +- Add systemd support for openSUSE >= 12.1 + ------------------------------------------------------------------- Tue Nov 12 20:41:45 UTC 2013 - chris@computersalat.de diff --git a/atftp.spec b/atftp.spec index c6f2ecb..bf48287 100644 --- a/atftp.spec +++ b/atftp.spec @@ -1,7 +1,7 @@ # # spec file for package atftp # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -32,6 +32,8 @@ Source1: atftpd.init Source2: atftpd.sysconfig Source3: atftpd.logrotate Source4: atftp.fw +Source5: atftpd.service +Source6: atftpd.socket Patch1: atftp-0.7.dif Patch2: atftp-CLK_TCK.diff Patch3: atftp-0.7_compiler_warnings.patch @@ -52,7 +54,13 @@ Patch14: atftp-0.7-default_dir_man.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build Provides: tftp(client) Provides: tftp(server) -PreReq: %insserv_prereq %fillup_prereq +%if 0%{?suse_version} >= 1210 +BuildRequires: systemd-rpm-macros +%{?systemd_requires} +%else +PreReq: %insserv_prereq +%endif +PreReq: %fillup_prereq PreReq: pwdutils BuildRequires: autoconf BuildRequires: automake @@ -95,8 +103,14 @@ make %{?_smp_mflags} %install %makeinstall # SuSE rc +%if 0%{?suse_version} >= 1210 +%{__install} -D -m 0755 %{S:5} %{buildroot}/%{_unitdir}/atftpd.service +%{__install} -D -m 0755 %{S:6} %{buildroot}/%{_unitdir}/atftpd.socket +ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcatftpd +%else %{__install} -D -m 0755 %{S:1} %{buildroot}/etc/init.d/atftpd %{__ln_s} -f ../../etc/init.d/atftpd %{buildroot}%{_sbindir}/rcatftpd +%endif %{__install} -D -m 0644 %{S:2} %{buildroot}/var/adm/fillup-templates/sysconfig.atftpd %{__install} -D -m 0644 %{S:3} %{buildroot}/etc/logrotate.d/%{name} %{__mkdir} -p %{buildroot}/%{_fwdefdir} @@ -117,16 +131,30 @@ if [ -f /etc/sysconfig/atftpd ]; then %{__sed} -i -e "s@^\(ATFTPD_OPTIONS=\"--daemon \"\)@#\1@" /etc/sysconfig/atftpd %{__sed} -i -e "s@^\(ATFTPD_DIRECTORY=\"/tftpboot\"\)@#\1@" /etc/sysconfig/atftpd fi +%if 0%{?suse_version} >= 1210 +%service_add_pre atftpd.service atftpd.socket +%endif %preun +%if 0%{?suse_version} >= 1210 +%service_del_preun atftpd.service atftpd.socket +%else %stop_on_removal atftpd +%endif %post +%if 0%{?suse_version} >= 1210 +%service_add_post atftpd.service atftpd.socket +%endif %{fillup_only -n atftpd} %postun +%if 0%{?suse_version} >= 1210 +%service_del_postun atftpd.service atftpd.socket +%else %restart_on_update atftpd %{insserv_cleanup} +%endif %files %defattr(-,root,root) @@ -135,7 +163,12 @@ fi %{_sbindir}/atftpd %{_sbindir}/in.tftpd %{_sbindir}/rcatftpd +%if 0%{?suse_version} >= 1210 +%{_unitdir}/atftpd.service +%{_unitdir}/atftpd.socket +%else /etc/init.d/atftpd +%endif %config /etc/logrotate.d/%{name} /var/adm/fillup-templates/sysconfig.atftpd %{_mandir}/man1/atftp.1.gz diff --git a/atftpd.service b/atftpd.service new file mode 100644 index 0000000..8a54683 --- /dev/null +++ b/atftpd.service @@ -0,0 +1,7 @@ +[Unit] +Description=Advanced TFTP Server + +[Service] +EnvironmentFile=/etc/sysconfig/atftpd +ExecStart=/usr/sbin/atftpd --user $ATFTPD_USER --group $ATFTPD_GROUP $ATFTPD_OPTIONS $ATFTPD_DIRECTORY +StandardInput=socket diff --git a/atftpd.socket b/atftpd.socket new file mode 100644 index 0000000..fa8b5c8 --- /dev/null +++ b/atftpd.socket @@ -0,0 +1,8 @@ +[Unit] +Description=Advanced tftp Server Activation Socket + +[Socket] +ListenDatagram=69 + +[Install] +WantedBy=sockets.target