diff options
author | Jason A. Donenfeld <zx2c4@gentoo.org> | 2016-10-14 18:25:20 +0200 |
---|---|---|
committer | Jason A. Donenfeld <zx2c4@gentoo.org> | 2016-10-14 18:25:50 +0200 |
commit | bacd0610a70acbd102193c6c4374a02a7b3121c4 (patch) | |
tree | c1e827ae07224c6886a8842d04064cae22f2dd0c /net-misc | |
parent | media-libs/kvazaar: Bump to 1.0.0. (diff) | |
download | gentoo-bacd0610a70acbd102193c6c4374a02a7b3121c4.tar.gz gentoo-bacd0610a70acbd102193c6c4374a02a7b3121c4.tar.bz2 gentoo-bacd0610a70acbd102193c6c4374a02a7b3121c4.zip |
net-misc/wireguard: add netifrc script
Package-Manager: portage-2.3.2
Diffstat (limited to 'net-misc')
-rw-r--r-- | net-misc/wireguard/files/wireguard-openrc.sh | 43 | ||||
-rw-r--r-- | net-misc/wireguard/wireguard-0.0.20161014.ebuild | 2 | ||||
-rw-r--r-- | net-misc/wireguard/wireguard-9999.ebuild | 2 |
3 files changed, 47 insertions, 0 deletions
diff --git a/net-misc/wireguard/files/wireguard-openrc.sh b/net-misc/wireguard/files/wireguard-openrc.sh new file mode 100644 index 000000000000..9c3df6a91e05 --- /dev/null +++ b/net-misc/wireguard/files/wireguard-openrc.sh @@ -0,0 +1,43 @@ +# Copyright (c) 2016 Gentoo Foundation +# All rights reserved. Released under the 2-clause BSD license. + +wireguard_depend() +{ + program /usr/bin/wg + after interface + before dhcp +} + +wireguard_pre_start() +{ + ip link delete dev "$IFACE" type wireguard 2>/dev/null + ebegin "Creating WireGuard interface $IFACE" + if ! ip link add dev "$IFACE" type wireguard; then + eend $? + return $? + fi + eend 0 + + ebegin "Configuring WireGuard interface $IFACE" + set -- $(_get_array "wireguard_$IFVAR") + if [[ -f $1 && $# -eq 1 ]]; then + /usr/bin/wg setconf "$IFACE" "$1" + else + eval /usr/bin/wg set "$IFACE" "$@" + fi + if [ $? -eq 0 ]; then + _up + eend 0 + return + fi + e=$? + ip link delete dev "$IFACE" type wireguard 2>/dev/null + eend $e +} + +wireguard_post_stop() +{ + ebegin "Removing WireGuard interface $IFACE" + ip link delete dev "$IFACE" type wireguard + eend $? +} diff --git a/net-misc/wireguard/wireguard-0.0.20161014.ebuild b/net-misc/wireguard/wireguard-0.0.20161014.ebuild index 83e13fc03a62..86294fa41502 100644 --- a/net-misc/wireguard/wireguard-0.0.20161014.ebuild +++ b/net-misc/wireguard/wireguard-0.0.20161014.ebuild @@ -53,6 +53,8 @@ src_install() { dodoc -r contrib/examples linux-mod_src_install emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" -C src/tools install + insinto /$(get_libdir)/netifrc/net + newins "${FILESDIR}"/wireguard-openrc.sh wireguard.sh } pkg_postinst() { diff --git a/net-misc/wireguard/wireguard-9999.ebuild b/net-misc/wireguard/wireguard-9999.ebuild index 83e13fc03a62..86294fa41502 100644 --- a/net-misc/wireguard/wireguard-9999.ebuild +++ b/net-misc/wireguard/wireguard-9999.ebuild @@ -53,6 +53,8 @@ src_install() { dodoc -r contrib/examples linux-mod_src_install emake DESTDIR="${D}" PREFIX="${EPREFIX}/usr" -C src/tools install + insinto /$(get_libdir)/netifrc/net + newins "${FILESDIR}"/wireguard-openrc.sh wireguard.sh } pkg_postinst() { |