-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·64 lines (56 loc) · 1.64 KB
/
setup.sh
File metadata and controls
executable file
·64 lines (56 loc) · 1.64 KB
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
#!/bin/bash
#Set DNS to Google by default
echo "nameserver 8.8.8.8" > /etc/resolv.conf
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
# Configure reverse proxy with caddy
if [ "${USE_LETS_ENCRYPT}" = "true" ]; then
# Configure Caddy for Let's Encrypt
cat << EOF > /etc/caddy/Caddyfile
${ADMIN_DOMAIN:-example.com} {
reverse_proxy localhost:5000
}
EOF
else
# Use local certs if Let's Encrypt is not enabled
cat << EOF > /etc/caddy/Caddyfile
{
local_certs
}
${ADMIN_DOMAIN:-example.com} {
tls internal
reverse_proxy localhost:5000
}
EOF
fi
caddy start --config /etc/caddy/Caddyfile --adapter caddyfile
echo "Reverse proxy configured with caddy."
# Create the configWireguard.py or configOpenVPN.py
cat << EOF > configWireguard.py
wireGuardBlockAds = ${ADBLOCK:-True}
EOF
echo "configureWireguard.py file created for AdBlock settings."
# Create the config.py
passwordhash=$(echo -n ${ADMIN_PASSWORD:-admin} | sha256sum | cut -d" " -f1)
cat << EOF > /app/config.py
import ${VPN_TYPE:-wireguard} as vpn
creds = {
"username": "${ADMIN_USERNAME:-admin}",
"password": "$passwordhash",
}
EOF
if [ -f "/app/config.py" ]; then
echo "config.py file created successfully."
else
echo "Failed to create config.py file."
fi
# Download vpn setup script
wget https://raw.githubusercontent.com/Nyr/${VPN_TYPE:-wireguard}-install/master/${VPN_TYPE:-wireguard}-install.sh -O vpn-install.sh
echo "VPN setup script downloaded."
# Setup vpn
chmod +x vpn-install.sh
bash vpn-install.sh <<< 'auto'
echo "VPN service installed."
# Run web admin portal
exec python3 /app/main.py
echo "Web admin portal started at ${ADMIN_DOMAIN:-example.com}"
echo "Done!"