Male / entrypoint.sh
LoremPizza's picture
Update entrypoint.sh
f91e299 verified
#!/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