From 78c717ce1eccf58c0b5af831db7e1da397ea29f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20=C5=A0imerda?= Date: Wed, 15 Feb 2012 13:35:10 +0100 Subject: [PATCH] Add sysvinit script for epel6 --- strongswan-init.patch | 119 +++++++++++++++++++++++++++++++++++ strongswan-programname.patch | 13 ---- strongswan.spec | 24 ++++++- 3 files changed, 141 insertions(+), 15 deletions(-) create mode 100644 strongswan-init.patch delete mode 100644 strongswan-programname.patch diff --git a/strongswan-init.patch b/strongswan-init.patch new file mode 100644 index 0000000..87d67d6 --- /dev/null +++ b/strongswan-init.patch @@ -0,0 +1,119 @@ +Index: strongswan-4.6.0/init/systemd/strongswan.service.in +=================================================================== +--- strongswan-4.6.0.orig/init/systemd/strongswan.service.in ++++ strongswan-4.6.0/init/systemd/strongswan.service.in +@@ -3,7 +3,7 @@ Description=strongSwan IPsec + After=syslog.target + + [Service] +-ExecStart=@SBINDIR@/ipsec start --nofork ++ExecStart=@SBINDIR@/strongswan start --nofork + StandardOutput=syslog + + [Install] +Index: strongswan-4.6.1/init/sysvinit/strongswan +=================================================================== +--- /dev/null ++++ strongswan-4.6.1/init/sysvinit/strongswan +@@ -0,0 +1,101 @@ ++#!/bin/sh ++# ++# strongswan An implementation of key management system for IPsec ++# ++# chkconfig: - 48 52 ++# description: Starts or stops the Strongswan daemons. ++ ++### BEGIN INIT INFO ++# Provides: ipsec ++# Required-Start: $network $remote_fs $syslog $named ++# Required-Stop: $syslog $remote_fs ++# Default-Start: ++# Default-Stop: 0 1 6 ++# Short-Description: Start Strongswan daemons at boot time ++### END INIT INFO ++ ++# Source function library. ++. /etc/rc.d/init.d/functions ++ ++exec="/usr/sbin/strongswan" ++prog="strongswan" ++config="/etc/racoon2/racoon2.conf" ++ ++[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog ++ ++lockfile=/var/lock/subsys/$prog ++ ++start() { ++ [ -x $exec ] || exit 5 ++ [ -f $config ] || exit 6 ++ echo -n $"Starting $prog: " ++ daemon $exec start ++ retval=$? ++ echo ++ [ $retval -eq 0 ] && touch $lockfile ++ return $retval ++} ++ ++stop() { ++ echo -n $"Stopping $prog: " ++ $exec stop ++ retval=$? ++ echo ++ [ $retval -eq 0 ] && rm -f $lockfile ++ return $retval ++} ++ ++restart() { ++ stop ++ start ++} ++ ++reload() { ++ restart ++} ++ ++force_reload() { ++ restart ++} ++ ++rh_status() { ++ # run checks to determine if the service is running or use generic status ++ status $prog ++} ++ ++rh_status_q() { ++ rh_status >/dev/null 2>&1 ++} ++ ++ ++case "$1" in ++ start) ++ rh_status_q && exit 0 ++ $1 ++ ;; ++ stop) ++ rh_status_q || exit 0 ++ $1 ++ ;; ++ restart) ++ $1 ++ ;; ++ reload) ++ rh_status_q || exit 7 ++ $1 ++ ;; ++ force-reload) ++ force_reload ++ ;; ++ status) ++ rh_status ++ ;; ++ condrestart|try-restart) ++ rh_status_q || exit 0 ++ restart ++ ;; ++ *) ++ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" ++ exit 2 ++esac ++exit $? diff --git a/strongswan-programname.patch b/strongswan-programname.patch deleted file mode 100644 index e18a0a1..0000000 --- a/strongswan-programname.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: strongswan-4.6.0/init/systemd/strongswan.service.in -=================================================================== ---- strongswan-4.6.0.orig/init/systemd/strongswan.service.in -+++ strongswan-4.6.0/init/systemd/strongswan.service.in -@@ -3,7 +3,7 @@ Description=strongSwan IPsec - After=syslog.target - - [Service] --ExecStart=@SBINDIR@/ipsec start --nofork -+ExecStart=@SBINDIR@/strongswan start --nofork - StandardOutput=syslog - - [Install] diff --git a/strongswan.spec b/strongswan.spec index 0aeeeed..bafbe22 100644 --- a/strongswan.spec +++ b/strongswan.spec @@ -6,7 +6,7 @@ Group: System Environment/Daemons License: GPLv2+ URL: http://www.strongswan.org/ Source0: http://download.strongswan.org/%{name}-%{version}.tar.gz -Patch0: %{name}-programname.patch +Patch0: %{name}-init.patch BuildRequires: gmp-devel BuildRequires: libcurl-devel BuildRequires: openldap-devel @@ -15,6 +15,10 @@ BuildRequires: systemd-units Requires(post): systemd-units Requires(preun): systemd-units Requires(postun): systemd-units +%else +Requires(post): chkconfig +Requires(preun): chkconfig +Requires(preun): initscripts %endif %description The strongSwan 4.6 branch supports both the IKEv1 and IKEv2 key exchange @@ -51,6 +55,13 @@ find %{buildroot} -type f -name '*.la' -delete chmod 644 %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf # protect configuration from ordinary user's eyes chmod 700 %{buildroot}%{_sysconfdir}/%{name} +# setup systemd unit or initscript +%if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 +%else +rm %{buildroot}%{_unitdir}/%{name}.service +install -m 755 init/sysvinit/%{name} %{buildroot}/%{_initddir}/%{name} +%endif + %files %doc README COPYING NEWS CREDITS TODO @@ -59,6 +70,8 @@ chmod 700 %{buildroot}%{_sysconfdir}/%{name} %config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf %if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 %{_unitdir}/%{name}.service +%else +%{_initddir}/%{name} %endif %dir %{_libdir}/%{name} %{_libdir}/%{name}/libcharon.so.0 @@ -139,6 +152,8 @@ if [ $1 -eq 1 ] ; then # Initial installation /bin/systemctl daemon-reload >/dev/null 2>&1 || : fi +%else +/sbin/chkconfig --add %{name} %endif %if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 @@ -149,7 +164,10 @@ if [ $1 -eq 0 ] ; then /bin/systemctl stop %{name}.service > /dev/null 2>&1 || : fi %endif - +if [ $1 -eq 0 ] ; then + /sbin/service %{name} stop >/dev/null 2>&1 + /sbin/chkconfig --del %{name} +fi %postun /sbin/ldconfig %if 0%{?fedora} >= 15 || 0%{?rhel} >= 7 @@ -158,6 +176,7 @@ if [ $1 -ge 1 ] ; then # Package upgrade, not uninstall /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : fi +%else %endif #TODO manpages @@ -165,6 +184,7 @@ fi %changelog * Wed Feb 15 2012 Pavel Šimerda - 4.6.1-7 - Expand tabs in config files for better readability +- Add sysvinit script for epel6 * Wed Feb 15 2012 Pavel Šimerda - 4.6.1-6 - Fix program name in systemd unit file