mirror of
https://github.com/WGDashboard/WGDashboard.git
synced 2026-12-01 17:07:47 +00:00
Compare commits
6
Commits
22cbe06ccf
...
v4.3.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0018a9b1e2 | ||
|
|
dded6a86df | ||
|
|
4ee6b462dc | ||
|
|
e27dd986bc | ||
|
|
e6448f2ffd | ||
|
|
e2b5a59291 |
+8
-3
@@ -1,9 +1,14 @@
|
|||||||
.git
|
.git
|
||||||
.github
|
.github
|
||||||
*.md
|
|
||||||
tests/
|
tests/
|
||||||
docs/
|
docs/
|
||||||
|
|
||||||
|
*.md
|
||||||
|
|
||||||
|
**/node_modules
|
||||||
|
**/venv
|
||||||
|
**/__pycache__
|
||||||
|
**/*.pyc
|
||||||
|
|
||||||
src/db
|
src/db
|
||||||
src/wg-dashboard.ini
|
src/wg-dashboard.ini
|
||||||
src/static/app
|
|
||||||
src/static/client
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ jobs:
|
|||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
with:
|
with:
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -74,7 +74,7 @@ jobs:
|
|||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
platforms: linux/amd64,linux/arm64
|
||||||
|
|
||||||
docker_scan:
|
docker_scan:
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
if: ${{ github.event_name != 'pull_request' }}
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
FROM golang:1.24 AS awg-go
|
|
||||||
|
|
||||||
RUN git clone https://github.com/WGDashboard/amneziawg-go /awg
|
|
||||||
WORKDIR /awg
|
|
||||||
RUN go mod download && \
|
|
||||||
go mod verify && \
|
|
||||||
go build -ldflags '-linkmode external -extldflags "-fno-PIC -static"' -v -o /usr/bin
|
|
||||||
|
|
||||||
FROM alpine:latest AS awg-tools
|
|
||||||
|
|
||||||
RUN apk update && apk add --no-cache \
|
|
||||||
make git build-base linux-headers \
|
|
||||||
&& git clone https://github.com/WGDashboard/amneziawg-tools \
|
|
||||||
&& cd amneziawg-tools/src \
|
|
||||||
&& make \
|
|
||||||
&& chmod +x wg*
|
|
||||||
|
|
||||||
FROM alpine:latest
|
|
||||||
LABEL maintainer="[email protected]"
|
|
||||||
|
|
||||||
RUN apk update && apk add --no-cache \
|
|
||||||
iproute2 iptables bash curl wget unzip procps sudo \
|
|
||||||
tzdata wireguard-tools python3 py3-psutil py3-bcrypt openresolv
|
|
||||||
|
|
||||||
COPY --from=awg-go /usr/bin/amneziawg-go /usr/bin/amneziawg-go
|
|
||||||
COPY --from=awg-tools /amneziawg-tools/src/wg /usr/bin/awg
|
|
||||||
COPY --from=awg-tools /amneziawg-tools/src/wg-quick/linux.bash /usr/bin/awg-quick
|
|
||||||
|
|
||||||
# Declaring environment variables, change Peernet to an address you like, standard is a 24 bit subnet.
|
|
||||||
ARG wg_net="10.0.0.1" \
|
|
||||||
wg_port="51820"
|
|
||||||
|
|
||||||
# Following ENV variables are changable on container runtime because /entrypoint.sh handles that. See compose.yaml for more info.
|
|
||||||
ENV TZ="Europe/Amsterdam" \
|
|
||||||
global_dns="9.9.9.9" \
|
|
||||||
wgd_port="10086" \
|
|
||||||
public_ip=""
|
|
||||||
|
|
||||||
# Using WGDASH -- like wg_net functionally as a ARG command. But it is needed in entrypoint.sh so it needs to be exported as environment variable.
|
|
||||||
ENV WGDASH=/opt/wgdashboard
|
|
||||||
|
|
||||||
# Doing WireGuard Dashboard installation measures. Modify the git clone command to get the preferred version, with a specific branch for example.
|
|
||||||
RUN mkdir /data \
|
|
||||||
&& mkdir /configs \
|
|
||||||
&& mkdir -p ${WGDASH}/src \
|
|
||||||
&& mkdir -p /etc/amnezia/amneziawg
|
|
||||||
COPY ./src ${WGDASH}/src
|
|
||||||
|
|
||||||
# Generate basic WireGuard interface. Echoing the WireGuard interface config for readability, adjust if you want it for efficiency.
|
|
||||||
# Also setting the pipefail option, verbose: https://github.com/hadolint/hadolint/wiki/DL4006.
|
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
|
||||||
RUN out_adapt=$(ip -o -4 route show to default | awk '{print $NF}') \
|
|
||||||
&& echo -e "[Interface]\n\
|
|
||||||
Address = ${wg_net}/24\n\
|
|
||||||
PrivateKey =\n\
|
|
||||||
PostUp = iptables -t nat -I POSTROUTING 1 -s ${wg_net}/24 -o ${out_adapt} -j MASQUERADE\n\
|
|
||||||
PostUp = iptables -I FORWARD -i wg0 -o wg0 -j DROP\n\
|
|
||||||
PreDown = iptables -t nat -D POSTROUTING -s ${wg_net}/24 -o ${out_adapt} -j MASQUERADE\n\
|
|
||||||
PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP\n\
|
|
||||||
ListenPort = ${wg_port}\n\
|
|
||||||
SaveConfig = true\n\
|
|
||||||
DNS = ${global_dns}" > /configs/wg0.conf.template \
|
|
||||||
&& chmod 600 /configs/wg0.conf.template
|
|
||||||
|
|
||||||
# Defining a way for Docker to check the health of the container. In this case: checking the gunicorn process.
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
|
||||||
CMD sh -c 'pgrep gunicorn > /dev/null && pgrep tail > /dev/null' || exit 1
|
|
||||||
|
|
||||||
# Copy the basic entrypoint.sh script.
|
|
||||||
COPY ./docker/entrypoint.sh /entrypoint.sh
|
|
||||||
|
|
||||||
# Exposing the default WireGuard Dashboard port for web access.
|
|
||||||
EXPOSE 10086
|
|
||||||
WORKDIR $WGDASH
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|
|
||||||
+42
-9
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Pull the current golang-alpine image.
|
# Pull the current golang-alpine image.
|
||||||
FROM golang:1.26-alpine3.23 AS awg-go
|
FROM golang:1.27-alpine3.24 AS awg-go-builder
|
||||||
|
|
||||||
# Install build-dependencies.
|
# Install build-dependencies.
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
@@ -30,7 +30,7 @@ RUN go version && \
|
|||||||
# AWG TOOLS BUILDING STAGE
|
# AWG TOOLS BUILDING STAGE
|
||||||
# Base: Alpine
|
# Base: Alpine
|
||||||
#
|
#
|
||||||
FROM alpine:3.24 AS awg-tools
|
FROM alpine:3.24 AS awg-tools-builder
|
||||||
|
|
||||||
# Install needed dependencies.
|
# Install needed dependencies.
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
@@ -55,7 +55,7 @@ RUN make && chmod +x wg*
|
|||||||
#
|
#
|
||||||
|
|
||||||
# Use the python-alpine image for building pip dependencies
|
# Use the python-alpine image for building pip dependencies
|
||||||
FROM python:3.14-alpine3.23 AS pip-builder
|
FROM python:3.15-alpine3.24 AS pip-builder
|
||||||
|
|
||||||
ARG TARGETPLATFORM
|
ARG TARGETPLATFORM
|
||||||
|
|
||||||
@@ -85,13 +85,32 @@ RUN . /opt/wgdashboard/src/venv/bin/activate && \
|
|||||||
pip3 install --upgrade pip && \
|
pip3 install --upgrade pip && \
|
||||||
pip3 install -r /opt/wgdashboard/src/requirements.txt
|
pip3 install -r /opt/wgdashboard/src/requirements.txt
|
||||||
|
|
||||||
|
#
|
||||||
|
# WGDashboard FRONTEND BUILDING
|
||||||
|
# Base: Node Alpine
|
||||||
|
#
|
||||||
|
FROM node:26-alpine3.24 AS frontend-builder
|
||||||
|
|
||||||
|
WORKDIR /workspace
|
||||||
|
|
||||||
|
# Copy frontend source, package files and lockfiles
|
||||||
|
COPY ./src/static/ ./
|
||||||
|
|
||||||
|
# Build the admin frontend
|
||||||
|
WORKDIR /workspace/app
|
||||||
|
RUN npm ci && npm run build
|
||||||
|
|
||||||
|
# Build the client frontend
|
||||||
|
WORKDIR /workspace/client
|
||||||
|
RUN npm ci && npm run build
|
||||||
|
|
||||||
#
|
#
|
||||||
# WGDashboard RUNNING STAGE
|
# WGDashboard RUNNING STAGE
|
||||||
# Base: Alpine
|
# Base: Alpine
|
||||||
#
|
#
|
||||||
|
|
||||||
# Running with the python-alpine image.
|
# Running with the python-alpine image.
|
||||||
FROM python:3.14-alpine3.23 AS final
|
FROM python:3.15-alpine3.24 AS final
|
||||||
LABEL maintainer="[email protected]"
|
LABEL maintainer="[email protected]"
|
||||||
|
|
||||||
# Install only the runtime dependencies
|
# Install only the runtime dependencies
|
||||||
@@ -102,9 +121,9 @@ RUN apk add --no-cache \
|
|||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
# Copy only the final binaries from the AWG builder stages
|
# Copy only the final binaries from the AWG builder stages
|
||||||
COPY --from=awg-go /usr/bin/amneziawg-go /usr/bin/amneziawg-go
|
COPY --from=awg-go-builder /usr/bin/amneziawg-go /usr/bin/amneziawg-go
|
||||||
COPY --from=awg-tools /workspace/awg-tools/src/wg /usr/bin/awg
|
COPY --from=awg-tools-builder /workspace/awg-tools/src/wg /usr/bin/awg
|
||||||
COPY --from=awg-tools /workspace/awg-tools/src/wg-quick/linux.bash /usr/bin/awg-quick
|
COPY --from=awg-tools-builder /workspace/awg-tools/src/wg-quick/linux.bash /usr/bin/awg-quick
|
||||||
|
|
||||||
# Environment variables
|
# Environment variables
|
||||||
ARG wg_net="10.0.0.1"
|
ARG wg_net="10.0.0.1"
|
||||||
@@ -121,11 +140,25 @@ ENV TZ="Europe/Amsterdam" \
|
|||||||
RUN mkdir /data /configs -p ${WGDASH}/src /etc/amnezia/amneziawg \
|
RUN mkdir /data /configs -p ${WGDASH}/src /etc/amnezia/amneziawg \
|
||||||
&& echo "name_servers=${global_dns}" >> /etc/resolvconf.conf
|
&& echo "name_servers=${global_dns}" >> /etc/resolvconf.conf
|
||||||
|
|
||||||
# Copy the venv and source files from local compiled locations or repos
|
# Copy application source
|
||||||
COPY ./src ${WGDASH}/src
|
COPY ./src ${WGDASH}/src
|
||||||
COPY --from=pip-builder /opt/wgdashboard/src/venv /opt/wgdashboard/src/venv
|
|
||||||
|
# Copy Python dependencies
|
||||||
|
COPY --from=pip-builder \
|
||||||
|
/opt/wgdashboard/src/venv \
|
||||||
|
${WGDASH}/src/venv
|
||||||
|
|
||||||
|
RUN rm -rf ${WGDASH}/src/static/dist \
|
||||||
|
${WGDASH}/src/static/app \
|
||||||
|
${WGDASH}/src/static/client
|
||||||
|
|
||||||
|
COPY --from=frontend-builder \
|
||||||
|
/workspace/dist/ \
|
||||||
|
${WGDASH}/src/static/dist/
|
||||||
|
|
||||||
COPY ./docker/wg0.conf.template /tmp/wg0.conf.template
|
COPY ./docker/wg0.conf.template /tmp/wg0.conf.template
|
||||||
COPY ./docker/wg-dashboard-oidc-providers.json.template /tmp/wg-dashboard-oidc-providers.json.template
|
COPY ./docker/wg-dashboard-oidc-providers.json.template /tmp/wg-dashboard-oidc-providers.json.template
|
||||||
|
|
||||||
# Copy in the runtime script, essential.
|
# Copy in the runtime script, essential.
|
||||||
COPY ./docker/entrypoint.sh /entrypoint.sh
|
COPY ./docker/entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
|
|||||||
+7
-9
@@ -9,8 +9,7 @@ from zipfile import ZipFile
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from jinja2 import Template
|
from flask import Flask, request, render_template, session, send_file, current_app
|
||||||
from flask import Flask, request, render_template, session, send_file, current_app, redirect, url_for
|
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
from icmplib import ping, traceroute
|
from icmplib import ping, traceroute
|
||||||
from flask.json.provider import DefaultJSONProvider
|
from flask.json.provider import DefaultJSONProvider
|
||||||
@@ -20,7 +19,8 @@ from sqlalchemy import RowMapping
|
|||||||
|
|
||||||
from modules.Utilities import (
|
from modules.Utilities import (
|
||||||
RegexMatch, StringToBoolean, ValidateDNSAddress,
|
RegexMatch, StringToBoolean, ValidateDNSAddress,
|
||||||
GenerateWireguardPublicKey, GenerateWireguardPrivateKey
|
GenerateWireguardPublicKey, GenerateWireguardPrivateKey,
|
||||||
|
RenderSandboxedTemplate
|
||||||
)
|
)
|
||||||
from packaging import version
|
from packaging import version
|
||||||
from modules.Email import EmailSender
|
from modules.Email import EmailSender
|
||||||
@@ -1597,10 +1597,9 @@ def API_Email_Send():
|
|||||||
if configuration is not None:
|
if configuration is not None:
|
||||||
fp, p = configuration.searchPeer(data.get('Peer'))
|
fp, p = configuration.searchPeer(data.get('Peer'))
|
||||||
if fp:
|
if fp:
|
||||||
template = Template(body)
|
|
||||||
download = p.downloadPeer()
|
download = p.downloadPeer()
|
||||||
body = template.render(peer=p.toJson(), configurationFile=download)
|
body = RenderSandboxedTemplate(body, peer=p.toJson(), configurationFile=download)
|
||||||
subject = Template(data.get('Subject', '')).render(peer=p.toJson(), configurationFile=download)
|
subject = RenderSandboxedTemplate(data.get('Subject', ''), peer=p.toJson(), configurationFile=download)
|
||||||
if data.get('IncludeAttachment', False):
|
if data.get('IncludeAttachment', False):
|
||||||
u = str(uuid4())
|
u = str(uuid4())
|
||||||
peerName = p.toJson().get('name', '').strip()
|
peerName = p.toJson().get('name', '').strip()
|
||||||
@@ -1629,11 +1628,10 @@ def API_Email_PreviewBody():
|
|||||||
return ResponseObject(False, "Peer does not exist")
|
return ResponseObject(False, "Peer does not exist")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
template = Template(body)
|
|
||||||
download = p.downloadPeer()
|
download = p.downloadPeer()
|
||||||
return ResponseObject(data={
|
return ResponseObject(data={
|
||||||
"Body": Template(body).render(peer=p.toJson(), configurationFile=download),
|
"Body": RenderSandboxedTemplate(body, peer=p.toJson(), configurationFile=download),
|
||||||
"Subject": Template(subject).render(peer=p.toJson(), configurationFile=download)
|
"Subject": RenderSandboxedTemplate(subject, peer=p.toJson(), configurationFile=download)
|
||||||
})
|
})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return ResponseObject(False, message=str(e))
|
return ResponseObject(False, message=str(e))
|
||||||
|
|||||||
+3
-3
@@ -7,12 +7,12 @@ import json
|
|||||||
import os, subprocess, uuid, random, re
|
import os, subprocess, uuid, random, re
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
import jinja2
|
|
||||||
import sqlalchemy as db
|
import sqlalchemy as db
|
||||||
from .PeerJob import PeerJob
|
from .PeerJob import PeerJob
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
from .PeerShareLink import PeerShareLink
|
from .PeerShareLink import PeerShareLink
|
||||||
from .Utilities import GenerateWireguardPublicKey, CheckAddress, ValidateDNSAddress
|
from .Utilities import GenerateWireguardPublicKey, CheckAddress, ValidateDNSAddress, \
|
||||||
|
RenderSandboxedTemplate
|
||||||
|
|
||||||
|
|
||||||
class Peer:
|
class Peer:
|
||||||
@@ -237,7 +237,7 @@ class Peer:
|
|||||||
if val is not None and ((type(val) is str and len(val) > 0) or (type(val) is int and val > 0)):
|
if val is not None and ((type(val) is str and len(val) > 0) or (type(val) is int and val > 0)):
|
||||||
final["file"] += f"{key} = {val}\n"
|
final["file"] += f"{key} = {val}\n"
|
||||||
|
|
||||||
final["file"] = jinja2.Template(final["file"]).render(configuration=self.configuration)
|
final["file"] = RenderSandboxedTemplate(final["file"], configuration=self.configuration)
|
||||||
|
|
||||||
|
|
||||||
if self.configuration.Protocol == "awg":
|
if self.configuration.Protocol == "awg":
|
||||||
|
|||||||
@@ -1,6 +1,21 @@
|
|||||||
import re, ipaddress
|
import re, ipaddress
|
||||||
import subprocess
|
import subprocess
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
|
from jinja2.sandbox import SandboxedEnvironment
|
||||||
|
|
||||||
|
sandboxEnvironment = SandboxedEnvironment()
|
||||||
|
|
||||||
|
def RenderSandboxedTemplate(source: str, **context) -> str:
|
||||||
|
"""
|
||||||
|
Render a Jinja2 template within a sandboxed environment. Template sources built with
|
||||||
|
user-provided content (e.g. email body, peer configuration file) must go through this
|
||||||
|
function, so unsafe attribute access (such as __globals__) is denied and template
|
||||||
|
injection cannot escalate into arbitrary code execution.
|
||||||
|
@param source: Template source string, may contain user-provided content
|
||||||
|
@param context: Variables passed into the template
|
||||||
|
@return: Rendered template
|
||||||
|
"""
|
||||||
|
return sandboxEnvironment.from_string(source).render(**context)
|
||||||
|
|
||||||
def RegexMatch(regex, text) -> bool:
|
def RegexMatch(regex, text) -> bool:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ WireGuard Configuration
|
|||||||
"""
|
"""
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import jinja2
|
|
||||||
import sqlalchemy, random, shutil, configparser, ipaddress, os, subprocess, time, re, uuid, psutil, traceback
|
import sqlalchemy, random, shutil, configparser, ipaddress, os, subprocess, time, re, uuid, psutil, traceback
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
@@ -21,7 +20,8 @@ from .Utilities import StringToBoolean, \
|
|||||||
ValidateDNSAddress, \
|
ValidateDNSAddress, \
|
||||||
ValidateEndpointAllowedIPs, \
|
ValidateEndpointAllowedIPs, \
|
||||||
CheckAddress, \
|
CheckAddress, \
|
||||||
CheckPeerKey
|
CheckPeerKey, \
|
||||||
|
RenderSandboxedTemplate
|
||||||
from .WireguardConfigurationInfo import WireguardConfigurationInfo, PeerGroupsClass
|
from .WireguardConfigurationInfo import WireguardConfigurationInfo, PeerGroupsClass
|
||||||
from .DashboardWebHooks import DashboardWebHooks
|
from .DashboardWebHooks import DashboardWebHooks
|
||||||
|
|
||||||
@@ -1242,7 +1242,7 @@ class WireguardConfiguration:
|
|||||||
elif key == "OverridePeerSettings":
|
elif key == "OverridePeerSettings":
|
||||||
for (key, val) in value.items():
|
for (key, val) in value.items():
|
||||||
try:
|
try:
|
||||||
status, msg = self.__validateOverridePeerSettings(key, jinja2.Template(val).render(configuration=self.toJson()))
|
status, msg = self.__validateOverridePeerSettings(key, RenderSandboxedTemplate(val, configuration=self.toJson()))
|
||||||
if not status:
|
if not status:
|
||||||
return False, msg, key
|
return False, msg, key
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ pyotp==2.10.0
|
|||||||
Flask==3.1.2
|
Flask==3.1.2
|
||||||
flask-cors==6.0.5
|
flask-cors==6.0.5
|
||||||
icmplib==3.0.4
|
icmplib==3.0.4
|
||||||
gunicorn==26.0.0
|
gunicorn==26.2.0
|
||||||
requests==2.34.2
|
requests==2.34.2
|
||||||
tcconfig==0.30.1
|
tcconfig==0.30.1
|
||||||
sqlalchemy==2.0.51
|
sqlalchemy==2.1.6
|
||||||
sqlalchemy_utils==0.42.1
|
sqlalchemy_utils==0.43.0
|
||||||
psycopg[binary]==3.3.4
|
psycopg[binary]==3.3.6
|
||||||
PyMySQL==1.2.0
|
PyMySQL==1.2.3
|
||||||
tzlocal==5.3.1
|
tzlocal==5.4.5
|
||||||
python-jose==3.5.0
|
python-jose[cryptography]==3.5.0
|
||||||
pydantic==2.13.4
|
pydantic==2.14.1
|
||||||
|
|||||||
Generated
+1775
-2412
File diff suppressed because it is too large
Load Diff
+18
-18
@@ -12,36 +12,36 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@volar/language-server": "2.4.28",
|
"@volar/language-server": "2.4.30",
|
||||||
"@vue/language-server": "3.2.7",
|
"@vue/language-server": "3.3.13",
|
||||||
"@vuepic/vue-datepicker": "^14.0.0",
|
"@vuepic/vue-datepicker": "^14.0.0",
|
||||||
"@vueuse/core": "^14.2.1",
|
"@vueuse/core": "^15.0.0",
|
||||||
"@vueuse/shared": "^14.3.0",
|
"@vueuse/shared": "^15.0.0",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"bootstrap": "^5.3.2",
|
"bootstrap": "^5.3.2",
|
||||||
"bootstrap-icons": "^1.11.3",
|
"bootstrap-icons": "^1.13.2",
|
||||||
"cidr-tools": "^12.0.2",
|
"cidr-tools": "^13.0.4",
|
||||||
"css-color-converter": "^2.0.0",
|
"css-color-converter": "^2.0.0",
|
||||||
"dayjs": "^1.11.19",
|
"dayjs": "^1.11.23",
|
||||||
"electron-builder": "^26.7.0",
|
"electron-builder": "^26.18.0",
|
||||||
"fuse.js": "^7.3.0",
|
"fuse.js": "^7.5.0",
|
||||||
"i": "^0.3.7",
|
"i": "^0.3.7",
|
||||||
"is-cidr": "^6.0.3",
|
"is-cidr": "^7.0.3",
|
||||||
"npm": "^11.13.0",
|
"npm": "^12.2.1",
|
||||||
"ol": "^10.9.0",
|
"ol": "^10.11.0",
|
||||||
"pinia": "^3.0.4",
|
"pinia": "^4.1.0",
|
||||||
"pinia-plugin-persistedstate": "^4.7.1",
|
"pinia-plugin-persistedstate": "^4.7.1",
|
||||||
"qrcode": "^1.5.3",
|
"qrcode": "^1.5.3",
|
||||||
"qrcodejs": "^1.0.0",
|
"qrcodejs": "^1.0.0",
|
||||||
"simple-code-editor": "^2.0.9",
|
"simple-code-editor": "^2.0.9",
|
||||||
"uuid": "^14.0.0",
|
"uuid": "^14.0.3",
|
||||||
"vue": "^3.5.32",
|
"vue": "^3.5.32",
|
||||||
"vue-chartjs": "^5.3.3",
|
"vue-chartjs": "^5.3.4",
|
||||||
"vue-router": "^5.0.6"
|
"vue-router": "^5.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^6.0.6",
|
"@vitejs/plugin-vue": "^6.0.10",
|
||||||
"vite": "^8.0.16"
|
"vite": "^8.3.5"
|
||||||
},
|
},
|
||||||
"overrides": {
|
"overrides": {
|
||||||
"tar": "^7.5.6"
|
"tar": "^7.5.6"
|
||||||
|
|||||||
Generated
+534
-676
File diff suppressed because it is too large
Load Diff
@@ -9,20 +9,20 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.18.0",
|
"axios": "^1.20.0",
|
||||||
"bootstrap": "^5.3.8",
|
"bootstrap": "^5.3.8",
|
||||||
"bootstrap-icons": "^1.13.1",
|
"bootstrap-icons": "^1.13.2",
|
||||||
"dayjs": "^1.11.21",
|
"dayjs": "^1.11.23",
|
||||||
"oidc-client-ts": "^3.5.0",
|
"oidc-client-ts": "^3.5.0",
|
||||||
"pinia": "^3.0.4",
|
"pinia": "^4.1.0",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"uuid": "^14.0.0",
|
"uuid": "^14.0.3",
|
||||||
"vue": "^3.5.35",
|
"vue": "^3.5.44",
|
||||||
"vue-router": "^5.1.0"
|
"vue-router": "^5.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^6.0.6",
|
"@vitejs/plugin-vue": "^6.0.10",
|
||||||
"vite": "^8.0.16",
|
"vite": "^8.3.5",
|
||||||
"vite-plugin-vue-devtools": "^8.1.2"
|
"vite-plugin-vue-devtools": "^8.2.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+208
-102
@@ -5,12 +5,17 @@
|
|||||||
#trap "kill $TOP_PID"
|
#trap "kill $TOP_PID"
|
||||||
export TOP_PID=$$
|
export TOP_PID=$$
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Configuration
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
app_name="dashboard.py"
|
app_name="dashboard.py"
|
||||||
app_official_name="WGDashboard"
|
app_official_name="WGDashboard"
|
||||||
venv_python="./venv/bin/python3"
|
venv_python="./venv/bin/python3"
|
||||||
venv_gunicorn="./venv/bin/gunicorn"
|
venv_gunicorn="./venv/bin/gunicorn"
|
||||||
pythonExecutable="python3"
|
pythonExecutable="python3"
|
||||||
|
|
||||||
|
frontend_dirs=("./static/app" "./static/client")
|
||||||
|
|
||||||
heavy_checkmark=$(printf "\xE2\x9C\x85")
|
heavy_checkmark=$(printf "\xE2\x9C\x85")
|
||||||
heavy_crossmark=$(printf "\xE2\x9D\x8C")
|
heavy_crossmark=$(printf "\xE2\x9D\x8C")
|
||||||
install=$(printf "\xF0\x9F\x92\xBF")
|
install=$(printf "\xF0\x9F\x92\xBF")
|
||||||
@@ -30,6 +35,10 @@ fi
|
|||||||
dashes='---------------------------------------------------------------------------------'
|
dashes='---------------------------------------------------------------------------------'
|
||||||
equals='============================================================'
|
equals='============================================================'
|
||||||
helpMsg="[WGDashboard] Please check ./log/install.txt for more details. For further assistance, please open a ticket on https://github.com/WGDashboard/WGDashboard/issues/new/choose, I'm more than happy to help :)"
|
helpMsg="[WGDashboard] Please check ./log/install.txt for more details. For further assistance, please open a ticket on https://github.com/WGDashboard/WGDashboard/issues/new/choose, I'm more than happy to help :)"
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Output helpers
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
print_header(){
|
print_header(){
|
||||||
printf "=================================================================================\n"
|
printf "=================================================================================\n"
|
||||||
printf "+ <WGDashboard> by Donald Zou - https://github.com/donaldzou +\n"
|
printf "+ <WGDashboard> by Donald Zou - https://github.com/donaldzou +\n"
|
||||||
@@ -49,6 +58,19 @@ help () {
|
|||||||
printf "=================================================================================\n"
|
printf "=================================================================================\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_logSection(){
|
||||||
|
{ printf "\n\n [%s] [%s] \n\n" "$1" "$(date)"; } >> ./log/install.txt
|
||||||
|
}
|
||||||
|
|
||||||
|
_unsupportedOS(){
|
||||||
|
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark"
|
||||||
|
printf "%s\n" "$helpMsg"
|
||||||
|
kill $TOP_PID
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Environment detection
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
_check_and_set_venv(){
|
_check_and_set_venv(){
|
||||||
VIRTUAL_ENV="./venv"
|
VIRTUAL_ENV="./venv"
|
||||||
if [ ! -d $VIRTUAL_ENV ]; then
|
if [ ! -d $VIRTUAL_ENV ]; then
|
||||||
@@ -72,15 +94,16 @@ _determineOS(){
|
|||||||
elif [ -f /etc/redhat-release ]; then
|
elif [ -f /etc/redhat-release ]; then
|
||||||
OS="redhat"
|
OS="redhat"
|
||||||
else
|
else
|
||||||
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark"
|
_unsupportedOS
|
||||||
printf "%s\n" "$helpMsg"
|
|
||||||
kill $TOP_PID
|
|
||||||
fi
|
fi
|
||||||
printf "[WGDashboard] OS: %s\n" "$OS"
|
printf "[WGDashboard] OS: %s\n" "$OS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Python
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
_installPython(){
|
_installPython(){
|
||||||
{ printf "\n\n [Installing Python] [%s] \n\n""$(date)"; } >> ./log/install.txt
|
_logSection "Installing Python"
|
||||||
printf "[WGDashboard] %s Installing Python\n" "$install"
|
printf "[WGDashboard] %s Installing Python\n" "$install"
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
ubuntu|debian|raspbian)
|
ubuntu|debian|raspbian)
|
||||||
@@ -112,7 +135,7 @@ _installPython(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
_installPythonVenv(){
|
_installPythonVenv(){
|
||||||
{ printf "\n\n [Installing Python Venv] [%s] \n\n""$(date)"; } >> ./log/install.txt
|
_logSection "Installing Python Venv"
|
||||||
printf "[WGDashboard] %s Installing Python Virtual Environment\n" "$install"
|
printf "[WGDashboard] %s Installing Python Virtual Environment\n" "$install"
|
||||||
if [ "$pythonExecutable" = "python3" ]; then
|
if [ "$pythonExecutable" = "python3" ]; then
|
||||||
case "$OS" in
|
case "$OS" in
|
||||||
@@ -133,9 +156,7 @@ _installPythonVenv(){
|
|||||||
{ echo "Python Virtual Environment is installed by default from version Python3.3"; printf "\n\n"; } &>> ./log/install.txt # https://wiki.archlinux.org/title/Python/Virtual_environment
|
{ echo "Python Virtual Environment is installed by default from version Python3.3"; printf "\n\n"; } &>> ./log/install.txt # https://wiki.archlinux.org/title/Python/Virtual_environment
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark"
|
_unsupportedOS
|
||||||
printf "%s\n" "$helpMsg"
|
|
||||||
kill $TOP_PID
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
@@ -156,7 +177,7 @@ _installPythonVenv(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
_installPythonPip(){
|
_installPythonPip(){
|
||||||
{ printf "\n\n [Installing Python Pip] [%s] \n\n""$(date)"; } >> ./log/install.txt
|
_logSection "Installing Python Pip"
|
||||||
|
|
||||||
if ! $pythonExecutable -m pip -h > /dev/null 2>&1
|
if ! $pythonExecutable -m pip -h > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
@@ -183,9 +204,7 @@ _installPythonPip(){
|
|||||||
{ sudo pacman -Syu python-pip; printf "\n\n"; } &>> ./log/install.txt
|
{ sudo pacman -Syu python-pip; printf "\n\n"; } &>> ./log/install.txt
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS. With experimental support for Alpine Linux.\n" "$heavy_crossmark"
|
_unsupportedOS
|
||||||
printf "%s\n" "$helpMsg"
|
|
||||||
kill $TOP_PID
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
@@ -200,6 +219,82 @@ _installPythonPip(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_checkPythonVersion(){
|
||||||
|
version_pass=$($pythonExecutable -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 12) else print("0");')
|
||||||
|
version=$($pythonExecutable --version)
|
||||||
|
if [ $version_pass == "1" ]
|
||||||
|
then
|
||||||
|
printf "[WGDashboard] %s Found compatible version of Python. Will be using %s to install WGDashboard.\n" "$heavy_checkmark" "$($pythonExecutable --version)"
|
||||||
|
return;
|
||||||
|
elif python3.12 --version > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
printf "[WGDashboard] %s Found Python 3.12. Will be using [python3.12] to install WGDashboard.\n" "$heavy_checkmark"
|
||||||
|
pythonExecutable="python3.12"
|
||||||
|
else
|
||||||
|
printf "[WGDashboard] %s Could not find a compatible version of Python. Current Python is %s.\n" "$heavy_crossmark" "$version"
|
||||||
|
printf "[WGDashboard] WGDashboard required Python 3.12 or above. Halting install now.\n"
|
||||||
|
kill $TOP_PID
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_determinePypiMirror(){
|
||||||
|
printf "[WGDashboard] %s Pinging list of recommended Python Package Index mirror\n" "$install"
|
||||||
|
urls=(
|
||||||
|
"https://pypi.org/simple/"
|
||||||
|
"https://pypi.tuna.tsinghua.edu.cn/simple/"
|
||||||
|
"https://pypi.mirrors.ustc.edu.cn/simple/"
|
||||||
|
"https://mirrors.aliyun.com/pypi/simple/"
|
||||||
|
"https://pypi.douban.com/simple/"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Ping each mirror's hostname once and extract the RTT
|
||||||
|
index=1
|
||||||
|
printf " ---------------------------------------------------------\n"
|
||||||
|
for url in "${urls[@]}"; do
|
||||||
|
hostname=$(echo "$url" | awk -F/ '{print $3}')
|
||||||
|
rtt=$(ping -c 1 -W 1 "$hostname" 2>/dev/null | grep 'time=' | awk -F'time=' '{print $2}' | awk '{print $1}')
|
||||||
|
# Handle cases where the hostname is not reachable
|
||||||
|
if [ -z "$rtt" ]; then
|
||||||
|
rtt="9999"
|
||||||
|
printf " [%i] [FAILED] %s\n" "$index" "$url"
|
||||||
|
else
|
||||||
|
rtt=${rtt//.*/}
|
||||||
|
printf " [%i] %sms %s\n" "$index" "$rtt" "$url"
|
||||||
|
fi
|
||||||
|
rtthost[$index]=$rtt
|
||||||
|
index=$((index+1))
|
||||||
|
done
|
||||||
|
printf " ---------------------------------------------------------\n"
|
||||||
|
for i in "${!rtthost[@]}"; do
|
||||||
|
[[ -z ${rtthost[i]} ]] && continue # Skip unset or empty values
|
||||||
|
if [[ -z $min_val || ${rtthost[i]} -lt $min_val ]]; then
|
||||||
|
min_val=${rtthost[i]}
|
||||||
|
min_idx=$i
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
min_idx=$((min_idx - 1))
|
||||||
|
|
||||||
|
printf " Which mirror you would like to use (Hit enter to use default)\n"
|
||||||
|
printf " Default is %s :" "${urls[$min_idx]}"
|
||||||
|
read -t ${msleep} -r choice
|
||||||
|
printf "\n"
|
||||||
|
|
||||||
|
if [[ -z "$choice" ]]; then
|
||||||
|
choice=$((min_idx + 1))
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#urls[@]} )); then
|
||||||
|
selected_url="${urls[choice-1]}"
|
||||||
|
printf "[WGDashboard] %s Will download Python packages from %s\n" "$heavy_checkmark" "$selected_url"
|
||||||
|
else
|
||||||
|
selected_url="${urls[0]}"
|
||||||
|
printf "[WGDashboard] %s Will download Python packages from %s\n" "$heavy_checkmark" "${urls[0]}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# WireGuard
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
_checkWireguard(){
|
_checkWireguard(){
|
||||||
if ! command -v wg > /dev/null 2>&1 || ! command -v wg-quick > /dev/null 2>&1
|
if ! command -v wg > /dev/null 2>&1 || ! command -v wg-quick > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
@@ -243,81 +338,100 @@ _checkWireguard(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Frontend (Node.js) - Docker builds the frontend itself, so this is only for
|
||||||
|
# bare-metal installs.
|
||||||
_checkPythonVersion(){
|
#------------------------------------------------------------------------------
|
||||||
version_pass=$($pythonExecutable -c 'import sys; print("1") if (sys.version_info.major == 3 and sys.version_info.minor >= 12) else print("0");')
|
_installNode(){
|
||||||
version=$($pythonExecutable --version)
|
_logSection "Installing Node.js"
|
||||||
if [ $version_pass == "1" ]
|
printf "[WGDashboard] %s Installing Node.js and npm\n" "$install"
|
||||||
then
|
case "$OS" in
|
||||||
printf "[WGDashboard] %s Found compatible version of Python. Will be using %s to install WGDashboard.\n" "$heavy_checkmark" "$($pythonExecutable --version)"
|
ubuntu|debian|raspbian)
|
||||||
return;
|
{ sudo apt update ; sudo apt-get install -y nodejs npm; printf "\n\n"; } &>> ./log/install.txt
|
||||||
elif python3.12 --version > /dev/null 2>&1
|
;;
|
||||||
then
|
centos|fedora|redhat|rhel|almalinux|rocky)
|
||||||
printf "[WGDashboard] %s Found Python 3.12. Will be using [python3.12] to install WGDashboard.\n" "$heavy_checkmark"
|
if command -v dnf &> /dev/null; then
|
||||||
pythonExecutable="python3.12"
|
{ sudo dnf install -y nodejs npm; printf "\n\n"; } &>> ./log/install.txt
|
||||||
else
|
else
|
||||||
printf "[WGDashboard] %s Could not find a compatible version of Python. Current Python is %s.\n" "$heavy_crossmark" "$version"
|
{ sudo yum install -y nodejs npm; printf "\n\n"; } &>> ./log/install.txt
|
||||||
printf "[WGDashboard] WGDashboard required Python 3.12 or above. Halting install now.\n"
|
fi
|
||||||
|
;;
|
||||||
|
alpine)
|
||||||
|
{ sudo apk update; sudo apk add nodejs npm --no-cache; printf "\n\n"; } &>> ./log/install.txt
|
||||||
|
;;
|
||||||
|
arch)
|
||||||
|
{ sudo pacman -Syu nodejs npm; printf "\n\n"; } &>> ./log/install.txt
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
_unsupportedOS
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# Vite requires Node.js ^20.19.0 || >=22.12.0
|
||||||
|
_isNodeVersionSupported(){
|
||||||
|
local node_version major minor
|
||||||
|
node_version=$(node --version 2>/dev/null | sed 's/^v//')
|
||||||
|
major=${node_version%%.*}
|
||||||
|
minor=${node_version#*.}
|
||||||
|
minor=${minor%%.*}
|
||||||
|
[[ "$major" =~ ^[0-9]+$ && "$minor" =~ ^[0-9]+$ ]] || return 1
|
||||||
|
|
||||||
|
if (( major > 22 )); then return 0; fi
|
||||||
|
if (( major == 22 && minor >= 12 )); then return 0; fi
|
||||||
|
if (( major == 20 && minor >= 19 )); then return 0; fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
_checkNode(){
|
||||||
|
if ! command -v node > /dev/null 2>&1 || ! command -v npm > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
_installNode
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v node > /dev/null 2>&1 || ! command -v npm > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
printf "[WGDashboard] %s Node.js and npm are still not installed, halting script now.\n" "$heavy_crossmark"
|
||||||
|
printf "%s\n" "$helpMsg"
|
||||||
kill $TOP_PID
|
kill $TOP_PID
|
||||||
|
elif ! _isNodeVersionSupported
|
||||||
|
then
|
||||||
|
printf "[WGDashboard] %s Found Node.js %s, but the frontend requires Node.js 20.19+ or 22.12+. Halting install now.\n" "$heavy_crossmark" "$(node --version)"
|
||||||
|
printf "%s\n" "$helpMsg"
|
||||||
|
kill $TOP_PID
|
||||||
|
else
|
||||||
|
printf "[WGDashboard] %s Node.js %s and npm %s are installed\n" "$heavy_checkmark" "$(node --version)" "$(npm --version)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_determinePypiMirror(){
|
_compileFrontend(){
|
||||||
printf "[WGDashboard] %s Pinging list of recommended Python Package Index mirror\n" "$install"
|
_logSection "Compiling Frontend"
|
||||||
urls=(
|
_checkNode
|
||||||
"https://pypi.org/simple/"
|
|
||||||
"https://pypi.tuna.tsinghua.edu.cn/simple/"
|
|
||||||
"https://pypi.mirrors.ustc.edu.cn/simple/"
|
|
||||||
"https://mirrors.aliyun.com/pypi/simple/"
|
|
||||||
"https://pypi.douban.com/simple/"
|
|
||||||
)
|
|
||||||
|
|
||||||
# Function to extract hostname and ping it
|
local dir
|
||||||
index=1
|
for dir in "${frontend_dirs[@]}"; do
|
||||||
printf " ---------------------------------------------------------\n"
|
printf "[WGDashboard] %s Compiling frontend in %s\n" "$install" "$dir"
|
||||||
for url in "${urls[@]}"; do
|
if ! ( cd "$dir" && npm ci && npm run build ) &>> ./log/install.txt
|
||||||
# Extract the hostname from the URL
|
then
|
||||||
hostname=$(echo "$url" | awk -F/ '{print $3}')
|
printf "[WGDashboard] %s Failed to compile frontend in %s, halting script now.\n" "$heavy_crossmark" "$dir"
|
||||||
# Ping the hostname once and extract the RTT
|
printf "%s\n" "$helpMsg"
|
||||||
rtt=$(ping -c 1 -W 1 "$hostname" 2>/dev/null | grep 'time=' | awk -F'time=' '{print $2}' | awk '{print $1}')
|
kill $TOP_PID
|
||||||
# Handle cases where the hostname is not reachable
|
return 1
|
||||||
if [ -z "$rtt" ]; then
|
|
||||||
rtt="9999"
|
|
||||||
printf " [%i] [FAILED] %s\n" "$index" "$url"
|
|
||||||
else
|
|
||||||
rtt=${rtt//.*/}
|
|
||||||
printf " [%i] %sms %s\n" "$index" "$rtt" "$url"
|
|
||||||
fi
|
|
||||||
rtthost[$index]=$rtt
|
|
||||||
index=$((index+1))
|
|
||||||
done
|
|
||||||
printf " ---------------------------------------------------------\n"
|
|
||||||
for i in "${!rtthost[@]}"; do
|
|
||||||
[[ -z ${rtthost[i]} ]] && continue # Skip unset or empty values
|
|
||||||
if [[ -z $min_val || ${rtthost[i]} -lt $min_val ]]; then
|
|
||||||
min_val=${rtthost[i]}
|
|
||||||
min_idx=$i
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
min_idx=$((min_idx - 1))
|
printf "[WGDashboard] %s Frontend is compiled\n" "$heavy_checkmark"
|
||||||
|
}
|
||||||
|
|
||||||
printf " Which mirror you would like to use (Hit enter to use default)\n"
|
#------------------------------------------------------------------------------
|
||||||
printf " Default is %s :" "${urls[$min_idx]}"
|
# Install
|
||||||
read -t ${msleep} -r choice
|
#------------------------------------------------------------------------------
|
||||||
printf "\n"
|
_ensureFolder(){
|
||||||
|
if [ ! -d "$1" ]
|
||||||
if [[ -z "$choice" ]]; then
|
then
|
||||||
choice=$((min_idx + 1))
|
mkdir "$1"
|
||||||
fi
|
printf "[WGDashboard] %s Created ./%s folder\n" "$heavy_checkmark" "$1"
|
||||||
|
|
||||||
if [[ "$choice" =~ ^[0-9]+$ ]] && (( choice >= 1 && choice <= ${#urls[@]} )); then
|
|
||||||
selected_url="${urls[choice-1]}"
|
|
||||||
printf "[WGDashboard] %s Will download Python packages from %s\n" "$heavy_checkmark" "$selected_url"
|
|
||||||
else
|
else
|
||||||
selected_url="${urls[0]}"
|
printf "[WGDashboard] %s Found existing ./%s folder\n" "$heavy_checkmark" "$1"
|
||||||
printf "[WGDashboard] %s Will download Python packages from %s\n" "$heavy_checkmark" "${urls[0]}"
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,29 +439,9 @@ install_wgd(){
|
|||||||
printf "[WGDashboard] Starting to install WGDashboard\n"
|
printf "[WGDashboard] Starting to install WGDashboard\n"
|
||||||
_determineOS
|
_determineOS
|
||||||
|
|
||||||
if [ ! -d "log" ]
|
_ensureFolder "log"
|
||||||
then
|
_ensureFolder "download"
|
||||||
mkdir "log"
|
_ensureFolder "db"
|
||||||
printf "[WGDashboard] %s Created ./log folder\n" "$heavy_checkmark"
|
|
||||||
else
|
|
||||||
printf "[WGDashboard] %s Found existing ./log folder\n" "$heavy_checkmark"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "download" ]
|
|
||||||
then
|
|
||||||
mkdir "download"
|
|
||||||
printf "[WGDashboard] %s Created ./download folder\n" "$heavy_checkmark"
|
|
||||||
else
|
|
||||||
printf "[WGDashboard] %s Found existing ./download folder\n" "$heavy_checkmark"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -d "db" ]
|
|
||||||
then
|
|
||||||
mkdir "db"
|
|
||||||
printf "[WGDashboard] %s Created ./db folder\n" "$heavy_checkmark"
|
|
||||||
else
|
|
||||||
printf "[WGDashboard] %s Found existing ./db folder\n" "$heavy_checkmark"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! python3 --version > /dev/null 2>&1
|
if ! python3 --version > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
@@ -362,6 +456,7 @@ install_wgd(){
|
|||||||
_installPythonVenv
|
_installPythonVenv
|
||||||
_installPythonPip
|
_installPythonPip
|
||||||
_checkWireguard
|
_checkWireguard
|
||||||
|
_compileFrontend
|
||||||
sudo chmod -R 755 /etc/wireguard/
|
sudo chmod -R 755 /etc/wireguard/
|
||||||
|
|
||||||
_check_and_set_venv
|
_check_and_set_venv
|
||||||
@@ -371,7 +466,6 @@ install_wgd(){
|
|||||||
printf "[WGDashboard] %s Installing latest Python dependencies\n" "$install"
|
printf "[WGDashboard] %s Installing latest Python dependencies\n" "$install"
|
||||||
{ date; python3 -m pip install -r requirements.txt -i "$selected_url"; printf "\n\n"; } >> ./log/install.txt #This all works on the default installation.
|
{ date; python3 -m pip install -r requirements.txt -i "$selected_url"; printf "\n\n"; } >> ./log/install.txt #This all works on the default installation.
|
||||||
|
|
||||||
|
|
||||||
if [ ! -f "ssl-tls.ini" ]
|
if [ ! -f "ssl-tls.ini" ]
|
||||||
then
|
then
|
||||||
printf "[SSL/TLS]\ncertificate_path = \nprivate_key_path = \n" >> ssl-tls.ini
|
printf "[SSL/TLS]\ncertificate_path = \nprivate_key_path = \n" >> ssl-tls.ini
|
||||||
@@ -379,10 +473,14 @@ install_wgd(){
|
|||||||
else
|
else
|
||||||
printf "[WGDashboard] %s Found existing ssl-tls.ini\n" "$heavy_checkmark"
|
printf "[WGDashboard] %s Found existing ssl-tls.ini\n" "$heavy_checkmark"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "[WGDashboard] %s WGDashboard installed successfully!\n" "$heavy_checkmark"
|
printf "[WGDashboard] %s WGDashboard installed successfully!\n" "$heavy_checkmark"
|
||||||
printf "[WGDashboard] Enter ./wgd.sh start to start the dashboard\n"
|
printf "[WGDashboard] Enter ./wgd.sh start to start the dashboard\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Status / SSL
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
check_wgd_status(){
|
check_wgd_status(){
|
||||||
if test -f "$PID_FILE"; then
|
if test -f "$PID_FILE"; then
|
||||||
if ps aux | grep -v grep | grep $(cat ./gunicorn.pid) > /dev/null; then
|
if ps aux | grep -v grep | grep $(cat ./gunicorn.pid) > /dev/null; then
|
||||||
@@ -407,6 +505,9 @@ certbot_renew_ssl () {
|
|||||||
certbot renew --work-dir $cb_work_dir --config-dir $cb_config_dir
|
certbot renew --work-dir $cb_work_dir --config-dir $cb_config_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Start / Stop
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
gunicorn_start () {
|
gunicorn_start () {
|
||||||
printf "[WGDashboard] Starting WGDashboard with Gunicorn in the background.\n"
|
printf "[WGDashboard] Starting WGDashboard with Gunicorn in the background.\n"
|
||||||
d=$(date '+%Y%m%d%H%M%S')
|
d=$(date '+%Y%m%d%H%M%S')
|
||||||
@@ -462,6 +563,9 @@ start_wgd_debug() {
|
|||||||
sudo "$venv_python" "$app_name"
|
sudo "$venv_python" "$app_name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Update
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
update_wgd() {
|
update_wgd() {
|
||||||
_determineOS
|
_determineOS
|
||||||
if ! python3 --version > /dev/null 2>&1
|
if ! python3 --version > /dev/null 2>&1
|
||||||
@@ -505,7 +609,9 @@ update_wgd() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
|
# Entry point
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
print_header
|
print_header
|
||||||
if [ "$#" -lt 1 ]; then
|
if [ "$#" -lt 1 ]; then
|
||||||
help
|
help
|
||||||
|
|||||||
Reference in New Issue
Block a user