convert to systemd

epel8
Tom "spot" Callaway 13 years ago
parent 5127293307
commit 8b3e151715

@ -0,0 +1 @@
D /var/run/openvpn 0710 root openvpn -

@ -4,7 +4,7 @@
Name: openvpn Name: openvpn
Version: 2.2.1 Version: 2.2.1
Release: 1%{?prerelease:.%{prerelease}}%{?dist} Release: 2%{?prerelease:.%{prerelease}}%{?dist}
Summary: A full-featured SSL VPN solution Summary: A full-featured SSL VPN solution
URL: http://openvpn.net/ URL: http://openvpn.net/
#Source0: http://openvpn.net/beta/%{name}-%{version}%{?prerelease:_%{prerelease}}.tar.gz #Source0: http://openvpn.net/beta/%{name}-%{version}%{?prerelease:_%{prerelease}}.tar.gz
@ -15,6 +15,11 @@ Source1: http://openvpn.net/signatures/%{name}-%{version}%{?prerelease
# Sample 2.0 config files # Sample 2.0 config files
Source2: roadwarrior-server.conf Source2: roadwarrior-server.conf
Source3: roadwarrior-client.conf Source3: roadwarrior-client.conf
# Systemd service
Source4: openvpn@.service
# Tmpfile.d config
Source5: %{name}-tmpfile.conf
# Don't start openvpn by default. # Don't start openvpn by default.
Patch0: openvpn-init.patch Patch0: openvpn-init.patch
Patch1: openvpn-script-security.patch Patch1: openvpn-script-security.patch
@ -22,11 +27,11 @@ Patch2: openvpn-2.1.1-init.patch
Patch3: openvpn-2.1.1-initinfo.patch Patch3: openvpn-2.1.1-initinfo.patch
License: GPLv2 License: GPLv2
Group: Applications/Internet Group: Applications/Internet
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(id -un)
BuildRequires: lzo-devel BuildRequires: lzo-devel
BuildRequires: openssl-devel BuildRequires: openssl-devel
BuildRequires: pam-devel BuildRequires: pam-devel
BuildRequires: pkcs11-helper-devel BuildRequires: pkcs11-helper-devel
BuildRequires: systemd-units
# For /sbin/ip. # For /sbin/ip.
BuildRequires: iproute BuildRequires: iproute
# We need /dev/net/tun. # We need /dev/net/tun.
@ -37,9 +42,10 @@ Requires: iproute
# For ifconfig and route. # For ifconfig and route.
Requires: net-tools Requires: net-tools
Requires(pre): /usr/sbin/useradd Requires(pre): /usr/sbin/useradd
Requires(post): /sbin/chkconfig Requires(post): systemd-sysv
Requires(preun): /sbin/chkconfig, /sbin/service Requires(post): systemd-units
Requires(postun): /sbin/service Requires(preun): systemd-units
Requires(postun): systemd-units
# Filter out the perl(Authen::PAM) dependency. # Filter out the perl(Authen::PAM) dependency.
# No perl dependency is really needed at all. # No perl dependency is really needed at all.
@ -115,12 +121,12 @@ rm -f %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u})-loopback-client \
%{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u})-loopback-server %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u})-loopback-server
%install %install
rm -rf $RPM_BUILD_ROOT
install -D -m 0644 %{name}.8 $RPM_BUILD_ROOT%{_mandir}/man8/%{name}.8 install -D -m 0644 %{name}.8 $RPM_BUILD_ROOT%{_mandir}/man8/%{name}.8
install -D -m 0755 %{name} $RPM_BUILD_ROOT%{_sbindir}/%{name} install -D -m 0755 %{name} $RPM_BUILD_ROOT%{_sbindir}/%{name}
install -D -m 0755 sample-scripts/%{name}.init \
$RPM_BUILD_ROOT%{_initrddir}/%{name} mkdir -p %{buildroot}%{_unitdir}
install -D -m 0755 %{SOURCE4} $RPM_BUILD_ROOT%{_unitdir}/
rm -rf %{buildroot}%{_initrddir}
install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/%{name} install -d -m 0755 $RPM_BUILD_ROOT%{_sysconfdir}/%{name}
mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name} mkdir -p $RPM_BUILD_ROOT%{_datadir}/%{name}
@ -135,10 +141,11 @@ for plugin in %{plugins} ; do
cp plugin/$plugin/README plugin/$plugin.txt cp plugin/$plugin/README plugin/$plugin.txt
done done
mkdir -m 755 -p $RPM_BUILD_ROOT%{_var}/run/%{name} # tmpfiles.d
mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
%clean install -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
rm -rf $RPM_BUILD_ROOT mkdir -p %{buildroot}%{_localstatedir}/run/
install -d -m 0710 %{buildroot}%{_localstatedir}/run/%{name}/
%pre %pre
getent group openvpn &>/dev/null || groupadd -r openvpn getent group openvpn &>/dev/null || groupadd -r openvpn
@ -147,21 +154,34 @@ getent passwd openvpn &>/dev/null || \
-d /etc/openvpn openvpn -d /etc/openvpn openvpn
%post %post
/sbin/chkconfig --add %{name} if [ $1 -eq 1 ] ; then
# Initial installation
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
fi
%preun %preun
if [ "$1" = 0 ]; then if [ $1 -eq 0 ] ; then
/sbin/service %{name} stop # Package removal, not upgrade
/sbin/chkconfig --del %{name} /bin/systemctl --no-reload disable openvpn.service > /dev/null 2>&1 || :
/bin/systemctl stop openvpn.service > /dev/null 2>&1 || :
fi fi
%postun %postun
if [ "$1" -ge 1 ]; then /bin/systemctl daemon-reload >/dev/null 2>&1 || :
/sbin/service %{name} condrestart >/dev/null 2>&1 # Normally, we'd try a restart here, but in this case, it could be troublesome.
fi
%triggerun -- openvpn < 2.2.1-2
# Save the current service runlevel info
# User must manually run systemd-sysv-convert --apply openvpn
# to migrate them to systemd targets
/usr/bin/systemd-sysv-convert --save openvpn >/dev/null 2>&1 ||:
# Run these because the SysV package being removed won't do them
/sbin/chkconfig --del openvpn >/dev/null 2>&1 || :
/bin/systemctl try-restart openvpn.service >/dev/null 2>&1 || :
%files %files
%defattr(-,root,root,0755)
%doc AUTHORS COPYING COPYRIGHT.GPL INSTALL PORTS README %doc AUTHORS COPYING COPYRIGHT.GPL INSTALL PORTS README
# Add NEWS when it isn't zero-length. # Add NEWS when it isn't zero-length.
%doc plugin/*.txt %doc plugin/*.txt
@ -170,11 +190,15 @@ fi
%{_sbindir}/%{name} %{_sbindir}/%{name}
%{_datadir}/%{name}/ %{_datadir}/%{name}/
%{_libdir}/%{name}/ %{_libdir}/%{name}/
%{_initrddir}/%{name} %{_unitdir}/%{name}@.service
%{_var}/run/%{name}/ %dir %{_localstatedir}/run/%{name}/
%config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf
%config %dir %{_sysconfdir}/%{name}/ %config %dir %{_sysconfdir}/%{name}/
%changelog %changelog
* Fri Sep 9 2011 Tom Callaway <spot@fedoraproject.org> 2.2.1-2
- convert to systemd
* Fri Jul 08 2011 Jon Ciesla <limb@jcomserv.net> 2.2.1-1 * Fri Jul 08 2011 Jon Ciesla <limb@jcomserv.net> 2.2.1-1
- Update to 2.2.1. - Update to 2.2.1.

@ -0,0 +1,11 @@
[Unit]
Description=OpenVPN Robust And Highly Flexible Tunneling Application On %I
After=syslog.target network.target
[Service]
Type=forking
PIDFile=/var/run/openvpn/%i.pid
ExecStart=/usr/sbin/openvpn --daemon --writepid /var/run/openvpn/%i.pid --cd /etc/openvpn/ --config %i.conf
[Install]
WantedBy=multi-user.target
Loading…
Cancel
Save