-
Notifications
You must be signed in to change notification settings - Fork 7
/
wireguard.sh
36 lines (30 loc) · 1.32 KB
/
wireguard.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
#!/usr/bin/env bash
#####################################################
# Created by Afiniel for Yiimpool use...
#####################################################
source $HOME/yiimpool/yiimp_single/.wireguard.install.cnf
source $STORAGE_ROOT/yiimp/.wireguard.conf
source /etc/yiimpool.conf
clear
echo -e "$YELLOW Installing WireGuard...$COL_RESET"
sudo add-apt-repository ppa:wireguard/wireguard -y
sudo apt-get update -y
sudo apt-get install wireguard-dkms wireguard-tools -y
(umask 077 && printf "[Interface]\nPrivateKey = " | sudo tee /etc/wireguard/wg0.conf > /dev/null)
wg genkey | sudo tee -a /etc/wireguard/wg0.conf | wg pubkey | sudo tee /etc/wireguard/publickey
# Install WireGuard on main server.
echo "ListenPort = 6121" | hide_output sudo tee -a /etc/wireguard/wg0.conf
echo "SaveConfig = true" | hide_output sudo tee -a /etc/wireguard/wg0.conf
echo "Address = ${DBInternalIP}/24" | hide_output sudo tee -a /etc/wireguard/wg0.conf
cd $HOME
sudo systemctl start wg-quick@wg0
sudo systemctl enable wg-quick@wg0
sudo ufw allow 6121
clear
dbpublic=${PUBLIC_IP}
mypublic="$(sudo cat /etc/wireguard/publickey)"
echo ' Public Ip: '"${dbpublic}"'
Public Key: '"${mypublic}"'
' | sudo -E tee $STORAGE_ROOT/yiimp/.wireguard_public.conf >/dev/null 2>&1;
echo -e "$GREEN WireGuard setup completed...$COL_RESET"
cd $HOME/yiimpool/yiimp_single