diff --git a/merge/net-vpn/.calculate_directory b/merge/net-vpn/.calculate_directory new file mode 100644 index 0000000..8e3df7f --- /dev/null +++ b/merge/net-vpn/.calculate_directory @@ -0,0 +1 @@ +{% calculate append = 'skip' %} diff --git a/merge/net-vpn/wireguard-tools/.calculate_directory b/merge/net-vpn/wireguard-tools/.calculate_directory new file mode 100644 index 0000000..85a7615 --- /dev/null +++ b/merge/net-vpn/wireguard-tools/.calculate_directory @@ -0,0 +1 @@ +{% calculate path='/etc', name='init.d', package='net-vpn/wireguard-tools' %} diff --git a/merge/net-vpn/wireguard-tools/wireguard b/merge/net-vpn/wireguard-tools/wireguard new file mode 100644 index 0000000..fdf5e13 --- /dev/null +++ b/merge/net-vpn/wireguard-tools/wireguard @@ -0,0 +1,79 @@ +{% calculate chmod='755' %} +#!/sbin/openrc-run +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +VPNDIR=${VPNDIR:-/etc/wireguard} +VPN=${SVCNAME#*.} +[[ $VPN == wireguard ]] && VPN="wg0" +VPNCONF="${VPNDIR}/${VPN}.conf" +extra_commands="reload" + +depend() { + need localmount net + use dns + after bootmisc +} + +checkconfig() { + if [ ! -e /sys/module/wireguard ]; then + if ! modprobe wireguard ; then + eerror "WireGuard support is not available" \ + "in this kernel" + return 1 + fi + fi + return 0 +} + +start() { + ebegin "Starting ${SVCNAME}" + + checkconfig || return 1 + + output="$(/usr/bin/wg-quick up ${VPNCONF} 2>&1)" + res=$? + if [[ $res != 0 ]] + then + while read line; + do + eerror " ${line:4}" + done <<<$output + else + while read line; + do + einfo " ${line:4}" + done <<<$output + fi + + eend $res +} + +stop() { + ebegin "Stopping ${SVCNAME}" + + output="$(/usr/bin/wg-quick down ${VPNCONF} 2>&1)" + if [[ $? != 0 ]] + then + while read line; + do + ewarn " ${line:4}" + done <<<$output + else + while read line; + do + einfo " ${line:4}" + done <<<$output + fi + eend 0 +} + +reload() { + ebegin "Reloading ${SVCNAME}" + grep -v Address ${VPNCONF} >${VPNCONF}.clear + /usr/bin/wg syncconf ${VPN} ${VPNCONF}.clear + rm ${VPNCONF}.clear + eend 0 +} + +# vim: set ts=4 :