-
Notifications
You must be signed in to change notification settings - Fork 0
/
wireguard-ui.sh
54 lines (43 loc) · 1.69 KB
/
wireguard-ui.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
mkdir -p ~/wireguard
cd ~/wireguard
echo "Welcome to the WireGuard installer!"
echo ""
echo "I need to ask you a few questions before starting the setup."
echo "You can keep the default options and just press enter if you are ok with them."
echo ""
# Get compose file
COMPOSE_FILE="https://github.com/ongtungduong/wireguard-installer/raw/main/compose.yaml"
curl -sSL "$COMPOSE_FILE" > compose.yaml
# Get environment variables
# Images
WG_IMAGE="ghcr.io/wg-easy/wg-easy:13"
echo "WG_IMAGE=$WG_IMAGE" > .env
# Host
while [ -z "$WG_HOST" ]; do
read -p "[Required] Please enter Wireguard Server IPv4 public address: " WG_HOST
done
echo "WG_HOST=$WG_HOST" >> .env
# Port
WG_PORT=${WG_PORT:-51820}
read -p "Please enter Wireguard Server UDP Port [Default: 51820]: " WG_PORT
echo "WG_PORT=$WG_PORT" >> .env
# Allowed IPs
WG_ALLOWED_IPS=${WG_ALLOWED_IPS:-"0.0.0.0/0"}
read -p "Please enter Wireguard Server Allow IPs [Default: 0.0.0.0/0]: " WG_ALLOWED_IPS
echo "WG_ALLOWED_IPS=$WG_ALLOWED_IPS" >> .env
# Passwords
echo "Generating Wireguard admin passwords..."
WG_PASSWORD=$(openssl rand -base64 32 | tr -d 'iI1lLoO0' | tr -d -c '[:alnum:]' | cut -c1-32)
echo "WG_PASSWORD=$WG_PASSWORD" >> .env
echo "To see Wireguard Admin Password, run the following command: cat ~/wireguard/.env | grep WG_PASSWORD"
# Wireguard UI
WG_UI_PORT=${WG_UI_PORT:-8080}
read -p "Please enter Wireguard Admin UI Port [Default: 8080]: " WG_UI_PORT
echo "WG_UI_PORT=$WG_UI_PORT" >> .env
# Start Wireguard
echo "Starting Wireguard Server..."
docker compose up -d
echo ""
echo "Wireguard Admin UI is running on port $WG_UI_PORT."
echo "It's recommended to not expose Wireguard Admin UI port to the public internet for security reasons."