forked from Mon-ius/Docker-Warp-Socks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·55 lines (43 loc) · 1.68 KB
/
entrypoint.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
#!/bin/bash
set -e
sleep 5
IFACE=$(ip route show default | awk '{print $5}')
if [ ! -e "/opt/wgcf-profile.conf" ]; then
IPv4=$(ifconfig $IFACE | awk '/inet /{print $2}' | cut -d' ' -f2)
IPv6=$(ifconfig $IFACE | awk '/inet6 /{print $2}' | cut -d' ' -f2)
TAR="https://api.github.com/repos/ViRb3/wgcf/releases/latest"
ARCH=$(dpkg --print-architecture)
URL=$(curl -fsSL ${TAR} | grep 'browser_download_url' | cut -d'"' -f4 | grep linux | grep "${ARCH}")
curl -fsSL "${URL}" -o ./wgcf && chmod +x ./wgcf && mv ./wgcf /usr/bin
wgcf register --accept-tos && wgcf generate && mv wgcf-profile.conf /opt
sed -i "/\[Interface\]/a PostDown = ip -6 rule delete from ${IPv6} lookup main" /opt/wgcf-profile.conf
sed -i "/\[Interface\]/a PostUp = ip -6 rule add from ${IPv6} lookup main" /opt/wgcf-profile.conf
sed -i "/\[Interface\]/a PostDown = ip -4 rule delete from ${IPv4} lookup main" /opt/wgcf-profile.conf
sed -i "/\[Interface\]/a PostUp = ip -4 rule add from ${IPv4} lookup main" /opt/wgcf-profile.conf
fi
if [ ! -e "/opt/danted.conf" ]; then
cat > /opt/danted.conf <<-EOF
logoutput: stderr
internal: ${IFACE} port = 9091
external: warp
user.unprivileged: nobody
socksmethod: none
clientmethod: none
client pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
log: error
}
socks pass {
from: 0.0.0.0/0 to: 0.0.0.0/0
}
EOF
fi
chmod +x /usr/local/bin/sthp
/bin/cp -rf /opt/wgcf-profile.conf /etc/wireguard/warp.conf
/bin/cp -rf /opt/danted.conf /etc/danted.conf
# Start the danted service
wg-quick up warp
danted &
# Start sthp with the desired command
sthp -p 9092 -s "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1):9091"
exec "$@"