# Authority: vip-ire
# Name: Daniel Berteaud

Summary: OpenVPN, a strong VPN solution build over SSL, pre-configured for routed mode
Name: smeserver-openvpn-routed
%define version 0.1.3
%define release 1
Version: %{version}
Release: %{release}%{?dist}
License: GPL
Group: Networking/Remote access
Source: %{name}-%{version}.tar.gz

BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot
BuildArchitectures: noarch

BuildRequires: e-smith-devtools

Requires: e-smith-base
Requires: openvpn
#Requires: perl(Net::OpenVPN::Manage)

%description
This package contains all the needed scripts and templates
to have a full working openvpn server running in routed mode.


%changelog
* Wed Dec 3 2014 Daniel Berteaud <daniel@firewall-services.com> 0.1.3-1
- Correctly push route to local network when not redirecting gw

* Mon Jun 23 2014 Daniel Berteaud <daniel@firewall-services.com> 0.1.2-1
- Fix plugin path on x86_64

* Wed Aug 21 2013 Daniel Berteaud <daniel@firewall-services.com> 0.1.1-1
- Use full path to the up script

* Tue Jun 11 2013 Daniel Berteaud <daniel@firewall-services.com> 0.1.0-1
- initial release

%prep
%setup -q -n %{name}-%{version}

%build
perl createlinks

%{__mkdir_p} root/etc/openvpn/routed/ccd
%{__mkdir_p} root/etc/openvpn/routed/priv
%{__mkdir_p} root/etc/openvpn/routed/pub
%{__mkdir_p} root/etc/openvpn/routed/tmp
%{__mkdir_p} root/var/log/openvpn-routed

%install
/bin/rm -rf $RPM_BUILD_ROOT
(cd root   ; /usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT)
/bin/rm -f %{name}-%{version}-filelist
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \
  --file /var/service/openvpn-routed/run 'attr(0755,root,root)' \
  --file /var/service/openvpn-routed/log/run 'attr(0755,root,root)' \
  --dir /var/log/openvpn-routed 'attr(0750,smelog,smelog)' \
  --dir /etc/openvpn/routed/pub 'attr(0755,root,root)' \
  --dir /etc/openvpn/routed/priv 'attr(0750,root,root)' \
  --dir /etc/openvpn/routed/ccd 'attr(0755,root,root)' \
  --dir /etc/openvpn/routed/tmp 'attr(0770,root,openvpn)' \
  --file /usr/bin/ovpn-routed-update-crl  'attr(0750,root,root)' \
  --file /etc/openvpn/routed/bin/up 'attr(755,root,root)' \
  > %{name}-%{version}-filelist

%files -f %{name}-%{version}-filelist
%defattr(-,root,root)

%clean
rm -rf $RPM_BUILD_ROOT


%post

%preun