-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
83 lines (70 loc) · 2.31 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
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
#!/bin/bash
# Exit when any command fails
set -e
# Modify resolv.conf to use Cloudflare WARP DNS
echo -e "# This file was generated by cloudflare-warp.\n$(cat /etc/resolv.conf)" > /tmp/resolv.conf
cp /tmp/resolv.conf /etc/resolv.conf
# Create a tun for WARP
echo "Creating tun for WARP..."
sudo mkdir -p /dev/net
echo "Checking if /dev/net/tun exists..."
if [ ! -c /dev/net/tun ]; then
echo "Creating TUN device..."
sudo mknod /dev/net/tun c 10 200
echo "Setting permissions for TUN device..."
sudo chmod 600 /dev/net/tun
echo "TUN device created."
else
echo "TUN device already exists."
fi
# Start dbus service
sudo mkdir -p /run/dbus
echo "Checking if /run/dbus/pid exists..."
if [ -f /run/dbus/pid ]; then
echo "Removing /run/dbus/pid..."
sudo rm /run/dbus/pid
fi
echo "Starting dbus service..."
sudo dbus-daemon --config-file=/usr/share/dbus-1/system.conf
# Start the Cloudflare WARP service
echo "Starting WARP service..."
sudo warp-svc --accept-tos &
# Sleep to wait for the WARP service to start
echo "Sleeping for 5 seconds..."
sleep 5
# Check if WARP client is registered
if [ ! -f /var/lib/cloudflare-warp/reg.json ]; then
if [ ! -f /var/lib/cloudflare-warp/mdm.xml ]; then
warp-cli registration new && echo "Warp client registered!"
# if a license key is provided, register the license
if [ -n "$WARP_LICENSE_KEY" ]; then
echo "License key found, registering license..."
warp-cli registration license "$WARP_LICENSE_KEY" && echo "Warp license registered!"
fi
fi
# connect to the warp server
warp-cli --accept-tos connect
else
echo "Warp client already registered, skip registration"
fi
# Start the proxy
gost $GOST_ARGS
# Sleep to wait for proxy to start
echo "Sleeping for 5 seconds..."
sleep 5
# Start Docker Daemon in the background
echo "Starting Docker Daemon..."
/usr/local/bin/start-docker.sh &
# Sleep to wait for the Docker Daemon to start
echo "Sleeping for 5 seconds..."
sleep 5
# Run inner Docker container with NetBird client
echo "Installing netbird client..."
docker run -d --name netbird-container --network host \
--cap-add=NET_ADMIN \
-e NB_SETUP_KEY="$NETBIRD_SETUP_KEY" \
-v netbird-client:/etc/netbird \
-e NB_MANAGEMENT_URL="$NETBIRD_MGMT_URL" \
netbirdio/netbird:latest
# Execute specified command
"$@"