Skip to content

Commit 6260be8

Browse files
authored
Alpine-Wireguard (#3611)
1 parent bcbe73f commit 6260be8

File tree

3 files changed

+166
-0
lines changed

3 files changed

+166
-0
lines changed

ct/alpine-wireguard.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: MickLesk (CanbiZ)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://www.wireguard.com/
7+
8+
APP="Alpine-Wireguard"
9+
var_tags="${var_tags:-alpine;vpn}"
10+
var_cpu="${var_cpu:-1}"
11+
var_ram="${var_ram:-256}"
12+
var_disk="${var_disk:-1}"
13+
var_os="${var_os:-alpine}"
14+
var_version="${var_version:-3.21}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
msg_info "Updating Alpine Packages"
24+
$STD apk update
25+
$STD apk upgrade
26+
msg_ok "Updated Alpine Packages"
27+
28+
msg_info "update wireguard-tools"
29+
$STD apk add --no-cache --upgrade wireguard-tools
30+
msg_ok "wireguard-tools updated"
31+
32+
if [[ -d /etc/wgdashboard/src ]]; then
33+
msg_info "update WGDashboard"
34+
cd /etc/wgdashboard/src || exit
35+
$STD echo "y" | ./wgd.sh update
36+
$STD ./wgd.sh start
37+
msg_ok "WGDashboard updated"
38+
fi
39+
40+
exit 0
41+
}
42+
43+
start
44+
build_container
45+
description
46+
47+
msg_ok "Completed Successfully!\n"
48+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
49+
echo -e "${INFO}${YW} WGDashboard Access it using the following URL:${CL}"
50+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:10086${CL}"

frontend/public/json/wireguard.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@
2424
"os": "debian",
2525
"version": "12"
2626
}
27+
},
28+
{
29+
"type": "alpine",
30+
"script": "ct/alpine-wireguard.sh",
31+
"resources": {
32+
"cpu": 1,
33+
"ram": 256,
34+
"hdd": 1,
35+
"os": "alpine",
36+
"version": "3.21"
37+
}
2738
}
2839
],
2940
"default_credentials": {
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: MickLesk (CanbiZ)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://www.wireguard.com/
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies"
17+
$STD apk add \
18+
newt \
19+
curl \
20+
openssh \
21+
nano \
22+
mc \
23+
gpg \
24+
iptables \
25+
openrc
26+
msg_ok "Installed Dependencies"
27+
28+
msg_info "Installing WireGuard"
29+
$STD apk add --no-cache wireguard-tools
30+
if [[ ! -L /etc/init.d/wg-quick.wg0 ]]; then
31+
ln -s /etc/init.d/wg-quick /etc/init.d/wg-quick.wg0
32+
fi
33+
34+
private_key=$(wg genkey)
35+
cat <<EOF >/etc/wireguard/wg0.conf
36+
[Interface]
37+
PrivateKey = ${private_key}
38+
Address = 10.0.0.1/24
39+
SaveConfig = true
40+
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;
41+
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE;
42+
ListenPort = 51820
43+
EOF
44+
msg_ok "Installed WireGuard"
45+
46+
read -rp "Do you want to install WGDashboard? (y/N): " INSTALL_WGD
47+
if [[ "$INSTALL_WGD" =~ ^[Yy]$ ]]; then
48+
msg_info "Installing additional dependencies for WGDashboard"
49+
$STD apk add --no-cache \
50+
python3 \
51+
py3-pip \
52+
git \
53+
sudo \
54+
musl-dev \
55+
linux-headers \
56+
gcc \
57+
python3-dev
58+
msg_ok "Installed additional dependencies for WGDashboard"
59+
msg_info "Installing WGDashboard"
60+
git clone -q https://github.com/donaldzou/WGDashboard.git /etc/wgdashboard
61+
cd /etc/wgdashboard/src || exit
62+
chmod u+x wgd.sh
63+
$STD ./wgd.sh install
64+
$STD echo "net.ipv4.ip_forward=1" >>/etc/sysctl.conf
65+
sysctl -p /etc/sysctl.conf
66+
msg_ok "Installed WGDashboard"
67+
68+
msg_info "Creating Service for WGDashboard"
69+
cat <<EOF >/etc/init.d/wg-dashboard
70+
#!/sbin/openrc-run
71+
72+
description="WireGuard Dashboard Service"
73+
74+
depend() {
75+
need net
76+
after firewall
77+
}
78+
79+
start() {
80+
ebegin "Starting WGDashboard"
81+
cd /etc/wgdashboard/src/ || exit 1
82+
./wgd.sh start &
83+
eend $?
84+
}
85+
86+
stop() {
87+
ebegin "Stopping WGDashboard"
88+
pkill -f "wgd.sh"
89+
eend $?
90+
}
91+
EOF
92+
chmod +x /etc/init.d/wg-dashboard
93+
$STD rc-update add wg-dashboard default
94+
$STD rc-service wg-dashboard start
95+
msg_ok "Created Service for WGDashboard"
96+
97+
fi
98+
99+
msg_info "Starting Services"
100+
$STD rc-update add wg-quick.wg0 default
101+
$STD rc-service wg-quick.wg0 start
102+
msg_ok "Started Services"
103+
104+
motd_ssh
105+
customize

0 commit comments

Comments
 (0)