diff options
Diffstat (limited to 'net-misc/openconnect/files')
-rw-r--r-- | net-misc/openconnect/files/openconnect.conf.in | 26 | ||||
-rw-r--r-- | net-misc/openconnect/files/openconnect.init.in | 123 | ||||
-rw-r--r-- | net-misc/openconnect/files/openconnect.init.in-r1 | 137 | ||||
-rw-r--r-- | net-misc/openconnect/files/openconnect.init.in-r2 | 144 | ||||
-rw-r--r-- | net-misc/openconnect/files/openconnect.init.in-r3 | 145 | ||||
-rw-r--r-- | net-misc/openconnect/files/openconnect.logrotate | 8 |
6 files changed, 583 insertions, 0 deletions
diff --git a/net-misc/openconnect/files/openconnect.conf.in b/net-misc/openconnect/files/openconnect.conf.in new file mode 100644 index 0000000..53b14e6 --- /dev/null +++ b/net-misc/openconnect/files/openconnect.conf.in @@ -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/net-misc/openconnect/files/openconnect.init.in b/net-misc/openconnect/files/openconnect.init.in new file mode 100644 index 0000000..5eee4ec --- /dev/null +++ b/net-misc/openconnect/files/openconnect.init.in @@ -0,0 +1,123 @@ +#!/sbin/runscript +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/openconnect/files/openconnect.init.in,v 1.4 2012/12/22 11:21:37 hwoarang Exp $ + +VPN="${RC_SVCNAME#*.}" +VPNLOG="/var/log/openconnect/${VPN}" +VPNLOGFILE="${VPNLOG}/openconnect.log" +VPNERRFILE="${VPNLOG}/openconnect.err" +VPNPID="/run/openconnect/${VPN}.pid" +VPNDIR="/etc/openconnect/${VPN}" +PREUPSCRIPT="${VPNDIR}/preup.sh" +PREDOWNSCRIPT="${VPNDIR}/predown.sh" +POSTUPSCRIPT="${VPNDIR}/postup.sh" +POSTDOWNSCRIPT="${VPNDIR}/postdown.sh" +SERVER="server_${VPN}" +PASSWORD="password_${VPN}" +VPNOPTS="vpnopts_${VPN}" + +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:" + echo + eerror "ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0" + echo + eerror "And then call it instead:" + echo + eerror "/etc/init.d/openconnect.vpn0 start" + return 1 + fi +} + +checktuntap() { + if [ $(uname -s) = "Linux" ] ; then + if [ ! -e /dev/net/tun ]; then + if ! modprobe tun ; then + eerror "TUN/TAP support is not available in this kernel" + return 1 + fi + fi + if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then + ebegin "Detected broken /dev/net/tun symlink, fixing..." + rm -f /dev/net/tun + ln -s /dev/misc/net/tun /dev/net/tun + eend $? + fi + fi +} + +start() { + ebegin "Starting OpenConnect: ${VPN}" + + checkconfig || return 1 + + checktuntap || return 1 + + if [ "${!SERVER}" == "vpn.server.tld" ]; then + eend 1 "${VPN} not configured" + return 1 + fi + + if [ ! -e "${VPNLOG}" ]; then + mkdir -p "${VPNLOG}" + fi + + local piddir="${VPNPID%/*}" + if [ ! -d "$piddir" ] ; then + mkdir -p "$piddir" + if [ $? -ne 0 ]; then + eerror "Directory $piddir for pidfile does not exist and cannot be created" + return 1 + fi + fi + + if [ -x "${PREUPSCRIPT}" ] ; then + "${PREUPSCRIPT}" + fi + + start-stop-daemon --start --make-pidfile --pidfile "${VPNPID}" --stderr "${VPNERRFILE}" --stdout "${VPNLOGFILE}" --background \ + --exec /usr/sbin/openconnect \ + -- --pid-file="${VPNPID}" ${!VPNOPTS} ${!SERVER} <<< ${!PASSWORD} + + local retval=$? + + if [ ! ${retval} -eq 0 ]; then + eend ${retval} + return ${retval} + fi + + if [ -x "${POSTUPSCRIPT}" ] ; then + "${POSTUPSCRIPT}" + fi + + eend $? +} + +stop() { + ebegin "Stopping OpenConnect: ${VPN}" + + checkconfig || return 1 + + if [ -x "${PREDOWNSCRIPT}" ] ; then + "${PREDOWNSCRIPT}" + fi + + start-stop-daemon --pidfile "${VPNPID}" --stop /usr/sbin/openconnect + local retval=$? + + if [ ! ${retval} -eq 0 ]; then + eend ${retval} + return ${retval} + fi + + + if [ -x "${POSTDOWNSCRIPT}" ] ; then + "${POSTDOWNSCRIPT}" + fi + eend $? +} diff --git a/net-misc/openconnect/files/openconnect.init.in-r1 b/net-misc/openconnect/files/openconnect.init.in-r1 new file mode 100644 index 0000000..72e3ab7 --- /dev/null +++ b/net-misc/openconnect/files/openconnect.init.in-r1 @@ -0,0 +1,137 @@ +#!/sbin/runscript +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/openconnect/files/openconnect.init.in-r1,v 1.1 2013/06/23 12:43:56 hasufell Exp $ + +VPN="${RC_SVCNAME#*.}" +VPNLOG="/var/log/openconnect/${VPN}" +VPNLOGFILE="${VPNLOG}/openconnect.log" +VPNERRFILE="${VPNLOG}/openconnect.err" +VPNPID="/run/openconnect/${VPN}.pid" +VPNDIR="/etc/openconnect/${VPN}" +PREUPSCRIPT="${VPNDIR}/preup.sh" +PREDOWNSCRIPT="${VPNDIR}/predown.sh" +POSTUPSCRIPT="${VPNDIR}/postup.sh" +POSTDOWNSCRIPT="${VPNDIR}/postdown.sh" +SERVER="server_${VPN}" +PASSWORD="password_${VPN}" +VPNOPTS="vpnopts_${VPN}" + +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:" + echo + eerror "ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0" + echo + eerror "And then call it instead:" + echo + eerror "/etc/init.d/openconnect.vpn0 start" + return 1 + fi +} + +checktuntap() { + if [ $(uname -s) = "Linux" ] ; then + if [ ! -e /dev/net/tun ]; then + if ! modprobe tun ; then + eerror "TUN/TAP support is not available in this kernel" + return 1 + fi + fi + if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then + ebegin "Detected broken /dev/net/tun symlink, fixing..." + rm -f /dev/net/tun + ln -s /dev/misc/net/tun /dev/net/tun + eend $? + fi + fi +} + +start() { + ebegin "Starting OpenConnect: ${VPN}" + + local tmp_SERVER tmp_VPNOPTS tmp_PASSWORD + eval tmp_SERVER="\${${SERVER}}" + eval tmp_VPNOPTS="\${${VPNOPTS}}" + eval tmp_PASSWORD="\${${PASSWORD}}" + + checkconfig || return 1 + + checktuntap || return 1 + + if [ "${tmp_SERVER}" = "vpn.server.tld" ]; then + eend 1 "${VPN} not configured" + return 1 + fi + + if [ ! -e "${VPNLOG}" ]; then + mkdir -p "${VPNLOG}" + fi + + local piddir="${VPNPID%/*}" + if [ ! -d "$piddir" ] ; then + mkdir -p "$piddir" + if [ $? -ne 0 ]; then + eerror "Directory $piddir for pidfile does not exist and cannot be created" + return 1 + fi + fi + + if [ -x "${PREUPSCRIPT}" ] ; then + "${PREUPSCRIPT}" + fi + + start-stop-daemon --start \ + --make-pidfile \ + --pidfile "${VPNPID}" \ + --stderr "${VPNERRFILE}" \ + --stdout "${VPNLOGFILE}" \ + --background \ + --exec /usr/sbin/openconnect -- \ + --pid-file="${VPNPID}" \ + ${tmp_VPNOPTS} \ + ${tmp_SERVER} <<-E + ${tmp_PASSWORD} + E + + local retval=$? + + if [ ! ${retval} -eq 0 ]; then + eend ${retval} + return ${retval} + fi + + if [ -x "${POSTUPSCRIPT}" ] ; then + "${POSTUPSCRIPT}" + fi + + eend $? +} + +stop() { + ebegin "Stopping OpenConnect: ${VPN}" + + checkconfig || return 1 + + if [ -x "${PREDOWNSCRIPT}" ] ; then + "${PREDOWNSCRIPT}" + fi + + start-stop-daemon --pidfile "${VPNPID}" --stop /usr/sbin/openconnect + local retval=$? + + if [ ! ${retval} -eq 0 ]; then + eend ${retval} + return ${retval} + fi + + + if [ -x "${POSTDOWNSCRIPT}" ] ; then + "${POSTDOWNSCRIPT}" + fi + eend $? +} diff --git a/net-misc/openconnect/files/openconnect.init.in-r2 b/net-misc/openconnect/files/openconnect.init.in-r2 new file mode 100644 index 0000000..fd4d44a --- /dev/null +++ b/net-misc/openconnect/files/openconnect.init.in-r2 @@ -0,0 +1,144 @@ +#!/sbin/runscript +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/openconnect/files/openconnect.init.in-r2,v 1.1 2014/03/17 17:05:14 hasufell Exp $ + +VPN="${RC_SVCNAME#*.}" +VPNLOG="/var/log/openconnect/${VPN}" +VPNLOGFILE="${VPNLOG}/openconnect.log" +VPNERRFILE="${VPNLOG}/openconnect.err" +VPNPID="/run/openconnect/${VPN}.pid" +VPNDIR="/etc/openconnect/${VPN}" +PREUPSCRIPT="${VPNDIR}/preup.sh" +PREDOWNSCRIPT="${VPNDIR}/predown.sh" +POSTUPSCRIPT="${VPNDIR}/postup.sh" +POSTDOWNSCRIPT="${VPNDIR}/postdown.sh" +SERVER="server_${VPN}" +PASSWORD="password_${VPN}" +VPNOPTS="vpnopts_${VPN}" + +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:" + echo + eerror "ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0" + echo + eerror "And then call it instead:" + echo + eerror "/etc/init.d/openconnect.vpn0 start" + return 1 + fi +} + +checktuntap() { + if [ $(uname -s) = "Linux" ] ; then + if [ ! -e /dev/net/tun ]; then + if ! modprobe tun ; then + eerror "TUN/TAP support is not available in this kernel" + return 1 + fi + fi + if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then + ebegin "Detected broken /dev/net/tun symlink, fixing..." + rm -f /dev/net/tun + ln -s /dev/misc/net/tun /dev/net/tun + eend $? + fi + fi +} + +start() { + ebegin "Starting OpenConnect: ${VPN}" + + local tmp_SERVER tmp_VPNOPTS tmp_PASSWORD + eval tmp_SERVER="\${${SERVER}}" + eval tmp_VPNOPTS="\${${VPNOPTS}}" + eval tmp_PASSWORD="\${${PASSWORD}}" + + checkconfig || return 1 + + checktuntap || return 1 + + if [ "${tmp_SERVER}" = "vpn.server.tld" ]; then + eend 1 "${VPN} not configured" + return 1 + fi + + if [ ! -e "${VPNLOG}" ]; then + mkdir -p "${VPNLOG}" + fi + + local piddir="${VPNPID%/*}" + if [ ! -d "$piddir" ] ; then + mkdir -p "$piddir" + if [ $? -ne 0 ]; then + eerror "Directory $piddir for pidfile does not exist and cannot be created" + return 1 + fi + fi + + if [ -x "${PREUPSCRIPT}" ] ; then + "${PREUPSCRIPT}" + fi + + start-stop-daemon --start \ + --make-pidfile \ + --pidfile "${VPNPID}" \ + --stderr "${VPNERRFILE}" \ + --stdout "${VPNLOGFILE}" \ + --background \ + --exec /usr/sbin/openconnect -- \ + --interface="${VPN}" \ + --pid-file="${VPNPID}" \ + ${tmp_VPNOPTS} \ + ${tmp_SERVER} <<-E + ${tmp_PASSWORD} + E + + local retval=$? + + if [ ! ${retval} -eq 0 ]; then + eend ${retval} + return ${retval} + fi + + if [ -x "${POSTUPSCRIPT}" ] ; then + # wait until the interface is up and an ip address is set before running postup + while true; do + if [ -n "$(ip addr show $VPN | grep inet)" ]; then + "${POSTUPSCRIPT}" + break + fi + done + fi + + eend $? +} + +stop() { + ebegin "Stopping OpenConnect: ${VPN}" + + checkconfig || return 1 + + if [ -x "${PREDOWNSCRIPT}" ] ; then + "${PREDOWNSCRIPT}" + fi + + start-stop-daemon --pidfile "${VPNPID}" --stop /usr/sbin/openconnect + local retval=$? + + if [ ! ${retval} -eq 0 ]; then + eend ${retval} + return ${retval} + fi + + + if [ -x "${POSTDOWNSCRIPT}" ] ; then + "${POSTDOWNSCRIPT}" + fi + eend $? +} diff --git a/net-misc/openconnect/files/openconnect.init.in-r3 b/net-misc/openconnect/files/openconnect.init.in-r3 new file mode 100644 index 0000000..423c7e0 --- /dev/null +++ b/net-misc/openconnect/files/openconnect.init.in-r3 @@ -0,0 +1,145 @@ +#!/sbin/runscript +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/openconnect/files/openconnect.init.in-r3,v 1.1 2014/12/09 00:14:37 floppym Exp $ + +VPN="${RC_SVCNAME#*.}" +VPNLOG="/var/log/openconnect/${VPN}" +VPNLOGFILE="${VPNLOG}/openconnect.log" +VPNERRFILE="${VPNLOG}/openconnect.err" +VPNPID="/run/openconnect/${VPN}.pid" +VPNDIR="/etc/openconnect/${VPN}" +PREUPSCRIPT="${VPNDIR}/preup.sh" +PREDOWNSCRIPT="${VPNDIR}/predown.sh" +POSTUPSCRIPT="${VPNDIR}/postup.sh" +POSTDOWNSCRIPT="${VPNDIR}/postdown.sh" +SERVER="server_${VPN}" +PASSWORD="password_${VPN}" +VPNOPTS="vpnopts_${VPN}" + +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:" + echo + eerror "ln -s /etc/init.d/openconnect /etc/init.d/openconnect.vpn0" + echo + eerror "And then call it instead:" + echo + eerror "/etc/init.d/openconnect.vpn0 start" + return 1 + fi +} + +checktuntap() { + if [ $(uname -s) = "Linux" ] ; then + if [ ! -e /dev/net/tun ]; then + if ! modprobe tun ; then + eerror "TUN/TAP support is not available in this kernel" + return 1 + fi + fi + if [ -h /dev/net/tun ] && [ -c /dev/misc/net/tun ]; then + ebegin "Detected broken /dev/net/tun symlink, fixing..." + rm -f /dev/net/tun + ln -s /dev/misc/net/tun /dev/net/tun + eend $? + fi + fi +} + +start() { + ebegin "Starting OpenConnect: ${VPN}" + + local tmp_SERVER tmp_VPNOPTS tmp_PASSWORD + eval tmp_SERVER="\${${SERVER}}" + eval tmp_VPNOPTS="\${${VPNOPTS}}" + eval tmp_PASSWORD="\${${PASSWORD}}" + + checkconfig || return 1 + + checktuntap || return 1 + + if [ "${tmp_SERVER}" = "vpn.server.tld" ]; then + eend 1 "${VPN} not configured" + return 1 + fi + + if [ ! -e "${VPNLOG}" ]; then + mkdir -p "${VPNLOG}" + fi + + local piddir="${VPNPID%/*}" + if [ ! -d "$piddir" ] ; then + mkdir -p "$piddir" + if [ $? -ne 0 ]; then + eerror "Directory $piddir for pidfile does not exist and cannot be created" + return 1 + fi + fi + + if [ -x "${PREUPSCRIPT}" ] ; then + "${PREUPSCRIPT}" + fi + + start-stop-daemon --start \ + --make-pidfile \ + --pidfile "${VPNPID}" \ + --stderr "${VPNERRFILE}" \ + --stdout "${VPNLOGFILE}" \ + --background \ + --exec /usr/sbin/openconnect -- \ + --interface="${VPN}" \ + --pid-file="${VPNPID}" \ + ${tmp_VPNOPTS} \ + ${tmp_SERVER} <<-E + ${tmp_PASSWORD} + E + + local retval=$? + + if [ ! ${retval} -eq 0 ]; then + eend ${retval} + return ${retval} + fi + + if [ -x "${POSTUPSCRIPT}" ] ; then + # wait until the interface is up and an ip address is set before running postup + while true; do + sleep 0.5 + if [ -n "$(ip addr show $VPN 2> /dev/null | grep inet)" ]; then + "${POSTUPSCRIPT}" + break + fi + done + fi + + eend $? +} + +stop() { + ebegin "Stopping OpenConnect: ${VPN}" + + checkconfig || return 1 + + if [ -x "${PREDOWNSCRIPT}" ] ; then + "${PREDOWNSCRIPT}" + fi + + start-stop-daemon --pidfile "${VPNPID}" --stop /usr/sbin/openconnect + local retval=$? + + if [ ! ${retval} -eq 0 ]; then + eend ${retval} + return ${retval} + fi + + + if [ -x "${POSTDOWNSCRIPT}" ] ; then + "${POSTDOWNSCRIPT}" + fi + eend $? +} diff --git a/net-misc/openconnect/files/openconnect.logrotate b/net-misc/openconnect/files/openconnect.logrotate new file mode 100644 index 0000000..0455e68 --- /dev/null +++ b/net-misc/openconnect/files/openconnect.logrotate @@ -0,0 +1,8 @@ +# openconnect logrotate snipet for Gentoo Linux +# +/var/log/openconnect/*/* { + missingok + size 5M + notifempty +} + |