Commit | Line | Data |
---|---|---|
f48ae55b MW |
1 | ;;; -*-conf-windows-*- |
2 | ;;; | |
3 | ;;; systemd service configuration for the main tripe server. | |
ca1e21b0 MW |
4 | ;;; |
5 | ;;; (c) 2014 Mark Wooding | |
6 | ;;; | |
7 | ||
8 | ;;;----- Licensing notice --------------------------------------------------- | |
9 | ;;; | |
10 | ;;; This file is part of Trivial IP Encryption (TrIPE). | |
11 | ;;; | |
12 | ;;; TrIPE is free software: you can redistribute it and/or modify it under | |
13 | ;;; the terms of the GNU General Public License as published by the Free | |
14 | ;;; Software Foundation; either version 3 of the License, or (at your | |
15 | ;;; option) any later version. | |
16 | ;;; | |
17 | ;;; TrIPE is distributed in the hope that it will be useful, but WITHOUT | |
18 | ;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | ;;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
20 | ;;; for more details. | |
21 | ;;; | |
22 | ;;; You should have received a copy of the GNU General Public License | |
23 | ;;; along with TrIPE. If not, see <https://www.gnu.org/licenses/>. | |
f48ae55b MW |
24 | |
25 | [Unit] | |
26 | Description=Tripe virtual private network server | |
27 | Documentation=man:tripe(8) | |
28 | ||
29 | ConditionPathExists=@sbindir@/tripe | |
30 | ConditionPathExists=@bindir@/tripectl | |
31 | ||
32 | After=syslog.target network.target | |
33 | ||
34 | [Install] | |
35 | WantedBy=multi-user.target | |
36 | ||
37 | [Service] | |
38 | Type=forking | |
39 | PIDFile=/var/run/tripectl.pid | |
40 | ||
41 | ExecStart=/bin/sh -e -c ' \ | |
42 | . @initconfig@ && \ | |
43 | logopt= && \ | |
44 | case $${syslogp-nil} in nil) ;; *) logopt="$$logopt -l" ;; esac && \ | |
45 | case $${logfile+t},$${syslogp-nil} in \ | |
46 | t,*) logopt="$$logopt -f$$logfile" ;; \ | |
47 | ,nil) logopt="$$logopt -f@logfile@" ;; \ | |
48 | esac && \ | |
49 | exec @bindir@/tripectl -D -s -p@sbindir@/tripe \ | |
50 | -P/var/run/tripectl.pid \ | |
51 | $$logopt \ | |
52 | $${keytag+-S-t$$keytag} \ | |
53 | $${addr+-S-b$$addr} $${port+-S-p$$port} \ | |
54 | $${user+-U$$user} $${group+-G$$group} \ | |
55 | $${sockmode+-S-m$$sockmode} \ | |
56 | $${trace+-S-t$$trace} \ | |
57 | $${tunnel+-S-n$$tunnel} \ | |
58 | $$miscopts' | |
59 | ||
60 | ExecReload=@bindir@/tripectl RELOAD | |
61 | ExecStop=@bindir@/tripectl QUIT | |
62 | ||
63 | ExecStartPre=/bin/sh -e -c ' \ | |
64 | if { test -f /proc/misc && grep -q tun /proc/misc; } || \ | |
65 | modprobe -q tun; \ | |
66 | then \ | |
67 | : good; \ | |
68 | else \ | |
69 | echo >&2 "tripe needs the TUN/TAP driver"; exit 1; \ | |
70 | fi; \ | |
71 | if test -c /dev/net/tun; then \ | |
72 | : good; \ | |
73 | else \ | |
74 | echo >&2 "tripe needs /dev/net/tun, which is missing"; \ | |
75 | exit 1; \ | |
76 | fi' | |
77 | ||
78 | ExecStartPost=/bin/sh -e -c ' \ | |
79 | for i in 1 2 3 4 give-up; do \ | |
80 | @bindir@/tripectl HELP >/dev/null 2>&1 && break; \ | |
81 | sleep 1; \ | |
82 | done; \ | |
83 | case $$i in \ | |
84 | give-up) echo >&2 "tripe daemon failed to start"; exit 1 ;; \ | |
85 | esac' |