distribution/packages/network/wireguard-tools/scripts/wg-keygen

26 lines
654 B
Text
Raw Normal View History

2022-02-05 14:23:32 +00:00
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2019-present Team LibreELEC (https://libreelec.tv)
if [ -x /usr/bin/wg ]; then
umask 077
mkdir -p /storage/.cache/wireguard
if [ ! -f /storage/.cache/wireguard/privatekey ]; then
wg genkey > /storage/.cache/wireguard/privatekey
fi
if [ ! -f /storage/.cache/wireguard/publickey ]; then
wg pubkey < /storage/.cache/wireguard/privatekey > /storage/.cache/wireguard/publickey
fi
if [ ! -f /storage/.cache/wireguard/preshared ]; then
wg genpsk > /storage/.cache/wireguard/preshared
fi
fi
echo "WireGuard keys have been saved to /storage/.cache/wireguard/"
exit 0