Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: net-vpn/openconnect/files/, net-vpn/openconnect/
Date: Sat, 02 Oct 2021 06:02:03
Message-Id: 1633154409.e7ea3fbeadbd0524ea7d7498a8eb563b0b780495.floppym@gentoo
1 commit: e7ea3fbeadbd0524ea7d7498a8eb563b0b780495
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Sat Oct 2 05:54:38 2021 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Sat Oct 2 06:00:09 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e7ea3fbe
7
8 net-vpn/openconnect: revise init script
9
10 Remove warnings about removal of variables.
11 Restore sample conf.d file.
12 Allow for missing config file.
13 Use eval to allow quoted whitespace in vpnopts.
14
15 Bug: https://bugs.gentoo.org/733614
16 Closes: https://bugs.gentoo.org/763579
17 Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
18
19 net-vpn/openconnect/files/openconnect.conf.in | 2 +-
20 net-vpn/openconnect/files/openconnect.initd | 109 +++++++++++++++++++++
21 ...t-8.10-r2.ebuild => openconnect-8.10-r3.ebuild} | 5 +-
22 net-vpn/openconnect/openconnect-9999.ebuild | 5 +-
23 4 files changed, 118 insertions(+), 3 deletions(-)
24
25 diff --git a/net-vpn/openconnect/files/openconnect.conf.in b/net-vpn/openconnect/files/openconnect.conf.in
26 index 53b14e61378..7e44f569c0c 100644
27 --- a/net-vpn/openconnect/files/openconnect.conf.in
28 +++ b/net-vpn/openconnect/files/openconnect.conf.in
29 @@ -23,4 +23,4 @@
30 server_vpn0="vpn.server.tld"
31 password_vpn0="YOUR_PASSWORD"
32 # Any OPENCONNECT options my go here (see openconnect --help)
33 -vpnopts_vpn0="-l --passwd-on-stdin --user=YOUR_USERNAME --script=/etc/openconnect/openconnect.sh"
34 +vpnopts_vpn0="-l --passwd-on-stdin --user=YOUR_USERNAME"
35
36 diff --git a/net-vpn/openconnect/files/openconnect.initd b/net-vpn/openconnect/files/openconnect.initd
37 new file mode 100644
38 index 00000000000..7b33920f498
39 --- /dev/null
40 +++ b/net-vpn/openconnect/files/openconnect.initd
41 @@ -0,0 +1,109 @@
42 +#!/sbin/openrc-run
43 +# Copyright 1999-2021 Gentoo Authors
44 +# Distributed under the terms of the GNU General Public License v2
45 +
46 +VPN="${RC_SVCNAME#*.}"
47 +VPNCONF=/etc/openconnect/${VPN}.conf
48 +VPNDIR="/etc/openconnect/${VPN}"
49 +VPNLOG="/var/log/openconnect/${VPN}"
50 +VPNLOGFILE="${VPNLOG}/openconnect.log"
51 +VPNERRFILE="${VPNLOG}/openconnect.err"
52 +
53 +command="/usr/sbin/openconnect"
54 +name="OpenConnect: ${VPN}"
55 +pidfile="/run/openconnect/${VPN}.pid"
56 +stopsig="SIGINT"
57 +
58 +depend() {
59 + before netmount
60 +}
61 +
62 +checkconfig() {
63 + if [ $VPN = "openconnect" ]; then
64 + eerror "You cannot call openconnect directly. You must create a symbolic link to it with the vpn name:"
65 + eerror
66 + eerror "ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0"
67 + eerror
68 + eerror "And then call it instead:"
69 + eerror
70 + eerror "/etc/init.d/openconnect.vpn0 start"
71 + return 1
72 + fi
73 + return 0
74 +}
75 +
76 +checktuntap() {
77 + if [ "$RC_UNAME" = "Linux" -a ! -e /dev/net/tun ] ; then
78 + if ! modprobe tun ; then
79 + eerror "TUN/TAP support is not available in this kernel"
80 + return 1
81 + fi
82 + fi
83 +}
84 +
85 +run_hook() {
86 + if [ -x "$1" ]; then
87 + "$@"
88 + fi
89 +}
90 +
91 +start_pre() {
92 + checkconfig || return
93 + checktuntap || return
94 + checkpath -d "${VPNLOG}" || return
95 + checkpath -d /run/openconnect || return
96 + run_hook "${VPNDIR}/preup.sh"
97 +}
98 +
99 +ssd_helper() {
100 + if [ -n "${password}" ]; then
101 + start-stop-daemon "$@" <<EOF
102 +${password}
103 +EOF
104 + else
105 + start-stop-daemon "$@"
106 + fi
107 +}
108 +
109 +start() {
110 + local server vpnopts password
111 + eval server=\$server_${VPN}
112 + eval vpnopts=\$vpnopts_${VPN}
113 + eval password=\$password_${VPN}
114 +
115 + local config=
116 + if [ -e "${VPNCONF}" ]; then
117 + config="--config=${VPNCONF}"
118 + fi
119 +
120 + # Allow quoted whitespace in vpnopts.
121 + eval set -- ${vpnopts}
122 +
123 + ebegin "Starting ${name}"
124 + ssd_helper --start \
125 + --exec "${command}" \
126 + --pidfile "${pidfile}" \
127 + -- \
128 + --background \
129 + ${config} \
130 + --interface="${VPN}" \
131 + --pid-file="${pidfile}" \
132 + "$@" \
133 + "${server}" \
134 + >> "${VPNLOGFILE}" \
135 + 2>> "${VPNERRFILE}"
136 + eend $?
137 +}
138 +
139 +start_post() {
140 + run_hook "${VPNDIR}/postup.sh"
141 +}
142 +
143 +stop_pre() {
144 + checkconfig || return
145 + run_hook "${VPNDIR}/predown.sh"
146 +}
147 +
148 +stop_post() {
149 + run_hook "${VPNDIR}/postdown.sh"
150 +}
151
152 diff --git a/net-vpn/openconnect/openconnect-8.10-r2.ebuild b/net-vpn/openconnect/openconnect-8.10-r3.ebuild
153 similarity index 96%
154 rename from net-vpn/openconnect/openconnect-8.10-r2.ebuild
155 rename to net-vpn/openconnect/openconnect-8.10-r3.ebuild
156 index ba71fcaef77..8b5c8962bee 100644
157 --- a/net-vpn/openconnect/openconnect-8.10-r2.ebuild
158 +++ b/net-vpn/openconnect/openconnect-8.10-r3.ebuild
159 @@ -129,8 +129,11 @@ src_install() {
160 default
161 find "${ED}" -name '*.la' -delete || die
162
163 - newinitd "${FILESDIR}"/openconnect.initd.8.10 openconnect
164 dodoc "${FILESDIR}"/README.OpenRC
165 +
166 + newconfd "${FILESDIR}"/openconnect.conf.in openconnect
167 + newinitd "${FILESDIR}"/openconnect.initd openconnect
168 +
169 insinto /etc/logrotate.d
170 newins "${FILESDIR}"/openconnect.logrotate openconnect
171
172
173 diff --git a/net-vpn/openconnect/openconnect-9999.ebuild b/net-vpn/openconnect/openconnect-9999.ebuild
174 index ba71fcaef77..8b5c8962bee 100644
175 --- a/net-vpn/openconnect/openconnect-9999.ebuild
176 +++ b/net-vpn/openconnect/openconnect-9999.ebuild
177 @@ -129,8 +129,11 @@ src_install() {
178 default
179 find "${ED}" -name '*.la' -delete || die
180
181 - newinitd "${FILESDIR}"/openconnect.initd.8.10 openconnect
182 dodoc "${FILESDIR}"/README.OpenRC
183 +
184 + newconfd "${FILESDIR}"/openconnect.conf.in openconnect
185 + newinitd "${FILESDIR}"/openconnect.initd openconnect
186 +
187 insinto /etc/logrotate.d
188 newins "${FILESDIR}"/openconnect.logrotate openconnect