summaryrefslogtreecommitdiff
path: root/tunsafe.spec
blob: 36150a29f4c1477feca8aeed79c07305c4524c74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
%global  commit 85a871c1d226956df7c1308a1e5527556fe35fe1

Name:    tunsafe
Version: 1.5rc2
Release: 1%{?dist}
Summary: WireGuard VPN client

License: AGPL-1.0 AND BSD-3-Clause AND OpenSSL
URL:     https://github.com/TunSafe/TunSafe
Source0: https://github.com/TunSafe/TunSafe/archive/%{commit}.tar.gz

BuildRequires: clang
BuildRequires: systemd

%description
High performance and secure VPN client that uses the WireGuard protocol.

%prep
%setup -q -n TunSafe-%{commit}

%build
sed -i "s|clang++-6.0|clang++ -g %{optflags}|;s|-lrt|-lrt %{build_ldflags}|" build_linux.sh

make

%install
install -Dm755 %{name} %{buildroot}/%{_bindir}/%{name}
install -Dm644 installer/TunSafe.conf %{buildroot}%{_sysconfdir}/%{name}/%{name}.conf
mkdir -p %{buildroot}%{_unitdir}

cat > %{buildroot}%{_unitdir}/tunsafe@.service << 'EOF'
[Unit]
Description=TunSafe VPN (%i)
After=network-online.target
Wants=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/tunsafe start -n %i /etc/tunsafe/%i.conf
ExecStop=/usr/bin/tunsafe stop %i
Restart=on-failure
RestartSec=5
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target
EOF

%files
%license LICENSE.AGPL.TXT installer/LICENSE.TXT
%doc docs/*txt installer/ChangeLog.txt TunSafe.conf
%dir %{_sysconfdir}/%{name}
%config(noreplace) %{_sysconfdir}/%{name}/%{name}.conf
%{_bindir}/%{name}
%{_unitdir}/%{name}@.service

%changelog