Compare commits
2 Commits
master
...
with_wg_in
Author | SHA1 | Date | |
---|---|---|---|
![]() |
85aec24406 | ||
![]() |
3f0ce7949f |
@ -8,6 +8,12 @@ ORANGE='\033[0;33m'
|
||||
GREEN='\033[0;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
if [ -n "$WG_INSTANCE" ]; then
|
||||
PARAMS_FILE="/etc/wireguard/$WG_INSTANCE.params"
|
||||
else
|
||||
PARAMS_FILE=/etc/wireguard/wg0.params
|
||||
fi
|
||||
|
||||
function isRoot() {
|
||||
if [ "${EUID}" -ne 0 ]; then
|
||||
echo "You need to run this script as root"
|
||||
@ -121,7 +127,14 @@ function initialCheck() {
|
||||
}
|
||||
|
||||
function installQuestions() {
|
||||
echo "Welcome to the WireGuard installer!"
|
||||
local instance_label=
|
||||
local default_ifname=wg0
|
||||
if [ -n "$WG_INSTANCE" ]; then
|
||||
instance_label="($WG_INSTANCE instance) "
|
||||
default_ifname="wg_${WG_INSTANCE/-/_}"
|
||||
SERVER_WG_NIC="$WG_INSTANCE"
|
||||
fi
|
||||
echo "Welcome to the WireGuard ${instance_label}installer!"
|
||||
echo "The git repository is available at: https://github.com/angristan/wireguard-install"
|
||||
echo ""
|
||||
echo "I need to ask you a few questions before starting the setup."
|
||||
@ -143,7 +156,7 @@ function installQuestions() {
|
||||
done
|
||||
|
||||
until [[ ${SERVER_WG_NIC} =~ ^[a-zA-Z0-9_]+$ && ${#SERVER_WG_NIC} -lt 16 ]]; do
|
||||
read -rp "WireGuard interface name: " -e -i wg0 SERVER_WG_NIC
|
||||
read -rp "WireGuard interface name: " -e -i $default_ifname SERVER_WG_NIC
|
||||
done
|
||||
|
||||
until [[ ${SERVER_WG_IPV4} =~ ^([0-9]{1,3}\.){3} ]]; do
|
||||
@ -247,7 +260,7 @@ SERVER_PRIV_KEY=${SERVER_PRIV_KEY}
|
||||
SERVER_PUB_KEY=${SERVER_PUB_KEY}
|
||||
CLIENT_DNS_1=${CLIENT_DNS_1}
|
||||
CLIENT_DNS_2=${CLIENT_DNS_2}
|
||||
ALLOWED_IPS=${ALLOWED_IPS}" >/etc/wireguard/params
|
||||
ALLOWED_IPS=${ALLOWED_IPS}" >"$PARAMS_FILE"
|
||||
|
||||
# Add server interface
|
||||
echo "[Interface]
|
||||
@ -578,8 +591,8 @@ function manageMenu() {
|
||||
initialCheck
|
||||
|
||||
# Check if WireGuard is already installed and load params
|
||||
if [[ -e /etc/wireguard/params ]]; then
|
||||
source /etc/wireguard/params
|
||||
if [[ -e "$PARAMS_FILE" ]]; then
|
||||
source "$PARAMS_FILE"
|
||||
manageMenu
|
||||
else
|
||||
installWireGuard
|
||||
|
Loading…
x
Reference in New Issue
Block a user