Skip to content

Instantly share code, notes, and snippets.

@Ne00n
Last active October 30, 2022 12:38
Show Gist options
  • Save Ne00n/aec590a479ee7cdac5e987b931df3062 to your computer and use it in GitHub Desktop.
Save Ne00n/aec590a479ee7cdac5e987b931df3062 to your computer and use it in GitHub Desktop.
wg boring
cat << 'EOF' > /usr/local/sbin/boringtun-upgrade
#!/bin/bash
#src https://github.com/Nyr/wireguard-install/blob/master/wireguard-install.sh
latest=$(wget -qO- https://wg.nyr.be/1/latest 2>/dev/null || curl -sL https://wg.nyr.be/1/latest 2>/dev/null)
# If server did not provide an appropriate response, exit
if ! head -1 <<< "$latest" | grep -qiE "^boringtun.+[0-9]+\.[0-9]+.*$"; then
echo "Update server unavailable"
exit
fi
current=$(/usr/local/sbin/boringtun -V)
if [[ "$current" != "$latest" ]]; then
download="https://wg.nyr.be/1/latest/download"
xdir=$(mktemp -d)
# If download and extraction are successful, upgrade the boringtun binary
if { wget -qO- "$download" 2>/dev/null || curl -sL "$download" ; } | tar xz -C "$xdir" --wildcards "boringtun-*/boringtun" --strip-components 1; then
systemctl stop [email protected]
rm -f /usr/local/sbin/boringtun
mv "$xdir"/boringtun /usr/local/sbin/boringtun
echo "Succesfully updated to $(/usr/local/sbin/boringtun -V)"
else
echo "boringtun update failed"
fi
rm -rf "$xdir"
else
echo "$current is up to date"
fi
EOF
chmod +x /usr/local/sbin/boringtun-upgrade
/usr/local/sbin/boringtun-upgrade
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment