mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-12-27 09:22:19 +08:00
fixed issues with commits
This commit is contained in:
parent
d4819b13eb
commit
0c5033ff79
8 changed files with 1 additions and 154 deletions
|
@ -1,5 +1,4 @@
|
||||||
# WGDashboard Docker Explanation:
|
# WGDashboard Docker Explanation:
|
||||||
|
|
||||||
Author: DaanSelen<br>
|
Author: DaanSelen<br>
|
||||||
|
|
||||||
This document delves into how the WGDashboard Docker container has been built.<br>
|
This document delves into how the WGDashboard Docker container has been built.<br>
|
||||||
|
@ -100,7 +99,6 @@ dselen/wgdashboard latest c96fd96ee3b3 42 minutes ago 314MB
|
||||||
|
|
||||||
## Closing remarks:
|
## Closing remarks:
|
||||||
|
|
||||||
Excuse the large image size, whoops! Debian's big... sometimes.<br>
|
|
||||||
For feedback please submit an issue to the repository. Or message dselen@nerthus.nl.
|
For feedback please submit an issue to the repository. Or message dselen@nerthus.nl.
|
||||||
|
|
||||||
## In Progress:
|
## In Progress:
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
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
|
|
|
@ -1,2 +0,0 @@
|
||||||
bcrypt
|
|
||||||
psutil
|
|
|
@ -31,7 +31,7 @@ ensure_installation() {
|
||||||
|
|
||||||
# This first step is to ensure the wg0.conf file exists, and if not, then its copied over from the ephemeral container storage.
|
# This first step is to ensure the wg0.conf file exists, and if not, then its copied over from the ephemeral container storage.
|
||||||
if [ ! -f "/etc/wireguard/wg0.conf" ]; then
|
if [ ! -f "/etc/wireguard/wg0.conf" ]; then
|
||||||
echo "Standard wg0 Configuration file not found, grabbing template. And adjusting permissions."
|
echo "Standard wg0 Configuration file not found, grabbing template."
|
||||||
cp -a "/setup/conf/wg0.conf" "/etc/wireguard/wg0.conf"
|
cp -a "/setup/conf/wg0.conf" "/etc/wireguard/wg0.conf"
|
||||||
|
|
||||||
echo "Setting a secure private key."
|
echo "Setting a secure private key."
|
||||||
|
|
|
@ -1,34 +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
|
|
||||||
}
|
|
||||||
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
|
|
|
@ -1,13 +0,0 @@
|
||||||
#!/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
|
|
|
@ -1,26 +0,0 @@
|
||||||
#!/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
|
|
33
src/wgd.sh
33
src/wgd.sh
|
@ -341,22 +341,7 @@ stop_wgd() {
|
||||||
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() {
|
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
|
# Re-assign config_files to ensure it includes any newly created configurations
|
||||||
local config_files=$(find /etc/wireguard -type f -name "*.conf")
|
local config_files=$(find /etc/wireguard -type f -name "*.conf")
|
||||||
|
|
||||||
|
@ -371,24 +356,6 @@ start_core() {
|
||||||
done
|
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
|
||||||
|
|
Loading…
Reference in a new issue