File sslh.spec of Package sslh

#
# spec file for package sslh
#
# Copyright (C) 2012 by Lars Vogdt
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
#

Name:           sslh
Version:        1.16
Release:        0
License:        GPL-2.0+
Summary:        SSL/SSH multiplexer
Url:            http://www.rutschle.net/tech/sslh.shtml
Group:          Productivity/Networking/SSH
Vendor:         http://www.rutschle.net/
Source:         http://www.rutschle.net/tech/%{name}-v%{version}.tar.bz2
Source1:        sslh.init
Source2:        sslh.sysconfig
Source3:        sslh.conf.d
Patch1:         missing-call-to-setgroups-before-setuid.patch
BuildRequires:  libcap-devel
BuildRequires:  tcpd-devel
BuildRequires:  libconfig-devel
%if 0%{?suse_version} >= 1210
BuildRequires: systemd
%{?systemd_requires}
%endif
PreReq:         %fillup_prereq
PreReq:         %insserv_prereq
PreReq:         coreutils
PreReq:         pwdutils
Requires:       openssh
Requires:       openssl
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
%define         sslh_user sslh

%description
sslh lets one accept both HTTPS and SSH connections on the same port. It makes
it possible to connect to an SSH server on port 443 (e.g. from inside a
corporate firewall) while still serving HTTPS on that port.

%prep
%setup -q -n %{name}-v%{version}
%patch1 -p1
cp -a %{S:1} .

%build
#

%install
MAKEOPTS="USELIBCAP=1 PREFIX=%{_prefix} DESTDIR=%{buildroot} install"
%if 0%{?suse_version} <= 1210
MAKEOPTS="USELIBCONFIG=0 $MAKEOPTS"
%endif
make $MAKEOPTS
%if 0%{?suse_version} > 1210
# install default configuration
mkdir -p %{buildroot}%{_sysconfdir}/default
sed -e "s|USER=nobody|USER=%{sslh_user}|g;
		s|LISTEN=ifname:443|LISTEN=0.0.0.0:443|g" scripts/etc.default.sslh > %{buildroot}%{_sysconfdir}/default/sslh
%endif
# install init script and depending sysconfig file
install -Dm755 sslh.init %{buildroot}%{_sysconfdir}/init.d/sslh
ln -s %{_sysconfdir}/init.d/sslh %{buildroot}%{_sbindir}/rcsslh
install -Dm644 %{S:2} %{buildroot}/var/adm/fillup-templates/sysconfig.%{name}
%if 0%{?suse_version} >= 1210
# install systemd service
install -Dm644 scripts/systemd.sslh.service %{buildroot}%{_unitdir}/%{name}.service
install -Dm644 %SOURCE3 %{buildroot}%{_sysconfdir}/conf.d/sslh

%endif

%clean
rm -fr %{buildroot}

%pre
# Create user on the system if necessary
if
    id %{sslh_user} > /dev/null 2>&1
then
    : OK user sslh already present
else
    useradd  -r -o -g nogroup -s /bin/false -c "User for SSLH" -d /var/lib/empty %{sslh_user} 2> /dev/null || :
fi
%if 0%{?suse_version} >= 1210
%service_add_pre %{name}.service
%endif

%post
%fillup_and_insserv %{name}
%if 0%{?suse_version} >= 1210
%service_add_post %{name}.service
%endif

%preun
%stop_on_removal %{name}
%if 0%{?suse_version} >= 1210
%service_del_preun %{name}.service
%endif

%postun
%restart_on_update %{name}
%insserv_cleanup
%if 0%{?suse_version} >= 1210
%service_del_postun %{name}.service
%endif

%files
%defattr(-, root, root)
%doc ChangeLog README.md
%{_sbindir}/sslh
%{_sbindir}/rcsslh
%if 0%{?suse_version} > 1210
%config(noreplace) %{_sysconfdir}/default/sslh
%endif
%if 0%{?suse_version} >= 1210
%{_unitdir}/%{name}.service
%dir %{_sysconfdir}/conf.d
%config(noreplace) %{_sysconfdir}/conf.d/sslh
%endif
%{_sysconfdir}/init.d/sslh
/var/adm/fillup-templates/sysconfig.%{name}
%doc %{_mandir}/man8/sslh.8*

%changelog
openSUSE Build Service is sponsored by