From 1842097fc719069f2561449d53d30088a2f6d2a74bf15899df4c3452f61ff8fc Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Mon, 6 May 2013 11:17:06 +0000 Subject: [PATCH] - Try to migrate openvpn.service autostart to openvpn@.service instance enablement. OBS-URL: https://build.opensuse.org/package/show/network:vpn/openvpn?expand=0&rev=60 --- openvpn.changes | 6 ++++++ openvpn.spec | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/openvpn.changes b/openvpn.changes index bb80770..bd2a3e6 100644 --- a/openvpn.changes +++ b/openvpn.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Mon May 6 11:13:49 UTC 2013 - mt@suse.de + +- Try to migrate openvpn.service autostart to openvpn@.service + instance enablement. + ------------------------------------------------------------------- Tue Apr 23 13:20:48 UTC 2013 - mt@suse.de diff --git a/openvpn.spec b/openvpn.spec index 4045ed4..30cf644 100644 --- a/openvpn.spec +++ b/openvpn.spec @@ -178,6 +178,40 @@ rm -rf $RPM_BUILD_ROOT%{_datadir}/doc/{OpenVPN,%name} %__mkdir_p -m750 %{_localstatedir}/run/openvpn %if %{with_systemd} %service_add_post %{name}.target +# try to migrate openvpn.service autostart to openvpn@.service +if test ${FIRST_ARG:-$1} -ge 1 -a \ + -x /bin/systemctl -a \ + -f /etc/sysconfig/openvpn -a \ + -f /var/adm/fillup-templates/sysconfig.openvpn && \ + /bin/systemctl --quiet is-enabled openvpn.service &>/dev/null ; +then + . /etc/sysconfig/openvpn + try_service_cgroup_join() + { + local p="/var/run/openvpn/${1}.pid" + local t="/sys/fs/cgroup/systemd/system/openvpn@.service/${1}" + /sbin/checkproc -p "$p" "%{_sbindir}/openvpn" &>/dev/null || return 0 + test -d "$t" || mkdir -p "$t" 2>/dev/null || return 1 + cat "$p" > "$t/tasks" 2>/dev/null || return 1 + } + if test "X$OPENVPN_AUTOSTART" != "X" ; then + for conf in $OPENVPN_AUTOSTART ; do + test -f "/etc/openvpn/${conf}.conf" && \ + /bin/systemctl enable "openvpn@${conf}.service" && \ + try_service_cgroup_join "$conf" || continue + done + else + shopt -s nullglob || : + for conf in /etc/openvpn/*.conf ; do + conf=${conf##*/} + conf=${conf%.conf} + test -f "/etc/openvpn/${conf}.conf" && \ + /bin/systemctl enable "openvpn@${conf}.service" && \ + try_service_cgroup_join "$conf" || continue + done + fi +fi +rm -f /etc/sysconfig/openvpn || : %else %{?fillup_and_insserv:%fillup_and_insserv} %endif