summaryrefslogtreecommitdiff
path: root/net-vpn/openconnect/files
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2020-11-25 22:39:15 +0000
committerV3n3RiX <venerix@redcorelinux.org>2020-11-25 22:39:15 +0000
commitd934827bf44b7cfcf6711964418148fa60877668 (patch)
tree0625f358789b5e015e49db139cc1dbc9be00428f /net-vpn/openconnect/files
parent2e34d110f164bf74d55fced27fe0000201b3eec5 (diff)
gentoo resync : 25.11.2020
Diffstat (limited to 'net-vpn/openconnect/files')
-rw-r--r--net-vpn/openconnect/files/README.OpenRC30
-rw-r--r--net-vpn/openconnect/files/openconnect.initd.8.10105
2 files changed, 135 insertions, 0 deletions
diff --git a/net-vpn/openconnect/files/README.OpenRC b/net-vpn/openconnect/files/README.OpenRC
new file mode 100644
index 000000000000..baa617d94eaa
--- /dev/null
+++ b/net-vpn/openconnect/files/README.OpenRC
@@ -0,0 +1,30 @@
+The service script for openconnect supports multiple vpn tunnels.
+
+You need to create a symbolic link to /etc/init.d/openconnect in
+/etc/init.d for each tunnel instead of calling it directly:
+
+ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0
+
+Also, create a configuration file for the tunnel in /etc/openconnect. To
+follow this example, the configuration file would be called
+/etc/openconnect/vpn0.conf. See man openconnect for the options that can
+go in this file.
+
+You can then start the vpn tunnel like this:
+
+rc-service openconnect.vpn0 start
+
+If you would like to run preup, postup, predown, and/or postdown scripts,
+You need to create a directory in /etc/openconnect with the name of the vpn:
+
+mkdir /etc/openconnect/vpn0
+
+Then add executable shell files:
+
+mkdir /etc/openconnect/vpn0
+cd /etc/openconnect/vpn0
+echo '#!/bin/sh' > preup.sh
+cp preup.sh predown.sh
+cp preup.sh postup.sh
+cp preup.sh postdown.sh
+chmod 755 /etc/openconnect/vpn0/*
diff --git a/net-vpn/openconnect/files/openconnect.initd.8.10 b/net-vpn/openconnect/files/openconnect.initd.8.10
new file mode 100644
index 000000000000..cec5350e17ce
--- /dev/null
+++ b/net-vpn/openconnect/files/openconnect.initd.8.10
@@ -0,0 +1,105 @@
+#!/sbin/openrc-run
+# Copyright 1999-2015 Gentoo Foundation
+# 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
+ if [ ! -f "${VPNCONF}" ]; then
+ ewarn "The configuration file for ${VPN} does not exist."
+ ewarn "Please create ${VPNCONF}"
+ ewarn "This will become a fatal error in a future release."
+ fi
+ local server vpnopts password
+ eval server=\$server_${VPN}
+ eval vpnopts=\$vpnopts_${VPN}
+ eval password=\$password_${VPN}
+ if [ -n "$server" ] || [ -n "$vpnopts" ] || [ -n "password" ]; then
+ ewarn "server_${VPN}, vpnopts${VPN} and password_${VPN} are deprecated"
+ ewarn"Please move them to the appropriate settings in ${VPNCONF}"
+ ewarn "They will be ignored in the future."
+ 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"
+}
+
+start() {
+ local server vpnopts password
+ eval server=\$server_${VPN}
+ eval vpnopts=\$vpnopts_${VPN}
+ eval password=\$password_${VPN}
+
+ ebegin "Starting ${name}"
+ start-stop-daemon --start --exec "${command}" -- \
+ --background \
+ --config="${VPNCONF:-/dev/null}" \
+ --interface="${VPN}" \
+ --pid-file="${pidfile}" \
+ ${vpnopts} \
+ "${server}" \
+ >> "${VPNLOGFILE}" \
+ 2>> "${VPNERRFILE}" \
+ <<EOF
+${password}
+EOF
+ eend $?
+}
+
+start_post() {
+ run_hook "${VPNDIR}/postup.sh"
+}
+
+stop_pre() {
+ checkconfig || return
+ run_hook "${VPNDIR}/predown.sh"
+}
+
+stop_post() {
+ run_hook "${VPNDIR}/postdown.sh"
+}