summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2021-10-02 01:54:38 -0400
committerMike Gilbert <floppym@gentoo.org>2021-10-02 02:00:09 -0400
commite7ea3fbeadbd0524ea7d7498a8eb563b0b780495 (patch)
tree7ddcb0ed0c665711e0794bc06d54c34268db36b4 /net-vpn/openconnect
parentnet-vpn/openconnect: support python3.10 (diff)
downloadgentoo-e7ea3fbeadbd0524ea7d7498a8eb563b0b780495.tar.gz
gentoo-e7ea3fbeadbd0524ea7d7498a8eb563b0b780495.tar.bz2
gentoo-e7ea3fbeadbd0524ea7d7498a8eb563b0b780495.zip
net-vpn/openconnect: revise init script
Remove warnings about removal of variables. Restore sample conf.d file. Allow for missing config file. Use eval to allow quoted whitespace in vpnopts. Bug: https://bugs.gentoo.org/733614 Closes: https://bugs.gentoo.org/763579 Signed-off-by: Mike Gilbert <floppym@gentoo.org>
Diffstat (limited to 'net-vpn/openconnect')
-rw-r--r--net-vpn/openconnect/files/openconnect.conf.in2
-rw-r--r--net-vpn/openconnect/files/openconnect.initd109
-rw-r--r--net-vpn/openconnect/openconnect-8.10-r3.ebuild (renamed from net-vpn/openconnect/openconnect-8.10-r2.ebuild)5
-rw-r--r--net-vpn/openconnect/openconnect-9999.ebuild5
4 files changed, 118 insertions, 3 deletions
diff --git a/net-vpn/openconnect/files/openconnect.conf.in b/net-vpn/openconnect/files/openconnect.conf.in
index 53b14e61378e..7e44f569c0c4 100644
--- a/net-vpn/openconnect/files/openconnect.conf.in
+++ b/net-vpn/openconnect/files/openconnect.conf.in
@@ -23,4 +23,4 @@
server_vpn0="vpn.server.tld"
password_vpn0="YOUR_PASSWORD"
# Any OPENCONNECT options my go here (see openconnect --help)
-vpnopts_vpn0="-l --passwd-on-stdin --user=YOUR_USERNAME --script=/etc/openconnect/openconnect.sh"
+vpnopts_vpn0="-l --passwd-on-stdin --user=YOUR_USERNAME"
diff --git a/net-vpn/openconnect/files/openconnect.initd b/net-vpn/openconnect/files/openconnect.initd
new file mode 100644
index 000000000000..7b33920f498c
--- /dev/null
+++ b/net-vpn/openconnect/files/openconnect.initd
@@ -0,0 +1,109 @@
+#!/sbin/openrc-run
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+VPN="${RC_SVCNAME#*.}"
+VPNCONF=/etc/openconnect/${VPN}.conf
+VPNDIR="/etc/openconnect/${VPN}"
+VPNLOG="/var/log/openconnect/${VPN}"
+VPNLOGFILE="${VPNLOG}/openconnect.log"
+VPNERRFILE="${VPNLOG}/openconnect.err"
+
+command="/usr/sbin/openconnect"
+name="OpenConnect: ${VPN}"
+pidfile="/run/openconnect/${VPN}.pid"
+stopsig="SIGINT"
+
+depend() {
+ before netmount
+}
+
+checkconfig() {
+ if [ $VPN = "openconnect" ]; then
+ eerror "You cannot call openconnect directly. You must create a symbolic link to it with the vpn name:"
+ eerror
+ eerror "ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0"
+ eerror
+ eerror "And then call it instead:"
+ eerror
+ eerror "/etc/init.d/openconnect.vpn0 start"
+ return 1
+ fi
+ return 0
+}
+
+checktuntap() {
+ if [ "$RC_UNAME" = "Linux" -a ! -e /dev/net/tun ] ; then
+ if ! modprobe tun ; then
+ eerror "TUN/TAP support is not available in this kernel"
+ return 1
+ fi
+ fi
+}
+
+run_hook() {
+ if [ -x "$1" ]; then
+ "$@"
+ fi
+}
+
+start_pre() {
+ checkconfig || return
+ checktuntap || return
+ checkpath -d "${VPNLOG}" || return
+ checkpath -d /run/openconnect || return
+ run_hook "${VPNDIR}/preup.sh"
+}
+
+ssd_helper() {
+ if [ -n "${password}" ]; then
+ start-stop-daemon "$@" <<EOF
+${password}
+EOF
+ else
+ start-stop-daemon "$@"
+ fi
+}
+
+start() {
+ local server vpnopts password
+ eval server=\$server_${VPN}
+ eval vpnopts=\$vpnopts_${VPN}
+ eval password=\$password_${VPN}
+
+ local config=
+ if [ -e "${VPNCONF}" ]; then
+ config="--config=${VPNCONF}"
+ fi
+
+ # Allow quoted whitespace in vpnopts.
+ eval set -- ${vpnopts}
+
+ ebegin "Starting ${name}"
+ ssd_helper --start \
+ --exec "${command}" \
+ --pidfile "${pidfile}" \
+ -- \
+ --background \
+ ${config} \
+ --interface="${VPN}" \
+ --pid-file="${pidfile}" \
+ "$@" \
+ "${server}" \
+ >> "${VPNLOGFILE}" \
+ 2>> "${VPNERRFILE}"
+ eend $?
+}
+
+start_post() {
+ run_hook "${VPNDIR}/postup.sh"
+}
+
+stop_pre() {
+ checkconfig || return
+ run_hook "${VPNDIR}/predown.sh"
+}
+
+stop_post() {
+ run_hook "${VPNDIR}/postdown.sh"
+}
diff --git a/net-vpn/openconnect/openconnect-8.10-r2.ebuild b/net-vpn/openconnect/openconnect-8.10-r3.ebuild
index ba71fcaef777..8b5c8962bee9 100644
--- a/net-vpn/openconnect/openconnect-8.10-r2.ebuild
+++ b/net-vpn/openconnect/openconnect-8.10-r3.ebuild
@@ -129,8 +129,11 @@ src_install() {
default
find "${ED}" -name '*.la' -delete || die
- newinitd "${FILESDIR}"/openconnect.initd.8.10 openconnect
dodoc "${FILESDIR}"/README.OpenRC
+
+ newconfd "${FILESDIR}"/openconnect.conf.in openconnect
+ newinitd "${FILESDIR}"/openconnect.initd openconnect
+
insinto /etc/logrotate.d
newins "${FILESDIR}"/openconnect.logrotate openconnect
diff --git a/net-vpn/openconnect/openconnect-9999.ebuild b/net-vpn/openconnect/openconnect-9999.ebuild
index ba71fcaef777..8b5c8962bee9 100644
--- a/net-vpn/openconnect/openconnect-9999.ebuild
+++ b/net-vpn/openconnect/openconnect-9999.ebuild
@@ -129,8 +129,11 @@ src_install() {
default
find "${ED}" -name '*.la' -delete || die
- newinitd "${FILESDIR}"/openconnect.initd.8.10 openconnect
dodoc "${FILESDIR}"/README.OpenRC
+
+ newconfd "${FILESDIR}"/openconnect.conf.in openconnect
+ newinitd "${FILESDIR}"/openconnect.initd openconnect
+
insinto /etc/logrotate.d
newins "${FILESDIR}"/openconnect.logrotate openconnect