mirror of
https://github.com/WGDashboard/WGDashboard.git
synced 2026-08-04 06:53:00 +00:00
Compare commits
56 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b3b30470fc | |||
| 41d91e75fc | |||
| a97a91b844 | |||
| f1c577ab76 | |||
| 891990b2f1 | |||
| e9ab7029c9 | |||
| 6f681dba09 | |||
| b3edff947d | |||
| d35bd6e75b | |||
| f3a2f98864 | |||
| e21853286e | |||
| c012b8c4a5 | |||
| 48f6c28556 | |||
| 0c1502f801 | |||
| fec20ed381 | |||
| 252c147dcf | |||
| 453d474104 | |||
| 84cf4a9b66 | |||
| fb016bebde | |||
| 8f6a738481 | |||
| b07f958577 | |||
| 8da0fde52a | |||
| 39be16cb63 | |||
| 59d0c0def4 | |||
| 79c03db9a0 | |||
| 0c77823020 | |||
| deed7e0022 | |||
| 99db8c7335 | |||
| 9fe2aa9ed5 | |||
| 4c80dc256b | |||
| cafe9e9c11 | |||
| 27ff4e63b6 | |||
| 8020714e07 | |||
| dbd825ba4b | |||
| fee6cf29eb | |||
| 56287d8e7a | |||
| 45504eaf95 | |||
| b8a9b1150a | |||
| 8bd0e43f58 | |||
| 2c83e9e83c | |||
| 53c9ca10a7 | |||
| 75fbdac42e | |||
| 09d54546ca | |||
| b62fece3d0 | |||
| 284a2b7f64 | |||
| 9c873ccbbd | |||
| 5f72f90031 | |||
| 93cf3c69b8 | |||
| 88f856cbc7 | |||
| 2d5796d161 | |||
| acf4f3fbf0 | |||
| 8378030c70 | |||
| dc7140d486 | |||
| ed1c05dec9 | |||
| a4151800f1 | |||
| 932f24c966 |
@@ -0,0 +1,56 @@
|
|||||||
|
name: Docker Image Build and Analysis
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * *" # Schedule the workflow to run daily at midnight (UTC time). Adjust the time if needed.
|
||||||
|
workflow_dispatch: # Manual run trigger
|
||||||
|
inputs:
|
||||||
|
trigger-build:
|
||||||
|
description: 'Trigger a manual build and push'
|
||||||
|
default: 'true'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-analyze:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build Docker image
|
||||||
|
id: build-image
|
||||||
|
run: |
|
||||||
|
echo "Building Docker image..."
|
||||||
|
docker build -t my-app-image:latest .
|
||||||
|
echo "Docker image built successfully."
|
||||||
|
|
||||||
|
- name: Install Docker Scout
|
||||||
|
run: |
|
||||||
|
echo "Installing Docker Scout..."
|
||||||
|
curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s --
|
||||||
|
echo "Docker Scout installed successfully."
|
||||||
|
|
||||||
|
- name: Analyze Docker image with Docker Scout
|
||||||
|
id: analyze-image
|
||||||
|
run: |
|
||||||
|
echo "Analyzing Docker image with Docker Scout..."
|
||||||
|
docker scout cves my-app-image:latest > scout-results.txt
|
||||||
|
cat scout-results.txt # Print the report to the workflow logs for easy viewing
|
||||||
|
echo "Docker Scout analysis completed."
|
||||||
|
|
||||||
|
- name: Post Comment on Issue or PR
|
||||||
|
run: |
|
||||||
|
COMMENT="**Docker Image Build and Analysis Report**\n\nThe Docker image was built and analyzed successfully.\n\n**Build Summary:**\n- Image Tag: my-app-image:latest\n\n**Analysis Report:**\n\`\`\`\n$(cat scout-results.txt)\n\`\`\`"
|
||||||
|
|
||||||
|
# Post comment using GitHub API
|
||||||
|
curl -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
|
-d "{\"body\": \"$COMMENT\"}" \
|
||||||
|
"https://api.github.com/repos/NOXCIS/WGDashboard/issues/1/comments" # Replace '1' with the issue or PR number
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
# Pull from small Debian stable image.
|
||||||
|
FROM alpine:latest AS builder
|
||||||
|
|
||||||
|
LABEL maintainer="dselen@nerthus.nl"
|
||||||
|
|
||||||
|
WORKDIR /opt/wireguarddashboard/src
|
||||||
|
|
||||||
|
RUN apk update && \
|
||||||
|
apk add --no-cache sudo gcc musl-dev rust cargo linux-headers
|
||||||
|
|
||||||
|
COPY ./docker/alpine/builder.sh /opt/wireguarddashboard/src/
|
||||||
|
COPY ./docker/alpine/requirements.txt /opt/wireguarddashboard/src/
|
||||||
|
RUN chmod u+x /opt/wireguarddashboard/src/builder.sh
|
||||||
|
RUN /opt/wireguarddashboard/src/builder.sh
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
WORKDIR /opt/wireguarddashboard/src
|
||||||
|
|
||||||
|
COPY ./src /opt/wireguarddashboard/src/
|
||||||
|
COPY --from=builder /opt/wireguarddashboard/src/venv /opt/wireguarddashboard/src/venv
|
||||||
|
COPY --from=builder /opt/wireguarddashboard/src/log /opt/wireguarddashboard/src/log/
|
||||||
|
|
||||||
|
RUN apk update && \
|
||||||
|
apk add --no-cache wireguard-tools sudo && \
|
||||||
|
apk add --no-cache iptables ip6tables && \
|
||||||
|
chmod u+x /opt/wireguarddashboard/src/entrypoint.sh
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:10086/signin || exit 1
|
||||||
|
|
||||||
|
ENTRYPOINT ["/opt/wireguarddashboard/src/entrypoint.sh"]
|
||||||
@@ -24,6 +24,9 @@
|
|||||||
|
|
||||||
## 📣 What's New: v4.0
|
## 📣 What's New: v4.0
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> [📹 Demo video on YouTube](https://www.youtube.com/watch?v=0mwzd5Gr2eU)
|
||||||
|
|
||||||
### 🎉 New Features
|
### 🎉 New Features
|
||||||
|
|
||||||
- **Updated dashboard design**: Re-designed some of the section with more modern style and layout, the UI is faster and more responsive, it also uses less memory. But overall is still the same dashboard you're familiarized.
|
- **Updated dashboard design**: Re-designed some of the section with more modern style and layout, the UI is faster and more responsive, it also uses less memory. But overall is still the same dashboard you're familiarized.
|
||||||
@@ -55,6 +58,8 @@
|
|||||||
> Also, huge thanks to who contributed to this major release:
|
> Also, huge thanks to who contributed to this major release:
|
||||||
> @bolgovrussia, @eduardorosabales, @Profik, @airgapper, @tokon2000, @bkeenke, @kontorskiy777, @bugsse, @Johnnykson, @DaanSelen, @shuricksumy and many others!
|
> @bolgovrussia, @eduardorosabales, @Profik, @airgapper, @tokon2000, @bkeenke, @kontorskiy777, @bugsse, @Johnnykson, @DaanSelen, @shuricksumy and many others!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
## 📋 Table of Content
|
## 📋 Table of Content
|
||||||
@@ -77,6 +82,7 @@
|
|||||||
* [Debian 11.10](#debian-1110)
|
* [Debian 11.10](#debian-1110)
|
||||||
* [Red Hat Enterprise Linux 9.4 & CentOS 9-Stream](#red-hat-enterprise-linux-94--centos-9-stream)
|
* [Red Hat Enterprise Linux 9.4 & CentOS 9-Stream](#red-hat-enterprise-linux-94--centos-9-stream)
|
||||||
* [Fedora 40 & Fedora 39 & Fedora 38](#fedora-40--fedora-39--fedora-38)
|
* [Fedora 40 & Fedora 39 & Fedora 38](#fedora-40--fedora-39--fedora-38)
|
||||||
|
* [Alpine Linux 3.20.2](#alpine-linux-3202)
|
||||||
* [Manual Installation](#manual-installation)
|
* [Manual Installation](#manual-installation)
|
||||||
* [🪜 Usage](#-usage)
|
* [🪜 Usage](#-usage)
|
||||||
* [Start/Stop/Restart WGDashboard](#startstoprestart-wgdashboard)
|
* [Start/Stop/Restart WGDashboard](#startstoprestart-wgdashboard)
|
||||||
@@ -124,11 +130,11 @@
|
|||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> All operating systems below are tested by myself. All are ARM64 ran in UTM Virtual Machine.
|
> All operating systems below are tested by myself. All are ARM64 ran in UTM Virtual Machine.
|
||||||
|
|
||||||
| Ubuntu | Debian | Red Hat Enterprise Linux | CentOS | Fedora |
|
| Ubuntu | Debian | Red Hat Enterprise Linux | CentOS | Fedora | Alpine Linux |
|
||||||
|-----------|--------|--------------------------|----------|--------|
|
|-----------|--------|--------------------------|----------|--------|------------------------|
|
||||||
| 20.04 LTS | 12.6 | 9.4 | 9-Stream | 40 |
|
| 20.04 LTS | 12.6 | 9.4 | 9-Stream | 40 | 3.20.2 (Under Testing) |
|
||||||
| 22.04 LTS | 11.10 | | | 39 |
|
| 22.04 LTS | 11.10 | | | 39 | |
|
||||||
| 24.02 LTS | | | | 38 |
|
| 24.02 LTS | | | | 38 | |
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> If you installed WGDashboard on other systems without any issues, please let me know. Thank you!
|
> If you installed WGDashboard on other systems without any issues, please let me know. Thank you!
|
||||||
@@ -256,6 +262,20 @@ firewall-cmd --add-port=51820/udp --permanent && \
|
|||||||
firewall-cmd --reload
|
firewall-cmd --reload
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Alpine Linux 3.20.2
|
||||||
|
|
||||||
|
```shell
|
||||||
|
setup-interfaces -a ; \
|
||||||
|
rc-service networking --quiet start ; \
|
||||||
|
printf "https://mirrors.aliyun.com/alpine/latest-stable/main\nhttps://mirrors.aliyun.com/alpine/latest-stable/community" > /etc/apk/repositories ; \
|
||||||
|
apk update ; \
|
||||||
|
apk add wireguard-tools python3 python3-dev git iptables net-tools gcc musl-dev linux-headers sudo ; \
|
||||||
|
git clone -b v4.0-alpine-linux https://github.com/donaldzou/WGDashboard.git ; \
|
||||||
|
cd ./WGDashboard/src ; \
|
||||||
|
chmod +x ./wgd.sh ; \
|
||||||
|
./wgd.sh install
|
||||||
|
```
|
||||||
|
|
||||||
### Manual Installation
|
### Manual Installation
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
services:
|
||||||
|
|
||||||
|
wireguard-dashboard:
|
||||||
|
build: ./
|
||||||
|
container_name: wiregate
|
||||||
|
cap_add:
|
||||||
|
- NET_ADMIN
|
||||||
|
- SYS_MODULE
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- wg_net=10.0.0.1/24
|
||||||
|
- wg_port=51820
|
||||||
|
volumes:
|
||||||
|
- wgd_configs:/etc/wireguard
|
||||||
|
- wgd_app:/opt/wireguarddashboard/src
|
||||||
|
ports:
|
||||||
|
- 10086:10086/tcp
|
||||||
|
- 51820:51820/udp
|
||||||
|
sysctls:
|
||||||
|
- net.ipv4.ip_forward=1
|
||||||
|
- net.ipv4.conf.all.src_valid_mark=1
|
||||||
|
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
wgd_configs:
|
||||||
|
wgd_app:
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
# Pull from small Debian stable image.
|
|
||||||
FROM debian:stable-slim
|
|
||||||
LABEL maintainer="dselen@nerthus.nl"
|
|
||||||
|
|
||||||
# Declaring environment variables, change Peernet to an address you like, standard is a 24 bit subnet.
|
|
||||||
ENV wg_net="10.0.0.1"
|
|
||||||
# wg_net is used functionally as an ARG for its environment variable nature, do not change unless you know what you are doing.
|
|
||||||
|
|
||||||
# Following ENV variables are changable on container runtime because /entrypoint.sh handles that. See compose.yaml for more info.
|
|
||||||
ENV tz="Europe/Amsterdam"
|
|
||||||
ENV global_dns="1.1.1.1"
|
|
||||||
ENV enable_wg0="false"
|
|
||||||
ENV isolated_peers="true"
|
|
||||||
ENV public_ip="0.0.0.0"
|
|
||||||
|
|
||||||
# Doing basic system maintenance. Change the timezone to the desired timezone.
|
|
||||||
RUN ln -sf /usr/share/zoneinfo/${tz} /etc/localtime
|
|
||||||
|
|
||||||
# Doing package management operations, such as upgrading
|
|
||||||
RUN apt-get update && apt-get upgrade -y \
|
|
||||||
&& apt-get install -y --no-install-recommends curl \
|
|
||||||
git \
|
|
||||||
iproute2 \
|
|
||||||
iptables \
|
|
||||||
iputils-ping \
|
|
||||||
openresolv \
|
|
||||||
procps \
|
|
||||||
python3 \
|
|
||||||
python3-pip \
|
|
||||||
python3-venv \
|
|
||||||
traceroute \
|
|
||||||
wireguard \
|
|
||||||
wireguard-tools \
|
|
||||||
&& apt-get remove linux-image-* --autoremove -y \
|
|
||||||
&& apt-get clean \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
# Removing the Linux Image package to preserve space on the image, for this reason also deleting apt lists, to be able to install packages: run apt update.
|
|
||||||
|
|
||||||
# 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/wireguarddashboard
|
|
||||||
RUN python3 -m venv ${WGDASH}/venv
|
|
||||||
|
|
||||||
# Doing WireGuard Dashboard installation measures. Modify the git clone command to get the preferred version, with a specific branch for example.
|
|
||||||
RUN . ${WGDASH}/venv/bin/activate \
|
|
||||||
&& git clone https://github.com/donaldzou/WGDashboard.git ${WGDASH}/app \
|
|
||||||
&& pip3 install -r ${WGDASH}/app/src/requirements.txt \
|
|
||||||
&& chmod +x ${WGDASH}/app/src/wgd.sh \
|
|
||||||
&& .${WGDASH}/app/src/wgd.sh install
|
|
||||||
|
|
||||||
# Set the volume to be used for persistency.
|
|
||||||
VOLUME /etc/wireguard
|
|
||||||
|
|
||||||
# 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 wg genkey | tee /etc/wireguard/wg0_privatekey \
|
|
||||||
&& echo "[Interface]" > /wg0.conf \
|
|
||||||
&& echo "SaveConfig = true" >> /wg0.conf \
|
|
||||||
&& echo "Address = ${wg_net}/24" >> /wg0.conf \
|
|
||||||
&& echo "PrivateKey = $(cat /etc/wireguard/wg0_privatekey)" >> /wg0.conf \
|
|
||||||
&& echo "PostUp = iptables -t nat -I POSTROUTING 1 -s ${wg_net}/24 -o $(ip -o -4 route show to default | awk '{print $NF}') -j MASQUERADE" >> /wg0.conf \
|
|
||||||
&& echo "PostUp = iptables -I FORWARD -i wg0 -o wg0 -j DROP" >> /wg0.conf \
|
|
||||||
&& echo "PreDown = iptables -t nat -D POSTROUTING 1" >> /wg0.conf \
|
|
||||||
&& echo "PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP" >> /wg0.conf \
|
|
||||||
&& echo "ListenPort = 51820" >> /wg0.conf \
|
|
||||||
#&& echo "DNS = ${global_dns}" >> /wg0.conf \
|
|
||||||
&& rm /etc/wireguard/wg0_privatekey
|
|
||||||
|
|
||||||
# Defining a way for Docker to check the health of the container. In this case: checking the login URL.
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 CMD curl -f http://localhost:10086/signin || exit 1
|
|
||||||
|
|
||||||
# Copy the basic entrypoint.sh script.
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
|
||||||
|
|
||||||
# Exposing the default WireGuard Dashboard port for web access.
|
|
||||||
EXPOSE 10086
|
|
||||||
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
venv_python="./venv/bin/python3"
|
||||||
|
venv_gunicorn="./venv/bin/gunicorn"
|
||||||
|
pythonExecutable="python3"
|
||||||
|
|
||||||
|
|
||||||
|
_check_and_set_venv(){
|
||||||
|
VIRTUAL_ENV="./venv"
|
||||||
|
if [ ! -d $VIRTUAL_ENV ]; then
|
||||||
|
printf "[WGDashboard] Creating Python Virtual Environment under ./venv\n"
|
||||||
|
{ $pythonExecutable -m venv $VIRTUAL_ENV; } >> ./log/install.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! $venv_python --version > /dev/null 2>&1
|
||||||
|
then
|
||||||
|
printf "[WGDashboard] %s Python Virtual Environment under ./venv failed to create. Halting now.\n" "$heavy_crossmark"
|
||||||
|
kill $TOP_PID
|
||||||
|
fi
|
||||||
|
|
||||||
|
source ${VIRTUAL_ENV}/bin/activate
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
build_core () {
|
||||||
|
if [ ! -d "log" ]
|
||||||
|
then
|
||||||
|
printf "[WGDashboard] Creating ./log folder\n"
|
||||||
|
mkdir "log"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
apk add --no-cache python3 net-tools python3-dev py3-virtualenv
|
||||||
|
_check_and_set_venv
|
||||||
|
printf "[WGDashboard] Upgrading Python Package Manage (PIP)\n"
|
||||||
|
{ date; python3 -m pip install --upgrade pip; printf "\n\n"; } >> ./log/install.txt
|
||||||
|
printf "[WGDashboard] Building Bcrypt & Psutil\n"
|
||||||
|
{ date; python3 -m pip install -r requirements.txt ; printf "\n\n"; } >> ./log/install.txt
|
||||||
|
printf "[WGDashboard] Build Successfull!\n"
|
||||||
|
printf "[WGDashboard] Clean Up Pip!\n"
|
||||||
|
{ date; rm -rf /opt/wireguarddashboard/src/venv/lib/python3.12/site-packages/pip* ; printf "\n\n"; } >> ./log/install.txt
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
build_core
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
bcrypt
|
||||||
|
psutil
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
services:
|
|
||||||
wireguard-dashboard:
|
|
||||||
image: repo.nerthus.nl/app/wireguard-dashboard:latest
|
|
||||||
restart: unless-stopped
|
|
||||||
container_name: wire-dash
|
|
||||||
environment:
|
|
||||||
#- tz= # <--- Set container timezone, default: Europe/Amsterdam.
|
|
||||||
#- global_dns= # <--- Set global DNS address, default: 1.1.1.1.
|
|
||||||
- enable_wg0=true # <--- If true, wg0 will be started on container startup. default: false.
|
|
||||||
- isolated_peers=false # <--- When set to true, it disallows peers to talk to eachother, setting to false, allows it, default: true.
|
|
||||||
#- public_ip= # <--- Set public IP to ensure the correct one is chosen, defaulting to the IP give by ifconfig.me.
|
|
||||||
ports:
|
|
||||||
- 10086:10086/tcp
|
|
||||||
- 51820:51820/udp
|
|
||||||
volumes:
|
|
||||||
- conf:/etc/wireguard
|
|
||||||
- app:/opt/wireguarddashboard/app
|
|
||||||
cap_add:
|
|
||||||
- NET_ADMIN
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
conf:
|
|
||||||
app:
|
|
||||||
@@ -1,109 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
echo "Starting the WireGuard Dashboard Docker container."
|
|
||||||
|
|
||||||
clean_up() {
|
|
||||||
# Cleaning out previous data such as the .pid file and starting the WireGuard Dashboard. Making sure to use the python venv.
|
|
||||||
echo "Looking for remains of previous instances..."
|
|
||||||
if [ -f "/opt/wireguarddashboard/app/src/gunicorn.pid" ]; then
|
|
||||||
echo "Found old .pid file, removing."
|
|
||||||
rm /opt/wireguarddashboard/app/src/gunicorn.pid
|
|
||||||
else
|
|
||||||
echo "No remains found, continuing."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
start_core() {
|
|
||||||
# This first step is to ensure the wg0.conf file exists, and if not, then its copied over from the ephemeral container storage.
|
|
||||||
if [ ! -f "/etc/wireguard/wg0.conf" ]; then
|
|
||||||
cp "/wg0.conf" "/etc/wireguard/wg0.conf"
|
|
||||||
echo "WireGuard interface file copied over."
|
|
||||||
else
|
|
||||||
echo "WireGuard interface file looks to already be existing."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Activating Python venv and executing the WireGuard Dashboard service."
|
|
||||||
|
|
||||||
. "${WGDASH}"/venv/bin/activate
|
|
||||||
cd "${WGDASH}"/app/src || return # If changing the directory fails (permission or presence error), then bash will exist this function, causing the WireGuard Dashboard to not be succesfully launched.
|
|
||||||
bash wgd.sh start
|
|
||||||
|
|
||||||
# The following section takes care of the firewall rules regarding the 'isolated_peers' feature, which allows or drops packets destined from the wg0 to the wg0 interface.
|
|
||||||
if [ "${isolated_peers,,}" = "false" ]; then
|
|
||||||
echo "Isolated peers disabled, adjusting."
|
|
||||||
|
|
||||||
sed -i '/PostUp = iptables -I FORWARD -i wg0 -o wg0 -j DROP/d' /etc/wireguard/wg0.conf
|
|
||||||
sed -i '/PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP/d' /etc/wireguard/wg0.conf
|
|
||||||
elif [ "${isolated_peers,,}" = "true" ]; then
|
|
||||||
upblocking=$(grep -c "PostUp = iptables -I FORWARD -i wg0 -o wg0 -j DROP" /etc/wireguard/wg0.conf)
|
|
||||||
downblocking=$(grep -c "PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP" /etc/wireguard/wg0.conf)
|
|
||||||
if [ "$upblocking" -lt 1 ] && [ "$downblocking" -lt 1 ]; then
|
|
||||||
echo "Isolated peers enabled, adjusting."
|
|
||||||
|
|
||||||
sed -i '/PostUp = iptables -t nat -I POSTROUTING 1 -s/a PostUp = iptables -I FORWARD -i wg0 -o wg0 -j DROP' /etc/wireguard/wg0.conf
|
|
||||||
sed -i '/PreDown = iptables -t nat -D POSTROUTING 1 -s/a PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP' /etc/wireguard/wg0.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# The following section takes care of
|
|
||||||
if [ "${enable_wg0,,}" = "true" ]; then
|
|
||||||
echo "Preference for wg0 to be turned on found."
|
|
||||||
|
|
||||||
wg-quick up wg0
|
|
||||||
else
|
|
||||||
echo "Preference for wg0 to be turned off found."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
set_envvars() {
|
|
||||||
echo "Setting relevant variables for operation."
|
|
||||||
|
|
||||||
# If the timezone is different, for example in North-America or Asia.
|
|
||||||
if [ "${tz}" != "$(cat /etc/timezone)" ]; then
|
|
||||||
echo "Changing timezone."
|
|
||||||
|
|
||||||
ln -sf /usr/share/zoneinfo/"${tz}" /etc/localtime
|
|
||||||
echo "${tz}" > /etc/timezone
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Changing the DNS used for clients and the dashboard itself.
|
|
||||||
if [ "${global_dns}" != "$(grep "peer_global_dns = " /opt/wireguarddashboard/app/src/wg-dashboard.ini | awk '{print $NF}')" ]; then
|
|
||||||
echo "Changing default dns."
|
|
||||||
|
|
||||||
#sed -i "s/^DNS = .*/DNS = ${global_dns}/" /etc/wireguard/wg0.conf # Uncomment if you want to have DNS on server-level.
|
|
||||||
sed -i "s/^peer_global_dns = .*/peer_global_dns = ${global_dns}/" /opt/wireguarddashboard/app/src/wg-dashboard.ini
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Setting the public IP of the WireGuard Dashboard container host. If not defined, it will trying fetching it using a curl to ifconfig.me.
|
|
||||||
if [ "${public_ip}" = "0.0.0.0" ]; then
|
|
||||||
default_ip=$(curl -s ifconfig.me)
|
|
||||||
echo "Trying to fetch the Public-IP using ifconfig.me: ${default_ip}"
|
|
||||||
|
|
||||||
sed -i "s/^remote_endpoint = .*/remote_endpoint = ${default_ip}/" /opt/wireguarddashboard/app/src/wg-dashboard.ini
|
|
||||||
elif [ "${public_ip}" != "$(grep "remote_endpoint = " /opt/wireguarddashboard/app/src/wg-dashboard.ini | awk '{print $NF}')" ]; then
|
|
||||||
echo "Setting the Public-IP using given variable: ${public_ip}"
|
|
||||||
|
|
||||||
sed -i "s/^remote_endpoint = .*/remote_endpoint = ${public_ip}/" /opt/wireguarddashboard/app/src/wg-dashboard.ini
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
ensure_blocking() {
|
|
||||||
sleep 1s
|
|
||||||
echo "Ensuring container continuation."
|
|
||||||
|
|
||||||
# This function checks if the latest error log is created and tails it for docker logs uses.
|
|
||||||
if find "/opt/wireguarddashboard/app/src/log" -mindepth 1 -maxdepth 1 -type f | read -r; then
|
|
||||||
latestErrLog=$(find /opt/wireguarddashboard/app/src/log -name "error_*.log" | head -n 1)
|
|
||||||
latestAccLog=$(find /opt/wireguarddashboard/app/src/log -name "access_*.log" | head -n 1)
|
|
||||||
tail -f "${latestErrLog}" "${latestAccLog}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Blocking command in case of erroring. So the container does not quit.
|
|
||||||
sleep infinity
|
|
||||||
}
|
|
||||||
|
|
||||||
# Execute functions for the WireGuard Dashboard services, then set the environment variables
|
|
||||||
clean_up
|
|
||||||
start_core
|
|
||||||
set_envvars
|
|
||||||
ensure_blocking
|
|
||||||
+114
-103
@@ -33,7 +33,7 @@ import threading
|
|||||||
|
|
||||||
from flask.json.provider import DefaultJSONProvider
|
from flask.json.provider import DefaultJSONProvider
|
||||||
|
|
||||||
DASHBOARD_VERSION = 'v4.0.2'
|
DASHBOARD_VERSION = 'v4.0.4'
|
||||||
CONFIGURATION_PATH = os.getenv('CONFIGURATION_PATH', '.')
|
CONFIGURATION_PATH = os.getenv('CONFIGURATION_PATH', '.')
|
||||||
DB_PATH = os.path.join(CONFIGURATION_PATH, 'db')
|
DB_PATH = os.path.join(CONFIGURATION_PATH, 'db')
|
||||||
if not os.path.isdir(DB_PATH):
|
if not os.path.isdir(DB_PATH):
|
||||||
@@ -442,6 +442,8 @@ class WireguardConfiguration:
|
|||||||
return self.message
|
return self.message
|
||||||
|
|
||||||
def __init__(self, name: str = None, data: dict = None):
|
def __init__(self, name: str = None, data: dict = None):
|
||||||
|
print(f"[WGDashboard] Initialized Configuration: {name}")
|
||||||
|
|
||||||
self.__parser: configparser.ConfigParser = configparser.ConfigParser(strict=False)
|
self.__parser: configparser.ConfigParser = configparser.ConfigParser(strict=False)
|
||||||
self.__parser.optionxform = str
|
self.__parser.optionxform = str
|
||||||
self.__configFileModifiedTime = None
|
self.__configFileModifiedTime = None
|
||||||
@@ -588,83 +590,93 @@ class WireguardConfiguration:
|
|||||||
restricted = sqlSelect("SELECT * FROM '%s_restrict_access'" % self.Name).fetchall()
|
restricted = sqlSelect("SELECT * FROM '%s_restrict_access'" % self.Name).fetchall()
|
||||||
for i in restricted:
|
for i in restricted:
|
||||||
self.RestrictedPeers.append(Peer(i, self))
|
self.RestrictedPeers.append(Peer(i, self))
|
||||||
|
|
||||||
|
def configurationFileChanged(self) :
|
||||||
|
mt = os.path.getmtime(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'))
|
||||||
|
changed = self.__configFileModifiedTime is None or self.__configFileModifiedTime != mt
|
||||||
|
self.__configFileModifiedTime = mt
|
||||||
|
return changed
|
||||||
|
|
||||||
def __getPeers(self):
|
def __getPeers(self):
|
||||||
|
|
||||||
mt = os.path.getmtime(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'))
|
if self.configurationFileChanged():
|
||||||
# if self.__configFileModifiedTime is None or self.__configFileModifiedTime != mt:
|
self.Peers = []
|
||||||
self.Peers = []
|
with open(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'), 'r') as configFile:
|
||||||
with open(os.path.join(WG_CONF_PATH, f'{self.Name}.conf'), 'r') as configFile:
|
p = []
|
||||||
p = []
|
pCounter = -1
|
||||||
pCounter = -1
|
content = configFile.read().split('\n')
|
||||||
content = configFile.read().split('\n')
|
try:
|
||||||
try:
|
peerStarts = content.index("[Peer]")
|
||||||
peerStarts = content.index("[Peer]")
|
content = content[peerStarts:]
|
||||||
content = content[peerStarts:]
|
for i in content:
|
||||||
for i in content:
|
if not regex_match("#(.*)", i) and not regex_match(";(.*)", i):
|
||||||
if not regex_match("#(.*)", i) and not regex_match(";(.*)", i):
|
if i == "[Peer]":
|
||||||
if i == "[Peer]":
|
pCounter += 1
|
||||||
pCounter += 1
|
p.append({})
|
||||||
p.append({})
|
p[pCounter]["name"] = ""
|
||||||
p[pCounter]["name"] = ""
|
else:
|
||||||
else:
|
if len(i) > 0:
|
||||||
if len(i) > 0:
|
split = re.split(r'\s*=\s*', i, 1)
|
||||||
split = re.split(r'\s*=\s*', i, 1)
|
if len(split) == 2:
|
||||||
if len(split) == 2:
|
p[pCounter][split[0]] = split[1]
|
||||||
p[pCounter][split[0]] = split[1]
|
|
||||||
|
if regex_match("#Name# = (.*)", i):
|
||||||
|
split = re.split(r'\s*=\s*', i, 1)
|
||||||
|
print(split)
|
||||||
|
if len(split) == 2:
|
||||||
|
p[pCounter]["name"] = split[1]
|
||||||
|
|
||||||
if regex_match("#Name# = (.*)", i):
|
for i in p:
|
||||||
split = re.split(r'\s*=\s*', i, 1)
|
if "PublicKey" in i.keys():
|
||||||
print(split)
|
checkIfExist = sqlSelect("SELECT * FROM '%s' WHERE id = ?" % self.Name,
|
||||||
if len(split) == 2:
|
((i['PublicKey']),)).fetchone()
|
||||||
p[pCounter]["name"] = split[1]
|
if checkIfExist is None:
|
||||||
|
newPeer = {
|
||||||
for i in p:
|
"id": i['PublicKey'],
|
||||||
if "PublicKey" in i.keys():
|
"private_key": "",
|
||||||
checkIfExist = sqlSelect("SELECT * FROM '%s' WHERE id = ?" % self.Name,
|
"DNS": DashboardConfig.GetConfig("Peers", "peer_global_DNS")[1],
|
||||||
((i['PublicKey']),)).fetchone()
|
"endpoint_allowed_ip": DashboardConfig.GetConfig("Peers", "peer_endpoint_allowed_ip")[
|
||||||
if checkIfExist is None:
|
1],
|
||||||
newPeer = {
|
"name": i.get("name"),
|
||||||
"id": i['PublicKey'],
|
"total_receive": 0,
|
||||||
"private_key": "",
|
"total_sent": 0,
|
||||||
"DNS": DashboardConfig.GetConfig("Peers", "peer_global_DNS")[1],
|
"total_data": 0,
|
||||||
"endpoint_allowed_ip": DashboardConfig.GetConfig("Peers", "peer_endpoint_allowed_ip")[
|
"endpoint": "N/A",
|
||||||
1],
|
"status": "stopped",
|
||||||
"name": i.get("name"),
|
"latest_handshake": "N/A",
|
||||||
"total_receive": 0,
|
"allowed_ip": i.get("AllowedIPs", "N/A"),
|
||||||
"total_sent": 0,
|
"cumu_receive": 0,
|
||||||
"total_data": 0,
|
"cumu_sent": 0,
|
||||||
"endpoint": "N/A",
|
"cumu_data": 0,
|
||||||
"status": "stopped",
|
"traffic": [],
|
||||||
"latest_handshake": "N/A",
|
"mtu": DashboardConfig.GetConfig("Peers", "peer_mtu")[1],
|
||||||
"allowed_ip": i.get("AllowedIPs", "N/A"),
|
"keepalive": DashboardConfig.GetConfig("Peers", "peer_keep_alive")[1],
|
||||||
"cumu_receive": 0,
|
"remote_endpoint": DashboardConfig.GetConfig("Peers", "remote_endpoint")[1],
|
||||||
"cumu_sent": 0,
|
"preshared_key": i["PresharedKey"] if "PresharedKey" in i.keys() else ""
|
||||||
"cumu_data": 0,
|
}
|
||||||
"traffic": [],
|
sqlUpdate(
|
||||||
"mtu": DashboardConfig.GetConfig("Peers", "peer_mtu")[1],
|
"""
|
||||||
"keepalive": DashboardConfig.GetConfig("Peers", "peer_keep_alive")[1],
|
INSERT INTO '%s'
|
||||||
"remote_endpoint": DashboardConfig.GetConfig("Peers", "remote_endpoint")[1],
|
VALUES (:id, :private_key, :DNS, :endpoint_allowed_ip, :name, :total_receive, :total_sent,
|
||||||
"preshared_key": i["PresharedKey"] if "PresharedKey" in i.keys() else ""
|
:total_data, :endpoint, :status, :latest_handshake, :allowed_ip, :cumu_receive, :cumu_sent,
|
||||||
}
|
:cumu_data, :mtu, :keepalive, :remote_endpoint, :preshared_key);
|
||||||
sqlUpdate(
|
""" % self.Name
|
||||||
"""
|
, newPeer)
|
||||||
INSERT INTO '%s'
|
# sqldb.commit()
|
||||||
VALUES (:id, :private_key, :DNS, :endpoint_allowed_ip, :name, :total_receive, :total_sent,
|
self.Peers.append(Peer(newPeer, self))
|
||||||
:total_data, :endpoint, :status, :latest_handshake, :allowed_ip, :cumu_receive, :cumu_sent,
|
else:
|
||||||
:cumu_data, :mtu, :keepalive, :remote_endpoint, :preshared_key);
|
sqlUpdate("UPDATE '%s' SET allowed_ip = ? WHERE id = ?" % self.Name,
|
||||||
""" % self.Name
|
(i.get("AllowedIPs", "N/A"), i['PublicKey'],))
|
||||||
, newPeer)
|
# sqldb.commit()
|
||||||
# sqldb.commit()
|
self.Peers.append(Peer(checkIfExist, self))
|
||||||
self.Peers.append(Peer(newPeer, self))
|
except Exception as e:
|
||||||
else:
|
print(f"[WGDashboard] {self.Name} Error: {str(e)}")
|
||||||
sqlUpdate("UPDATE '%s' SET allowed_ip = ? WHERE id = ?" % self.Name,
|
else:
|
||||||
(i.get("AllowedIPs", "N/A"), i['PublicKey'],))
|
self.Peers.clear()
|
||||||
# sqldb.commit()
|
checkIfExist = sqlSelect("SELECT * FROM '%s'" % self.Name).fetchall()
|
||||||
self.Peers.append(Peer(checkIfExist, self))
|
for i in checkIfExist:
|
||||||
except Exception as e:
|
self.Peers.append(Peer(i, self))
|
||||||
print(f"[WGDashboard] {self.Name} Error: {str(e)}")
|
|
||||||
self.__configFileModifiedTime = mt
|
|
||||||
|
|
||||||
def addPeers(self, peers: list):
|
def addPeers(self, peers: list):
|
||||||
for p in peers:
|
for p in peers:
|
||||||
@@ -681,8 +693,6 @@ class WireguardConfiguration:
|
|||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
def allowAccessPeers(self, listOfPublicKeys):
|
def allowAccessPeers(self, listOfPublicKeys):
|
||||||
# numOfAllowedPeers = 0
|
|
||||||
# numOfFailedToAllowPeers = 0
|
|
||||||
if not self.getStatus():
|
if not self.getStatus():
|
||||||
self.toggleConfiguration()
|
self.toggleConfiguration()
|
||||||
|
|
||||||
@@ -693,7 +703,15 @@ class WireguardConfiguration:
|
|||||||
% (self.Name, self.Name,), (p['id'],))
|
% (self.Name, self.Name,), (p['id'],))
|
||||||
sqlUpdate("DELETE FROM '%s_restrict_access' WHERE id = ?"
|
sqlUpdate("DELETE FROM '%s_restrict_access' WHERE id = ?"
|
||||||
% self.Name, (p['id'],))
|
% self.Name, (p['id'],))
|
||||||
subprocess.check_output(f"wg set {self.Name} peer {p['id']} allowed-ips {p['allowed_ip']}",
|
|
||||||
|
presharedKeyExist = len(p['preshared_key']) > 0
|
||||||
|
rd = random.Random()
|
||||||
|
uid = uuid.UUID(int=rd.getrandbits(128), version=4)
|
||||||
|
if presharedKeyExist:
|
||||||
|
with open(f"{uid}", "w+") as f:
|
||||||
|
f.write(p['preshared_key'])
|
||||||
|
|
||||||
|
subprocess.check_output(f"wg set {self.Name} peer {p['id']} allowed-ips {p['allowed_ip']}{f' preshared-key {uid}' if presharedKeyExist else ''}",
|
||||||
shell=True, stderr=subprocess.STDOUT)
|
shell=True, stderr=subprocess.STDOUT)
|
||||||
else:
|
else:
|
||||||
return ResponseObject(False, "Failed to allow access of peer " + i)
|
return ResponseObject(False, "Failed to allow access of peer " + i)
|
||||||
@@ -803,12 +821,11 @@ class WireguardConfiguration:
|
|||||||
else:
|
else:
|
||||||
status = "stopped"
|
status = "stopped"
|
||||||
if int(latestHandshake[count + 1]) > 0:
|
if int(latestHandshake[count + 1]) > 0:
|
||||||
sqldb.execute("UPDATE '%s' SET latest_handshake = ?, status = ? WHERE id= ?" % self.Name
|
sqlUpdate("UPDATE '%s' SET latest_handshake = ?, status = ? WHERE id= ?" % self.Name
|
||||||
, (str(minus).split(".", maxsplit=1)[0], status, latestHandshake[count],))
|
, (str(minus).split(".", maxsplit=1)[0], status, latestHandshake[count],))
|
||||||
else:
|
else:
|
||||||
sqldb.execute("UPDATE '%s' SET latest_handshake = 'No Handshake', status = ? WHERE id= ?" % self.Name
|
sqlUpdate("UPDATE '%s' SET latest_handshake = 'No Handshake', status = ? WHERE id= ?" % self.Name
|
||||||
, (status, latestHandshake[count],))
|
, (status, latestHandshake[count],))
|
||||||
sqldb.commit()
|
|
||||||
count += 2
|
count += 2
|
||||||
|
|
||||||
|
|
||||||
@@ -1074,7 +1091,7 @@ def regex_match(regex, text):
|
|||||||
|
|
||||||
def iPv46RegexCheck(ip):
|
def iPv46RegexCheck(ip):
|
||||||
return re.match(
|
return re.match(
|
||||||
'((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))',
|
r'((^\s*((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))\s*$)|(^\s*((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$))',
|
||||||
ip)
|
ip)
|
||||||
|
|
||||||
class DashboardAPIKey:
|
class DashboardAPIKey:
|
||||||
@@ -1284,16 +1301,20 @@ def _regexMatch(regex, text):
|
|||||||
return pattern.search(text) is not None
|
return pattern.search(text) is not None
|
||||||
|
|
||||||
|
|
||||||
def _getConfigurationList() -> [WireguardConfiguration]:
|
def _getConfigurationList():
|
||||||
configurations = {}
|
# configurations = {}
|
||||||
for i in os.listdir(WG_CONF_PATH):
|
for i in os.listdir(WG_CONF_PATH):
|
||||||
if _regexMatch("^(.{1,}).(conf)$", i):
|
if _regexMatch("^(.{1,}).(conf)$", i):
|
||||||
i = i.replace('.conf', '')
|
i = i.replace('.conf', '')
|
||||||
try:
|
try:
|
||||||
configurations[i] = WireguardConfiguration(i)
|
if i in WireguardConfigurations.keys():
|
||||||
|
if WireguardConfigurations[i].configurationFileChanged():
|
||||||
|
WireguardConfigurations[i] = WireguardConfiguration(i)
|
||||||
|
else:
|
||||||
|
WireguardConfigurations[i] = WireguardConfiguration(i)
|
||||||
except WireguardConfiguration.InvalidConfigurationFileException as e:
|
except WireguardConfiguration.InvalidConfigurationFileException as e:
|
||||||
print(f"{i} have an invalid configuration file.")
|
print(f"{i} have an invalid configuration file.")
|
||||||
return configurations
|
|
||||||
|
|
||||||
|
|
||||||
def _checkIPWithRange(ip):
|
def _checkIPWithRange(ip):
|
||||||
@@ -1354,8 +1375,7 @@ def _generatePrivateKey() -> [bool, str]:
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
return False, None
|
return False, None
|
||||||
|
|
||||||
|
def _getWireguardConfigurationAvailableIP(configName: str, all: bool = False) -> tuple[bool, list[str]] | tuple[bool, None]:
|
||||||
def _getWireguardConfigurationAvailableIP(configName: str) -> tuple[bool, list[str]] | tuple[bool, None]:
|
|
||||||
if configName not in WireguardConfigurations.keys():
|
if configName not in WireguardConfigurations.keys():
|
||||||
return False, None
|
return False, None
|
||||||
configuration = WireguardConfigurations[configName]
|
configuration = WireguardConfigurations[configName]
|
||||||
@@ -1387,8 +1407,9 @@ def _getWireguardConfigurationAvailableIP(configName: str) -> tuple[bool, list[s
|
|||||||
if h not in existedAddress:
|
if h not in existedAddress:
|
||||||
availableAddress.append(ipaddress.ip_network(h).compressed)
|
availableAddress.append(ipaddress.ip_network(h).compressed)
|
||||||
count += 1
|
count += 1
|
||||||
if network.version == 6 and count > 255:
|
if not all:
|
||||||
break
|
if network.version == 6 and count > 255:
|
||||||
|
break
|
||||||
return True, availableAddress
|
return True, availableAddress
|
||||||
|
|
||||||
return False, None
|
return False, None
|
||||||
@@ -1534,7 +1555,7 @@ def API_SignOut():
|
|||||||
|
|
||||||
@app.route(f'{APP_PREFIX}/api/getWireguardConfigurations', methods=["GET"])
|
@app.route(f'{APP_PREFIX}/api/getWireguardConfigurations', methods=["GET"])
|
||||||
def API_getWireguardConfigurations():
|
def API_getWireguardConfigurations():
|
||||||
# WireguardConfigurations = _getConfigurationList()
|
_getConfigurationList()
|
||||||
return ResponseObject(data=[wc for wc in WireguardConfigurations.values()])
|
return ResponseObject(data=[wc for wc in WireguardConfigurations.values()])
|
||||||
|
|
||||||
|
|
||||||
@@ -1841,17 +1862,7 @@ def API_addPeers(configName):
|
|||||||
if i not in availableIps[1]:
|
if i not in availableIps[1]:
|
||||||
return ResponseObject(False, f"This IP is not available: {i}")
|
return ResponseObject(False, f"This IP is not available: {i}")
|
||||||
|
|
||||||
config.addPeers([{"id": public_key, "allowed_ip": ''.join(allowed_ips)}])
|
config.addPeers([{"id": public_key, "allowed_ip": ','.join(allowed_ips)}])
|
||||||
# subprocess.check_output(
|
|
||||||
# f"wg set {config.Name} peer {public_key} allowed-ips {''.join(allowed_ips)}",
|
|
||||||
# shell=True, stderr=subprocess.STDOUT)
|
|
||||||
# if len(preshared_key) > 0:
|
|
||||||
# subprocess.check_output(
|
|
||||||
# f"wg set {config.Name} peer {public_key} preshared-key {preshared_key}",
|
|
||||||
# shell=True, stderr=subprocess.STDOUT)
|
|
||||||
# subprocess.check_output(
|
|
||||||
# f"wg-quick save {config.Name}", shell=True, stderr=subprocess.STDOUT)
|
|
||||||
# config.getPeersList()
|
|
||||||
found, peer = config.searchPeer(public_key)
|
found, peer = config.searchPeer(public_key)
|
||||||
if found:
|
if found:
|
||||||
return peer.updatePeer(name, private_key, preshared_key, dns_addresses, ",".join(allowed_ips),
|
return peer.updatePeer(name, private_key, preshared_key, dns_addresses, ",".join(allowed_ips),
|
||||||
@@ -2188,7 +2199,7 @@ _, WG_CONF_PATH = DashboardConfig.GetConfig("Server", "wg_conf_path")
|
|||||||
|
|
||||||
|
|
||||||
WireguardConfigurations: dict[str, WireguardConfiguration] = {}
|
WireguardConfigurations: dict[str, WireguardConfiguration] = {}
|
||||||
WireguardConfigurations = _getConfigurationList()
|
_getConfigurationList()
|
||||||
|
|
||||||
def startThreads():
|
def startThreads():
|
||||||
bgThread = threading.Thread(target=backGroundThread)
|
bgThread = threading.Thread(target=backGroundThread)
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
echo "Starting the WireGuard Dashboard Docker container."
|
||||||
|
|
||||||
|
clean_up() {
|
||||||
|
# Cleaning out previous data such as the .pid file and starting the WireGuard Dashboard. Making sure to use the python venv.
|
||||||
|
echo "Looking for remains of previous instances..."
|
||||||
|
if [ -f "/opt/wireguarddashboard/app/src/gunicorn.pid" ]; then
|
||||||
|
echo "Found old .pid file, removing."
|
||||||
|
rm /opt/wireguarddashboard/app/src/gunicorn.pid
|
||||||
|
else
|
||||||
|
echo "No remains found, continuing."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
ensure_blocking() {
|
||||||
|
sleep 1s
|
||||||
|
echo "Ensuring container continuation."
|
||||||
|
|
||||||
|
# This function checks if the latest error log is created and tails it for docker logs uses.
|
||||||
|
if find "/opt/wireguarddashboard/src/log" -mindepth 1 -maxdepth 1 -type f | read -r; then
|
||||||
|
latestErrLog=$(find /opt/wireguarddashboard/src/log -name "error_*.log" | head -n 1)
|
||||||
|
latestAccLog=$(find /opt/wireguarddashboard/src/log -name "access_*.log" | head -n 1)
|
||||||
|
tail -f "${latestErrLog}" "${latestAccLog}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Blocking command in case of erroring. So the container does not quit.
|
||||||
|
sleep infinity
|
||||||
|
}
|
||||||
|
|
||||||
|
{ date; clean_up; printf "\n\n"; } >> ./log/install.txt
|
||||||
|
|
||||||
|
chmod u+x /opt/wireguarddashboard/src/wgd.sh
|
||||||
|
/opt/wireguarddashboard/src/wgd.sh install
|
||||||
|
/opt/wireguarddashboard/src/wgd.sh docker_start
|
||||||
|
ensure_blocking
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
WIREGUARD_INTERFACE=ADMINS
|
||||||
|
WIREGUARD_LAN=10.0.0.1/24
|
||||||
|
MASQUERADE_INTERFACE=eth0
|
||||||
|
|
||||||
|
CHAIN_NAME="WIREGUARD_$WIREGUARD_INTERFACE"
|
||||||
|
|
||||||
|
iptables -t nat -D POSTROUTING -o $MASQUERADE_INTERFACE -j MASQUERADE -s $WIREGUARD_LAN
|
||||||
|
|
||||||
|
# Remove and delete the WIREGUARD_wg0 chain
|
||||||
|
iptables -D FORWARD -j $CHAIN_NAME
|
||||||
|
iptables -F $CHAIN_NAME
|
||||||
|
iptables -X $CHAIN_NAME
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
WIREGUARD_INTERFACE=ADMINS
|
||||||
|
WIREGUARD_LAN=10.0.0.1/24
|
||||||
|
MASQUERADE_INTERFACE=eth0
|
||||||
|
|
||||||
|
iptables -t nat -I POSTROUTING -o $MASQUERADE_INTERFACE -j MASQUERADE -s $WIREGUARD_LAN
|
||||||
|
|
||||||
|
# Add a WIREGUARD_wg0 chain to the FORWARD chain
|
||||||
|
CHAIN_NAME="WIREGUARD_$WIREGUARD_INTERFACE"
|
||||||
|
iptables -N $CHAIN_NAME
|
||||||
|
iptables -A FORWARD -j $CHAIN_NAME
|
||||||
|
|
||||||
|
# Accept related or established traffic
|
||||||
|
iptables -A $CHAIN_NAME -o $WIREGUARD_INTERFACE -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
||||||
|
|
||||||
|
# Accept traffic from any Wireguard IP address connected to the Wireguard server
|
||||||
|
iptables -A $CHAIN_NAME -s $WIREGUARD_LAN -i $WIREGUARD_INTERFACE -j ACCEPT
|
||||||
|
|
||||||
|
# Allow traffic to the local loopback interface
|
||||||
|
iptables -A $CHAIN_NAME -o lo -j ACCEPT
|
||||||
|
|
||||||
|
# Drop everything else coming through the Wireguard interface
|
||||||
|
iptables -A $CHAIN_NAME -i $WIREGUARD_INTERFACE -j DROP
|
||||||
|
|
||||||
|
# Return to FORWARD chain
|
||||||
|
iptables -A $CHAIN_NAME -j RETURN
|
||||||
BIN
Binary file not shown.
Binary file not shown.
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+20
-20
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "app",
|
"name": "app",
|
||||||
"version": "4.0.2",
|
"version": "4.0.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+16
-4
@@ -30,12 +30,24 @@ export default {
|
|||||||
this.data.private_key = this.keypair.privateKey;
|
this.data.private_key = this.keypair.privateKey;
|
||||||
this.data.public_key = this.keypair.publicKey;
|
this.data.public_key = this.keypair.publicKey;
|
||||||
},
|
},
|
||||||
|
testKey(key){
|
||||||
|
const reg = /^[A-Za-z0-9+/]{43}=?=?$/;
|
||||||
|
return reg.test(key)
|
||||||
|
},
|
||||||
checkMatching(){
|
checkMatching(){
|
||||||
try{
|
try{
|
||||||
if (window.wireguard.generatePublicKey(this.keypair.privateKey)
|
if(this.keypair.privateKey){
|
||||||
!== this.keypair.publicKey){
|
if(this.testKey(this.keypair.privateKey)){
|
||||||
this.error = true;
|
this.keypair.publicKey = window.wireguard.generatePublicKey(this.keypair.privateKey)
|
||||||
this.dashboardStore.newMessage("WGDashboard", "Private Key and Public Key does not match.", "danger");
|
if (window.wireguard.generatePublicKey(this.keypair.privateKey)
|
||||||
|
!== this.keypair.publicKey){
|
||||||
|
this.error = true;
|
||||||
|
this.dashboardStore.newMessage("WGDashboard", "Private Key and Public Key does not match.", "danger");
|
||||||
|
}else{
|
||||||
|
this.data.private_key = this.keypair.privateKey
|
||||||
|
this.data.public_key = this.keypair.publicKey
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}catch (e){
|
}catch (e){
|
||||||
this.error = true;
|
this.error = true;
|
||||||
|
|||||||
+126
-82
@@ -65,8 +65,6 @@ _determineOS(){
|
|||||||
OS=$ID
|
OS=$ID
|
||||||
elif [ -f /etc/redhat-release ]; then
|
elif [ -f /etc/redhat-release ]; then
|
||||||
OS="redhat"
|
OS="redhat"
|
||||||
# elif [ -f /etc/arch-release ]; then
|
|
||||||
# OS="arch"
|
|
||||||
else
|
else
|
||||||
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS." "$heavy_crossmark"
|
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS." "$heavy_crossmark"
|
||||||
printf "%s\n" "$helpMsg"
|
printf "%s\n" "$helpMsg"
|
||||||
@@ -87,6 +85,9 @@ _installPython(){
|
|||||||
{ sudo yum install -y python3 net-tools ; printf "\n\n"; } >> ./log/install.txt
|
{ sudo yum install -y python3 net-tools ; printf "\n\n"; } >> ./log/install.txt
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
alpine)
|
||||||
|
{ apk update; apk add python3 net-tools; printf "\n\n"; } &>> ./log/install.txt
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if ! python3 --version > /dev/null 2>&1
|
if ! python3 --version > /dev/null 2>&1
|
||||||
@@ -112,6 +113,9 @@ _installPythonVenv(){
|
|||||||
{ sudo yum install -y python3-virtualenv; printf "\n\n"; } >> ./log/install.txt
|
{ sudo yum install -y python3-virtualenv; printf "\n\n"; } >> ./log/install.txt
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
alpine)
|
||||||
|
{ apk add python3 py3-virtualenv; 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.\n" "$heavy_crossmark"
|
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS.\n" "$heavy_crossmark"
|
||||||
printf "%s\n" "$helpMsg"
|
printf "%s\n" "$helpMsg"
|
||||||
@@ -123,18 +127,6 @@ _installPythonVenv(){
|
|||||||
ubuntu|debian)
|
ubuntu|debian)
|
||||||
{ sudo apt-get update; sudo apt-get install ${pythonExecutable}-venv; } &>> ./log/install.txt
|
{ sudo apt-get update; sudo apt-get install ${pythonExecutable}-venv; } &>> ./log/install.txt
|
||||||
;;
|
;;
|
||||||
# centos|fedora|redhat|rhel)
|
|
||||||
# if command -v dnf &> /dev/null; then
|
|
||||||
# { sudo dnf install -y ${pythonExecutable}-virtualenv; printf "\n\n"; } >> ./log/install.txt
|
|
||||||
# else
|
|
||||||
# { sudo yum install -y ${pythonExecutable}-virtualenv; printf "\n\n"; } >> ./log/install.txt
|
|
||||||
# fi
|
|
||||||
# ;;
|
|
||||||
# *)
|
|
||||||
# printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS.\n" "$heavy_crossmark"
|
|
||||||
# printf "%s\n" "$helpMsg"
|
|
||||||
# kill $TOP_PID
|
|
||||||
# ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -166,6 +158,9 @@ _installPythonPip(){
|
|||||||
{ sudo dnf install -y ${pythonExecutable}-pip; printf "\n\n"; } >> ./log/install.txt
|
{ sudo dnf install -y ${pythonExecutable}-pip; printf "\n\n"; } >> ./log/install.txt
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
alpine)
|
||||||
|
{ apk add py3-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.\n" "$heavy_crossmark"
|
printf "[WGDashboard] %s Sorry, your OS is not supported. Currently the install script only support Debian-based, Red Hat-based OS.\n" "$heavy_crossmark"
|
||||||
printf "%s\n" "$helpMsg"
|
printf "%s\n" "$helpMsg"
|
||||||
@@ -247,16 +242,14 @@ install_wgd(){
|
|||||||
_installPythonVenv
|
_installPythonVenv
|
||||||
_installPythonPip
|
_installPythonPip
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ ! -d "db" ]
|
if [ ! -d "db" ]
|
||||||
then
|
then
|
||||||
printf "[WGDashboard] Creating ./db folder\n"
|
printf "[WGDashboard] Creating ./db folder\n"
|
||||||
mkdir "db"
|
mkdir "db"
|
||||||
fi
|
fi
|
||||||
_check_and_set_venv
|
_check_and_set_venv
|
||||||
printf "[WGDashboard] Upgrading Python Package Manage (PIP)\n"
|
printf "[WGDashboard] Upgrading Python Package Manage (PIP)\n"
|
||||||
|
{ date; python3 -m ensurepip --upgrade; printf "\n\n"; } >> ./log/install.txt
|
||||||
{ date; python3 -m pip install --upgrade pip; printf "\n\n"; } >> ./log/install.txt
|
{ date; python3 -m pip install --upgrade pip; printf "\n\n"; } >> ./log/install.txt
|
||||||
printf "[WGDashboard] Installing latest Python dependencies\n"
|
printf "[WGDashboard] Installing latest Python dependencies\n"
|
||||||
{ date; python3 -m pip install -r requirements.txt ; printf "\n\n"; } >> ./log/install.txt
|
{ date; python3 -m pip install -r requirements.txt ; printf "\n\n"; } >> ./log/install.txt
|
||||||
@@ -281,11 +274,11 @@ check_wgd_status(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
certbot_create_ssl () {
|
certbot_create_ssl () {
|
||||||
certbot certonly --config ./certbot.ini --email "$EMAIL" --work-dir $cb_work_dir --config-dir $cb_config_dir --domain "$SERVERURL"
|
certbot certonly --config ./certbot.ini --email "$EMAIL" --work-dir $cb_work_dir --config-dir $cb_config_dir --domain "$SERVERURL"
|
||||||
}
|
}
|
||||||
|
|
||||||
certbot_renew_ssl () {
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
gunicorn_start () {
|
gunicorn_start () {
|
||||||
@@ -312,7 +305,7 @@ gunicorn_start () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gunicorn_stop () {
|
gunicorn_stop () {
|
||||||
sudo kill $(cat ./gunicorn.pid)
|
sudo kill $(cat ./gunicorn.pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
start_wgd () {
|
start_wgd () {
|
||||||
@@ -321,23 +314,70 @@ start_wgd () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop_wgd() {
|
stop_wgd() {
|
||||||
if test -f "$PID_FILE"; then
|
if test -f "$PID_FILE"; then
|
||||||
gunicorn_stop
|
gunicorn_stop
|
||||||
else
|
else
|
||||||
kill "$(ps aux | grep "[p]ython3 $app_name" | awk '{print $2}')"
|
kill "$(ps aux | grep "[p]ython3 $app_name" | awk '{print $2}')"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
startwgd_docker() {
|
||||||
|
_checkWireguard
|
||||||
|
printf "[WGDashboard][Docker] WireGuard configuration started\n"
|
||||||
|
{ date; start_core ; printf "\n\n"; } >> ./log/install.txt
|
||||||
|
gunicorn_start
|
||||||
|
}
|
||||||
|
|
||||||
|
start_core() {
|
||||||
|
local iptable_dir="/opt/wireguarddashboard/src/iptable-rules"
|
||||||
|
# Check if wg0.conf exists in /etc/wireguard
|
||||||
|
if [[ ! -f /etc/wireguard/wg0.conf ]]; then
|
||||||
|
echo "[WGDashboard][Docker] wg0.conf not found. Running generate configuration."
|
||||||
|
newconf_wgd
|
||||||
|
else
|
||||||
|
echo "[WGDashboard][Docker] wg0.conf already exists. Skipping WireGuard configuration generation."
|
||||||
|
fi
|
||||||
|
# Re-assign config_files to ensure it includes any newly created configurations
|
||||||
|
local config_files=$(find /etc/wireguard -type f -name "*.conf")
|
||||||
|
|
||||||
|
# Set file permissions
|
||||||
|
find /etc/wireguard -type f -name "*.conf" -exec chmod 600 {} \;
|
||||||
|
find "$iptable_dir" -type f -name "*.sh" -exec chmod +x {} \;
|
||||||
|
|
||||||
|
# Start WireGuard for each config file
|
||||||
|
for file in $config_files; do
|
||||||
|
config_name=$(basename "$file" ".conf")
|
||||||
|
wg-quick up "$config_name"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
newconf_wgd() {
|
||||||
|
local wg_port_listen=$wg_port
|
||||||
|
local wg_addr_range=$wg_net
|
||||||
|
private_key=$(wg genkey)
|
||||||
|
public_key=$(echo "$private_key" | wg pubkey)
|
||||||
|
cat <<EOF >"/etc/wireguard/wg0.conf"
|
||||||
|
[Interface]
|
||||||
|
PrivateKey = $private_key
|
||||||
|
Address = $wg_addr_range
|
||||||
|
ListenPort = $wg_port_listen
|
||||||
|
SaveConfig = true
|
||||||
|
PostUp = /opt/wireguarddashboard/src/iptable-rules/postup.sh
|
||||||
|
PreDown = /opt/wireguarddashboard/src/iptable-rules/postdown.sh
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
start_wgd_debug() {
|
start_wgd_debug() {
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
_checkWireguard
|
_checkWireguard
|
||||||
printf "[WGDashboard] Starting WGDashboard in the foreground.\n"
|
printf "[WGDashboard] Starting WGDashboard in the foreground.\n"
|
||||||
sudo "$venv_python" "$app_name"
|
sudo "$venv_python" "$app_name"
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
}
|
}
|
||||||
|
|
||||||
update_wgd() {
|
update_wgd() {
|
||||||
|
|
||||||
_determineOS
|
_determineOS
|
||||||
if ! python3 --version > /dev/null 2>&1
|
if ! python3 --version > /dev/null 2>&1
|
||||||
then
|
then
|
||||||
@@ -376,51 +416,55 @@ update_wgd() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if [ "$#" != 1 ];
|
if [ "$#" != 1 ];
|
||||||
then
|
then
|
||||||
help
|
help
|
||||||
else
|
else
|
||||||
if [ "$1" = "start" ]; then
|
if [ "$1" = "start" ]; then
|
||||||
if check_wgd_status; then
|
if check_wgd_status; then
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
printf "[WGDashboard] WGDashboard is already running.\n"
|
printf "[WGDashboard] WGDashboard is already running.\n"
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
else
|
else
|
||||||
start_wgd
|
start_wgd
|
||||||
fi
|
fi
|
||||||
elif [ "$1" = "stop" ]; then
|
elif [ "$1" = "docker_start" ]; then
|
||||||
if check_wgd_status; then
|
printf "%s\n" "$dashes"
|
||||||
printf "%s\n" "$dashes"
|
startwgd_docker
|
||||||
stop_wgd
|
printf "%s\n" "$dashes"
|
||||||
printf "[WGDashboard] WGDashboard is stopped.\n"
|
elif [ "$1" = "stop" ]; then
|
||||||
printf "%s\n" "$dashes"
|
if check_wgd_status; then
|
||||||
else
|
printf "%s\n" "$dashes"
|
||||||
printf "%s\n" "$dashes"
|
stop_wgd
|
||||||
printf "[WGDashboard] WGDashboard is not running.\n"
|
printf "[WGDashboard] WGDashboard is stopped.\n"
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
fi
|
else
|
||||||
elif [ "$1" = "update" ]; then
|
printf "%s\n" "$dashes"
|
||||||
update_wgd
|
printf "[WGDashboard] WGDashboard is not running.\n"
|
||||||
elif [ "$1" = "install" ]; then
|
printf "%s\n" "$dashes"
|
||||||
printf "%s\n" "$dashes"
|
fi
|
||||||
install_wgd
|
elif [ "$1" = "update" ]; then
|
||||||
printf "%s\n" "$dashes"
|
update_wgd
|
||||||
elif [ "$1" = "restart" ]; then
|
elif [ "$1" = "install" ]; then
|
||||||
if check_wgd_status; then
|
printf "%s\n" "$dashes"
|
||||||
printf "%s\n" "$dashes"
|
install_wgd
|
||||||
stop_wgd
|
printf "%s\n" "$dashes"
|
||||||
printf "| WGDashboard is stopped. |\n"
|
elif [ "$1" = "restart" ]; then
|
||||||
sleep 4
|
if check_wgd_status; then
|
||||||
start_wgd
|
printf "%s\n" "$dashes"
|
||||||
else
|
stop_wgd
|
||||||
start_wgd
|
printf "[WGDashboard] WGDashboard is stopped.\n"
|
||||||
fi
|
sleep 4
|
||||||
elif [ "$1" = "debug" ]; then
|
start_wgd
|
||||||
if check_wgd_status; then
|
else
|
||||||
printf "| WGDashboard is already running. |\n"
|
start_wgd
|
||||||
else
|
fi
|
||||||
start_wgd_debug
|
elif [ "$1" = "debug" ]; then
|
||||||
fi
|
if check_wgd_status; then
|
||||||
else
|
printf "[WGDashboard] WGDashboard is already running.\n"
|
||||||
help
|
else
|
||||||
fi
|
start_wgd_debug
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
help
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user