Last active
October 1, 2021 14:02
-
-
Save awoimbee/0602089974d75bfb2852068ae772fcc7 to your computer and use it in GitHub Desktop.
Test headscale locally
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ ! command -v wg ]; then | |
sudo pacman -S wireguard-tools --noconfirm --needed | |
fi | |
if [ ! -f ./private.key ]; then | |
wg genkey > private.key | |
wg pubkey < private.key > public.key # not needed | |
fi | |
if [ ! -f derp.yaml ]; then | |
wget https://raw.githubusercontent.com/juanfont/headscale/main/derp.yaml | |
fi | |
if [ ! -f config.json ]; then | |
# let's use SQLite for this test | |
wget https://raw.githubusercontent.com/juanfont/headscale/main/config.json.sqlite.example -O config.json | |
fi | |
touch db.sqlite | |
docker run -d \ | |
-v $(pwd)/private.key:/private.key \ | |
-v $(pwd)/config.json:/config.json \ | |
-v $(pwd)/derp.yaml:/derp.yaml \ | |
-v $(pwd)/db.sqlite:/db.sqlite \ | |
-p 127.0.0.1:8080:8080 \ | |
headscale/headscale:0.9.2 \ | |
headscale namespaces create myfirstnamespace | |
CONTAINER_ID=$(docker_run headscale serve | tail -n 1) | |
echo "container ID: $CONTAINER_ID" | |
################################################################################ | |
sudo pacman -S --neeede tailscale | |
sudo systemctl start tailscaled | |
sudo tailscale up --accept-dns=false --login-server http://localhost:8080 | |
# To authenticate, visit: | |
# http://127.0.0.1:8080/register?key=xxxxxxxxxxxxx | |
CONTAINER_ID=$(docker ps | grep "headscale" | awk '{print $1}') | |
MACHINEKEY=$(curl -s "http://127.0.0.1:8080/register?key=xxxxxxxxx" | awk -F'</?b>' '{print $2}' | awk NF | awk '{print $6}') | |
docker exec "$CONTAINER_ID" headscale -n myfirstnamespace nodes register "$MACHINEKEY" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment