File size: 1,486 Bytes
7096988
 
 
 
 
f91e299
 
 
 
 
7096988
f91e299
6f353e9
7096988
6f353e9
7096988
6f353e9
7096988
b1c81ba
6f353e9
7096988
 
 
 
 
 
 
 
b1c81ba
7096988
 
 
b1c81ba
7096988
 
 
 
 
b1c81ba
7096988
 
b1c81ba
 
 
 
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
#!/bin/bash

# exit when any command fails
set -e

# Check if /dev/net/tun already exists, avoid creating it if it's already present
if [ ! -c /dev/net/tun ]; then
    echo "/dev/net/tun not found, unable to create it as non-root user. Ensure the hosting environment provides the tun device."
    exit 1
fi

# start dbus (if applicable)
mkdir -p /run/dbus
if [ -f /run/dbus/pid ]; then
    rm /run/dbus/pid
fi
dbus-daemon --config-file=/usr/share/dbus-1/system.conf

# start the WARP daemon
warp-svc --accept-tos &

# sleep to wait for the daemon to start, default 2 seconds
sleep "$WARP_SLEEP"

# if /var/lib/cloudflare-warp/reg.json not exists, setup new warp client
if [ ! -f /var/lib/cloudflare-warp/reg.json ]; then
    # if /var/lib/cloudflare-warp/mdm.xml not exists, register the warp client
    if [ ! -f /var/lib/cloudflare-warp/mdm.xml ]; then
        warp-cli register && 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 register --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, skipping registration"
fi

# Start WARP in proxy mode on localhost
echo "Starting WARP in local proxy mode..."
warp-cli --accept-tos set-mode proxy
warp-cli --accept-tos connect