mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-08-27 23:41:14 +00:00
Streamiline
+ Added Docker Install arg to wgd.sh
This commit is contained in:
@@ -11,9 +11,6 @@ clean_up() {
|
||||
echo "No remains found, continuing."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
ensure_blocking() {
|
||||
sleep 1s
|
||||
echo "Ensuring container continuation."
|
||||
@@ -29,13 +26,9 @@ ensure_blocking() {
|
||||
sleep infinity
|
||||
}
|
||||
|
||||
# Execute functions for the WireGuard Dashboard services, then set the environment variables
|
||||
clean_up
|
||||
{ date; clean_up; printf "\n\n"; } >> ./log/install.txt
|
||||
|
||||
chmod u+x /opt/wireguarddashboard/src/wgd.sh
|
||||
if [ ! -f "/opt/wireguarddashboard/src/wg-dashboard.ini" ]; then
|
||||
/opt/wireguarddashboard/src/wgd.sh install
|
||||
|
||||
fi
|
||||
/opt/wireguarddashboard/src/wgd.sh start
|
||||
/opt/wireguarddashboard/src/wgd.sh install
|
||||
/opt/wireguarddashboard/src/wgd.sh docker_start
|
||||
ensure_blocking
|
||||
|
55
src/wgd.sh
55
src/wgd.sh
@@ -256,9 +256,6 @@ install_wgd(){
|
||||
_installPythonVenv
|
||||
_installPythonPip
|
||||
|
||||
|
||||
|
||||
|
||||
if [ ! -d "db" ]
|
||||
then
|
||||
printf "[WGDashboard] Creating ./db folder\n"
|
||||
@@ -266,6 +263,7 @@ install_wgd(){
|
||||
fi
|
||||
_check_and_set_venv
|
||||
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
|
||||
printf "[WGDashboard] Installing latest Python dependencies\n"
|
||||
{ date; python3 -m pip install -r requirements.txt ; printf "\n\n"; } >> ./log/install.txt
|
||||
@@ -337,6 +335,53 @@ stop_wgd() {
|
||||
fi
|
||||
}
|
||||
|
||||
startwgd_docker() {
|
||||
_checkWireguard
|
||||
printf "[WGDashboard] WireGuard Config 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 "wg0.conf not found. Running Generate Configuration."
|
||||
newconf_wgd
|
||||
else
|
||||
echo "wg0.conf already exists. Skipping WireGuard Config 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() {
|
||||
printf "%s\n" "$dashes"
|
||||
_checkWireguard
|
||||
@@ -396,6 +441,10 @@ if [ "$#" != 1 ];
|
||||
else
|
||||
start_wgd
|
||||
fi
|
||||
elif [ "$1" = "docker_start" ]; then
|
||||
printf "%s\n" "$dashes"
|
||||
startwgd_docker
|
||||
printf "%s\n" "$dashes"
|
||||
elif [ "$1" = "stop" ]; then
|
||||
if check_wgd_status; then
|
||||
printf "%s\n" "$dashes"
|
||||
|
Reference in New Issue
Block a user