From 666469715c12b70065a8a2ca97a89768444a88d7 Mon Sep 17 00:00:00 2001 From: hasufell Date: Wed, 23 Sep 2015 20:01:29 +0200 Subject: [PATCH] saving uncommitted changes in /etc prior to emerge run --- conf.d/._cfg0000_openconnect | 26 +++++++++++ init.d/._cfg0000_openconnect | 89 ++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 conf.d/._cfg0000_openconnect create mode 100755 init.d/._cfg0000_openconnect diff --git a/conf.d/._cfg0000_openconnect b/conf.d/._cfg0000_openconnect new file mode 100644 index 0000000..53b14e6 --- /dev/null +++ b/conf.d/._cfg0000_openconnect @@ -0,0 +1,26 @@ +# Variables to configure vpn tunnels where "vpnname" is the name of your vpn tunnel: +# +# server_vpnname +# password_vpnname +# vpnopts_vpnname +# +# The tunnel will need to be started with a symbolic link to openconnect: +# +# ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpnname +# +# If you'd like to execute a script on preup, postup, predown and postdown of the vpn tunnel, you +# need to create executable scripts in a directory with the same name as +# the vpn tunnel (vpn0 can be replaced with the vpn name): +# +# 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/*" + +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" diff --git a/init.d/._cfg0000_openconnect b/init.d/._cfg0000_openconnect new file mode 100755 index 0000000..f1af83e --- /dev/null +++ b/init.d/._cfg0000_openconnect @@ -0,0 +1,89 @@ +#!/sbin/openrc-run +# Copyright 1999-2015 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +VPN="${RC_SVCNAME#*.}" +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 +} + +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 \ + --interface="${VPN}" \ + --pid-file="${pidfile}" \ + ${vpnopts} \ + "${server}" \ + >> "${VPNLOGFILE}" \ + 2>> "${VPNERRFILE}" \ + <