-
Notifications
You must be signed in to change notification settings - Fork 32
/
setup.sh
99 lines (86 loc) · 2.81 KB
/
setup.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Open ports
read -p "VPN connection port: " vpnport
ufw allow 80
ufw allow 443
ufw allow $vpnport
echo "Ports 80, 443, and $vpnport opened, ensure they are open on VM hosting service too."
# Create 1GB swap memory
mkdir -p /var/swapmemory
cd /var/swapmemory
dd if=/dev/zero of=swapfile bs=1M count=1000
mkswap swapfile
swapon swapfile
chmod 600 swapfile
free -m
echo "Swap memory created."
# Boost network performance
sysctl -w net.core.rmem_max=26214400
sysctl -w net.core.rmem_default=26214400
sysctl -w net.core.dev_weight=40
sysctl -w net.core.netdev_tstamp_prequeue=0
sysctl -w kernel.randomize_va_space=0
echo "Network performance boosted."
# Install python, pip, and screen
apt update
apt install python3 python3-pip screen
echo "Installed python, pip, and screen."
# Install caddy
apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install caddy
echo "Caddy installed."
# Configure reverse proxy with caddy
read -p "Web admin panel domain: " admindomain
cat << EOF > /etc/caddy/Caddyfile
$admindomain {
reverse_proxy localhost:5000
}
EOF
caddy reload --config /etc/caddy/Caddyfile
echo "Reverse proxy configured with caddy."
# Setup the web admin panel
cd
git clone https://github.com/dashroshan/openvpn-wireguard-admin vpn
cd vpn
python3 -m pip install -r requirements.txt
echo "Web admin panel cloned and packages installed."
# Create the configWireguard.py
read -p "Enter 'wireguard' or 'openvpn' as needed: " vpntype
if [ "$vpntype" == "wireguard" ]; then
read -p "Enter 'True' or 'False' for AdBlock: " adblock
cat << EOF > configWireguard.py
wireGuardBlockAds = $adblock
EOF
echo "configureWireguard.py file created for AdBlock settings."
fi
# Create the config.py
read -p "Web admin panel username: " adminuser
read -p "Web admin panel password: " adminpass
passwordhash=$(echo -n $adminpass | sha256sum | cut -d" " -f1)
cat << EOF > config.py
import $vpntype as vpn
creds = {
"username": "$adminuser",
"password": "$passwordhash",
}
EOF
echo "config.py file created for web admin panel."
# Download vpn setup script
cd
if [ "$vpntype" == "wireguard" ]; then
wget https://raw.githubusercontent.com/Nyr/wireguard-install/master/wireguard-install.sh -O vpn-install.sh
else
wget https://raw.githubusercontent.com/Nyr/openvpn-install/master/openvpn-install.sh -O vpn-install.sh
fi
echo "VPN setup script downloaded."
# Setup vpn
chmod +x vpn-install.sh
bash vpn-install.sh
echo "VPN service installed."
# Run web admin portal
cd vpn
screen -dmS vpn bash -c 'python3 main.py; bash'
echo "Web admin portal started at $admindomain"
echo "Done!"