Refactor: WireGuard (#6839)

* Refactor

* Make WGDashboard optional
This commit is contained in:
Slaviša Arežina 2025-08-14 22:51:31 +02:00 committed by GitHub
parent ab07afb7bd
commit 50410acf8d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 25 deletions

View File

@ -30,10 +30,12 @@ function update_script() {
fi
apt-get update
apt-get -y upgrade
sleep 2
cd /etc/wgdashboard/src
./wgd.sh update
./wgd.sh start
if [[ ! -d /etc/wgdashboard ]]; then
sleep 2
cd /etc/wgdashboard/src
./wgd.sh update
./wgd.sh start
fi
exit
}
@ -43,5 +45,5 @@ description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} WGDashboard Access it using the following URL:${CL}"
echo -e "${INFO}${YW}Access WGDashboard (if installed) using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:10086${CL}"

View File

@ -46,6 +46,10 @@
{
"text": "Wireguard and WGDashboard are not the same. More info: `https://docs.wgdashboard.dev/what-is-wireguard-what-is-wgdashboard.html`",
"type": "info"
},
{
"text": "WGDashboard installation is optional.`",
"type": "info"
}
]
}

View File

@ -13,28 +13,27 @@ setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get install -y git
msg_ok "Installed Dependencies"
msg_info "Installing WireGuard"
$STD apt-get install -y wireguard wireguard-tools net-tools iptables
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confnew" install -y iptables-persistent &>/dev/null
$STD netfilter-persistent reload
msg_ok "Installed WireGuard"
msg_info "Installing WGDashboard"
git clone -q https://github.com/donaldzou/WGDashboard.git /etc/wgdashboard
cd /etc/wgdashboard/src
chmod u+x wgd.sh
$STD ./wgd.sh install
echo "net.ipv4.ip_forward=1" >>/etc/sysctl.conf
$STD sysctl -p /etc/sysctl.conf
msg_ok "Installed WGDashboard"
read -r -p "${TAB3}Would you like to add WGDashboard? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]; then
fetch_and_deploy_gh_release "wgdashboard" "donaldzou/WGDashboard" "tarball" "latest" "/etc/wgdashboard"
msg_info "Create Example Config for WGDashboard"
private_key=$(wg genkey)
cat <<EOF >/etc/wireguard/wg0.conf
msg_info "Installing WGDashboard"
cd /etc/wgdashboard/src
chmod u+x wgd.sh
$STD ./wgd.sh install
echo "net.ipv4.ip_forward=1" >>/etc/sysctl.conf
$STD sysctl -p /etc/sysctl.conf
msg_ok "Installed WGDashboard"
msg_info "Create Example Config for WGDashboard"
private_key=$(wg genkey)
cat <<EOF >/etc/wireguard/wg0.conf
[Interface]
PrivateKey = ${private_key}
Address = 10.0.0.1/24
@ -43,10 +42,10 @@ PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACC
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;
ListenPort = 51820
EOF
msg_ok "Created Example Config for WGDashboard"
msg_ok "Created Example Config for WGDashboard"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/wg-dashboard.service
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/wg-dashboard.service
[Unit]
After=syslog.target network-online.target
Wants=wg-quick.target
@ -66,8 +65,9 @@ Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now wg-dashboard
msg_ok "Created Service"
systemctl enable -q --now wg-dashboard
msg_ok "Created Service"
fi
motd_ssh
customize