mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 15:20:09 +01:00
Merge pull request #469 from DaanSelen/main
This commit is contained in:
commit
fdff54e11e
3
.github/workflows/docker-build.yaml
vendored
3
.github/workflows/docker-build.yaml
vendored
@ -30,9 +30,10 @@ jobs:
|
|||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Build and export
|
- name: Build and export (linux/amd64, linux/arm64, linux/arm/v7)
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ env.DOCKER_IMAGE }}:latest
|
tags: ${{ env.DOCKER_IMAGE }}:latest
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||||
|
@ -8,9 +8,6 @@ ARG wg_port="51820"
|
|||||||
# Following ENV variables are changable on container runtime because /entrypoint.sh handles that. See compose.yaml for more info.
|
# Following ENV variables are changable on container runtime because /entrypoint.sh handles that. See compose.yaml for more info.
|
||||||
ENV TZ="Europe/Amsterdam"
|
ENV TZ="Europe/Amsterdam"
|
||||||
ENV global_dns="1.1.1.1"
|
ENV global_dns="1.1.1.1"
|
||||||
|
|
||||||
ENV enable="none"
|
|
||||||
|
|
||||||
ENV isolate="none"
|
ENV isolate="none"
|
||||||
ENV public_ip="0.0.0.0"
|
ENV public_ip="0.0.0.0"
|
||||||
|
|
||||||
|
@ -3,14 +3,9 @@ services:
|
|||||||
image: donaldzou/wgdashboard:latest
|
image: donaldzou/wgdashboard:latest
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
container_name: wgdashboard
|
container_name: wgdashboard
|
||||||
environment:
|
#environment:
|
||||||
- tz=Europe/Amsterdam # <--- Set container timezone, default: Europe/Amsterdam.
|
|
||||||
- global_dns=9.9.9.9 # <--- Set global DNS address, default: 1.1.1.1.
|
|
||||||
|
|
||||||
#- tz= # <--- Set container timezone, default: Europe/Amsterdam.
|
#- tz= # <--- Set container timezone, default: Europe/Amsterdam.
|
||||||
#- global_dns= # <--- Set global DNS address, default: 1.1.1.1.
|
#- global_dns= # <--- Set global DNS address, default: 1.1.1.1.
|
||||||
|
|
||||||
#- enable= # <--- Set the interfaces that will be enabled on startup, default: 'none'.
|
|
||||||
#- isolate= # <--- Set the interfaces that will disallow peer communication, default: 'none'.
|
#- isolate= # <--- Set the interfaces that will disallow peer communication, default: 'none'.
|
||||||
#- public_ip= # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me.
|
#- public_ip= # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me.
|
||||||
ports:
|
ports:
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Path to the configuration file (exists because of previous function).
|
||||||
|
config_file="/data/wg-dashboard.ini"
|
||||||
|
|
||||||
echo "------------------------- START ----------------------------"
|
echo "------------------------- START ----------------------------"
|
||||||
echo "Starting the WireGuard Dashboard Docker container."
|
echo "Starting the WireGuard Dashboard Docker container."
|
||||||
|
|
||||||
@ -7,26 +10,39 @@ ensure_installation() {
|
|||||||
# When using a custom directory to store the files, this part moves over and makes sure the installation continues.
|
# When using a custom directory to store the files, this part moves over and makes sure the installation continues.
|
||||||
echo "Quick-installing..."
|
echo "Quick-installing..."
|
||||||
|
|
||||||
[ ! -d "/data/db" ] && echo "Creating database dir" && mkdir /data/db
|
if [ ! -d "/data/db" ]; then
|
||||||
ln -s /data/db "${WGDASH}/src/db"
|
echo "Creating database dir"
|
||||||
|
mkdir /data/db
|
||||||
|
fi
|
||||||
|
|
||||||
[ ! -f "/data/wg-dashboard.ini" ] && echo "Creating wg-dashboard.ini file" && touch /data/wg-dashboard.ini
|
if [ ! -d "${WGDASH}/src/db" ]; then
|
||||||
ln -s /data/wg-dashboard.ini "${WGDASH}/src/wg-dashboard.ini"
|
ln -s /data/db "${WGDASH}/src/db"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "${config_file}" ]; then
|
||||||
|
echo "Creating wg-dashboard.ini file"
|
||||||
|
touch "${config_file}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "${WGDASH}/src/wg-dashboard.ini" ]; then
|
||||||
|
ln -s "${config_file}" "${WGDASH}/src/wg-dashboard.ini"
|
||||||
|
fi
|
||||||
|
|
||||||
python3 -m venv "${WGDASH}"/src/venv
|
python3 -m venv "${WGDASH}"/src/venv
|
||||||
. "${WGDASH}/src/venv/bin/activate"
|
. "${WGDASH}/src/venv/bin/activate"
|
||||||
|
|
||||||
|
echo "Moving PIP dependency from ephemerality to runtime environment: psutil"
|
||||||
|
mv /usr/lib/python3.12/site-packages/psutil* "${WGDASH}"/src/venv/lib/python3.12/site-packages
|
||||||
|
|
||||||
|
echo "Moving PIP dependency from ephemerality to runtime environment: bcrypt"
|
||||||
[ ! -d "${WGDASH}/src/venv/lib/python3.12/site-packages/psutil" ] && echo "Moving PIP dependency: psutil" && mv /usr/lib/python3.12/site-packages/psutil* "${WGDASH}"/src/venv/lib/python3.12/site-packages
|
mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages
|
||||||
[ ! -d "${WGDASH}/src/venv/lib/python3.12/site-packages/bcrypt" ] && echo "Moving PIP dependency: bcrypt" && mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages
|
|
||||||
|
|
||||||
|
|
||||||
chmod +x "${WGDASH}"/src/wgd.sh
|
chmod +x "${WGDASH}"/src/wgd.sh
|
||||||
cd "${WGDASH}"/src || exit
|
cd "${WGDASH}"/src || exit
|
||||||
./wgd.sh install
|
./wgd.sh install
|
||||||
|
|
||||||
echo "Looks like the installation succeeded."
|
echo "Looks like the installation succeeded. Moving on."
|
||||||
|
|
||||||
# This first step is to ensure the wg0.conf file exists, and if not, then its copied over from the ephemeral container storage.
|
# This first step is to ensure the wg0.conf file exists, and if not, then its copied over from the ephemeral container storage.
|
||||||
# This is done so WGDashboard it works out of the box
|
# This is done so WGDashboard it works out of the box
|
||||||
@ -50,52 +66,45 @@ ensure_installation() {
|
|||||||
set_envvars() {
|
set_envvars() {
|
||||||
printf "\n------------- SETTING ENVIRONMENT VARIABLES ----------------\n"
|
printf "\n------------- SETTING ENVIRONMENT VARIABLES ----------------\n"
|
||||||
|
|
||||||
# Path to the configuration file (exists because of previous function).
|
|
||||||
local config_file="/opt/wireguarddashboard/src/wg-dashboard.ini"
|
|
||||||
|
|
||||||
# Check if the file is empty
|
# Check if the file is empty
|
||||||
if [ ! -s "$config_file" ]; then
|
if [ ! -s "${config_file}" ]; then
|
||||||
echo "Config file is empty. Creating [Peers] section."
|
echo "Config file is empty. Creating [Peers] section."
|
||||||
|
|
||||||
# Create [Peers] section with initial values
|
# Create [Peers] section with initial values
|
||||||
{
|
{
|
||||||
echo "[Peers]"
|
echo "[Peers]"
|
||||||
echo "remote_endpoint = ${public_ip}"
|
|
||||||
echo "peer_global_dns = ${global_dns}"
|
echo "peer_global_dns = ${global_dns}"
|
||||||
} > "$config_file"
|
echo "remote_endpoint = ${public_ip}"
|
||||||
|
#echo -e "\n[Server]"
|
||||||
|
} > "${config_file}"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Config file is not empty, enforcing environment variables."
|
echo "Config file is not empty, using pre-existing."
|
||||||
|
|
||||||
# Check and update the DNS if it has changed
|
|
||||||
current_dns=$(grep "peer_global_dns = " "$config_file" | awk '{print $NF}')
|
|
||||||
if [ "${global_dns}" != "$current_dns" ]; then
|
|
||||||
echo "Changing default DNS."
|
|
||||||
sed -i "s/^peer_global_dns = .*/peer_global_dns = ${global_dns}/" "$config_file"
|
|
||||||
else
|
|
||||||
echo "DNS is set correctly."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine the public IP and update if necessary
|
echo "Verifying current variables..."
|
||||||
echo "{$public_ip}"
|
|
||||||
|
# Check and update the DNS if it has changed
|
||||||
|
current_dns=$(grep "peer_global_dns = " "${config_file}" | awk '{print $NF}')
|
||||||
|
if [ "${global_dns}" == "$current_dns" ]; then
|
||||||
|
echo "DNS is correct, moving on."
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Changing default DNS..."
|
||||||
|
sed -i "s/^peer_global_dns = .*/peer_global_dns = ${global_dns}/" "${config_file}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${public_ip}" == "0.0.0.0" ]; then
|
||||||
|
|
||||||
if [ "${public_ip}" = "0.0.0.0" ]; then
|
|
||||||
default_ip=$(curl -s ifconfig.me)
|
default_ip=$(curl -s ifconfig.me)
|
||||||
|
|
||||||
echo "Trying to fetch the Public-IP using ifconfig.me: ${default_ip}"
|
echo "Trying to fetch the Public-IP using ifconfig.me: ${default_ip}"
|
||||||
sed -i "s/^remote_endpoint = .*/remote_endpoint = ${default_ip}/" "$config_file"
|
sed -i "s/^remote_endpoint = .*/remote_endpoint = ${default_ip}/" "${config_file}"
|
||||||
|
|
||||||
else
|
else
|
||||||
current_ip=$(grep "remote_endpoint = " "$config_file" | awk '{print $NF}')
|
echo "Public-IP is correct, moving on."
|
||||||
|
|
||||||
if [ "${public_ip}" != "$current_ip" ]; then
|
|
||||||
echo "Setting the Public-IP using given variable: ${public_ip}"
|
|
||||||
|
|
||||||
sed -i "s/^remote_endpoint = .*/remote_endpoint = ${public_ip}/" "$config_file"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# === CORE SERVICES ===
|
# === CORE SERVICES ===
|
||||||
@ -140,13 +149,16 @@ start_core() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Isolating the matches.
|
# Isolating the matches.
|
||||||
|
noneFound=0
|
||||||
|
|
||||||
for interface in "${do_isolate[@]}"; do
|
for interface in "${do_isolate[@]}"; do
|
||||||
|
|
||||||
if [ "$interface" = "none" ] || [ "$interface" = "" ]; then
|
if [ "$interface" = "none" ] || [ "$interface" = "" ]; then
|
||||||
echo "Found: $interface, stopping isolation checking."
|
echo "Found none, stopping isolation checking."
|
||||||
|
noneFound=1
|
||||||
break
|
break
|
||||||
else
|
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
if [ ! -f "/etc/wireguard/${interface}.conf" ]; then
|
if [ ! -f "/etc/wireguard/${interface}.conf" ]; then
|
||||||
echo "Ignoring ${interface}"
|
echo "Ignoring ${interface}"
|
||||||
@ -176,12 +188,13 @@ start_core() {
|
|||||||
|
|
||||||
|
|
||||||
for interface in "${non_isolate[@]}"; do
|
for interface in "${non_isolate[@]}"; do
|
||||||
if [ ! -f "/etc/wireguard/${interface}.conf" ]; then
|
if [ $noneFound -eq 1 ]; then
|
||||||
|
break
|
||||||
|
|
||||||
|
elif [ ! -f "/etc/wireguard/${interface}.conf" ]; then
|
||||||
echo "Ignoring ${interface}"
|
echo "Ignoring ${interface}"
|
||||||
|
|
||||||
elif [ -f "/etc/wireguard/${interface}.conf" ]; then
|
elif [ -f "/etc/wireguard/${interface}.conf" ]; then
|
||||||
|
|
||||||
|
|
||||||
echo "Removing isolation, if isolation is present for:" "$interface"
|
echo "Removing isolation, if isolation is present for:" "$interface"
|
||||||
|
|
||||||
sed -i "/PostUp = iptables -I FORWARD -i ${interface} -o ${interface} -j DROP/d" /etc/wireguard/"${interface}".conf
|
sed -i "/PostUp = iptables -I FORWARD -i ${interface} -o ${interface} -j DROP/d" /etc/wireguard/"${interface}".conf
|
||||||
|
@ -1881,8 +1881,8 @@ def API_getAllWireguardConfigurationBackup():
|
|||||||
files.sort(key=lambda x: x[1], reverse=True)
|
files.sort(key=lambda x: x[1], reverse=True)
|
||||||
|
|
||||||
for f, ct in files:
|
for f, ct in files:
|
||||||
if _regexMatch(f"^(.*)_(.*)\.(conf)$", f):
|
if _regexMatch(r"^(.*)_(.*)\.(conf)$", f):
|
||||||
s = re.search(f"^(.*)_(.*)\.(conf)$", f)
|
s = re.search(r"^(.*)_(.*)\.(conf)$", f)
|
||||||
name = s.group(1)
|
name = s.group(1)
|
||||||
if name not in existingConfiguration:
|
if name not in existingConfiguration:
|
||||||
if name not in data['NonExistingConfigurations'].keys():
|
if name not in data['NonExistingConfigurations'].keys():
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
"Turning Off...": "Uitzetten...",
|
"Turning Off...": "Uitzetten...",
|
||||||
"Address": "Adres",
|
"Address": "Adres",
|
||||||
"Listen Port": "Luisterpoort",
|
"Listen Port": "Luisterpoort",
|
||||||
"Public Key": "Public key",
|
"Public Key": "Publieke Sleutel",
|
||||||
"Connected Peers": "Verbonden Peers",
|
"Connected Peers": "Verbonden Peers",
|
||||||
"Total Usage": "Totaal Gebruik",
|
"Total Usage": "Totaal Gebruik",
|
||||||
"Total Received": "Totaal Ontvangen",
|
"Total Received": "Totaal Ontvangen",
|
||||||
@ -85,7 +85,7 @@
|
|||||||
"Active Jobs": "Actieve Taken",
|
"Active Jobs": "Actieve Taken",
|
||||||
"All Active Jobs": "Alle Actieve Taken",
|
"All Active Jobs": "Alle Actieve Taken",
|
||||||
"Logs": "Logboeken",
|
"Logs": "Logboeken",
|
||||||
"Private Key": "Private Key",
|
"Private Key": "Privé Sleutel",
|
||||||
"(Required for QR Code and Download)": "(Vereist voor QR-code en Download)",
|
"(Required for QR Code and Download)": "(Vereist voor QR-code en Download)",
|
||||||
"(Required)": "(Vereist)",
|
"(Required)": "(Vereist)",
|
||||||
"Endpoint Allowed IPs": "Allowed-IPs voor Eindpunt",
|
"Endpoint Allowed IPs": "Allowed-IPs voor Eindpunt",
|
||||||
@ -144,7 +144,7 @@
|
|||||||
"By adding peers by bulk, each peer's name will be auto generated, and Allowed IP will be assign to the next available IP.": "Bij het bulk toevoegen wordt de naam van elke peer automatisch gegenereerd en wordt de Allowed-IPs aan het volgende beschikbare IP toegewezen.",
|
"By adding peers by bulk, each peer's name will be auto generated, and Allowed IP will be assign to the next available IP.": "Bij het bulk toevoegen wordt de naam van elke peer automatisch gegenereerd en wordt de Allowed-IPs aan het volgende beschikbare IP toegewezen.",
|
||||||
"How many peers you want to add?": "Hoeveel peers wil je toevoegen?",
|
"How many peers you want to add?": "Hoeveel peers wil je toevoegen?",
|
||||||
"You can add up to (.*) peers": "Je kunt tot $1 peers toevoegen",
|
"You can add up to (.*) peers": "Je kunt tot $1 peers toevoegen",
|
||||||
"Use your own Private and Public Key": "Gebruik je eigen private- en public key",
|
"Use your own Private and Public Key": "Gebruik je eigen Privé- en Publieke Sleutel",
|
||||||
"Enter IP Address/CIDR": "Voer IP-adres/CIDR in",
|
"Enter IP Address/CIDR": "Voer IP-adres/CIDR in",
|
||||||
"IP Address/CIDR": "IP-adres/CIDR",
|
"IP Address/CIDR": "IP-adres/CIDR",
|
||||||
"or": "of",
|
"or": "of",
|
||||||
|
Loading…
Reference in New Issue
Block a user