Package init

This commit is contained in:
dogsheng 2019-11-19 11:53:02 +08:00
commit 7b71d038df
4 changed files with 105 additions and 0 deletions

BIN
portreserve-0.0.5.tar.bz2 Normal file

Binary file not shown.

View File

@ -0,0 +1,13 @@
diff -up portreserve-0.0.5/src/portreserve.c.pid-file portreserve-0.0.5/src/portreserve.c
--- portreserve-0.0.5/src/portreserve.c.pid-file 2011-06-23 16:50:21.000000000 +0100
+++ portreserve-0.0.5/src/portreserve.c 2013-11-27 09:48:01.073647566 +0000
@@ -314,6 +314,9 @@ portreserve (void)
free (cfgfile);
+ /* Give init a chance to spot our PID file (bug #901988). */
+ sleep (1);
+
return 0;
}

15
portreserve.service Normal file
View File

@ -0,0 +1,15 @@
[Unit]
Description=Port reservation utility
After=sockets.target
Before=basic.target shutdown.target
Conflicts=shutdown.target
DefaultDependencies=no
[Service]
Type=forking
PIDFile=/var/run/portreserve.pid
ExecStart=/sbin/portreserve
Restart=no
[Install]
WantedBy=multi-user.target

77
portreserve.spec Normal file
View File

@ -0,0 +1,77 @@
Name: portreserve
Version: 0.0.5
Release: 21
Summary: Reserve ports to prevent portmap mapping them
License: GPLv2+
URL: http://cyberelk.net/tim/portreserve/
Source0: http://cyberelk.net/tim/data/portreserve/stable/%{name}-%{version}.tar.bz2
Source1: portreserve.service
Patch0001: portreserve-pid-file.patch
BuildRequires: gcc xmlto systemd-units
Requires(post): systemd-units systemd-sysv
Requires(preun): systemd-units
Requires(postun): systemd-units
Obsoletes: portreserve-selinux < 0.0.3-3
%description
The portreserve program aims to help services with well-known ports that lie in the
bindresvport() range (currently 600-1023).. It prevents programs requesting a port
to the libc from occupying a real service's port by occupying it itself, until the
real service tells it to release the port (generally in the init script).
%package help
Summary: Help documents for portreserve
Requires: %{name} = %{version}-%{release}
%description help
Man pages and other related help documents for portreserve.
%prep
%autosetup -n %{name}-%{version} -p1
%build
%configure --sbindir=/sbin
make
%install
%make_install
install -d %{buildroot}%{_unitdir}
install -d %{buildroot}%{_tmpfilesdir}
install -d %{buildroot}%{_sysconfdir}/portreserve
install -d %{buildroot}%{_localstatedir}/run/portreserve
install -m644 %{SOURCE1} %{buildroot}%{_unitdir}/portreserve.service
cat << EOF > %{buildroot}%{_tmpfilesdir}/portreserve.conf
d %{_localstatedir}/run/portreserve 0755 root root 10d
EOF
%post
%systemd_post portreserve.service
%preun
%systemd_preun portreserve.service
%postun
%systemd_postun_with_restart portreserve.service
%triggerun -- portreserve < 0.0.5-3
%{_bindir}/systemd-sysv-convert --save portreserve >/dev/null 2>&1 ||:
/sbin/chkconfig --del portreserve >/dev/null 2>&1 || :
/bin/systemctl try-restart portreserve.service >/dev/null 2>&1 || :
%files
%doc COPYING
%{_unitdir}/portreserve.service
%dir %{_sysconfdir}/portreserve
%dir %{_localstatedir}/run/portreserve
%config %{_tmpfilesdir}/portreserve.conf
/sbin/*
%files help
%doc ChangeLog README NEWS
%{_mandir}/*/*
%changelog
* Wed Nov 06 2019 yanzhihua <yanzhihua4@huawei.com> - 0.0.5-21
- Package init