summaryrefslogtreecommitdiffhomepage
path: root/cmd/containerboot/test_tailscaled.sh
blob: 335e2cb0dcfd1955cee77062cb3be33301fd5025 (plain)
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
#!/usr/bin/env bash
#
# This is a fake tailscale daemon that records its arguments, symlinks a
# fake LocalAPI socket into place, and does nothing until terminated.
#
# It is used by main_test.go to test the behavior of containerboot.

set -eu

echo $0 $@ >>$TS_TEST_RECORD_ARGS

socket=""
while [[ $# -gt 0 ]]; do
	case $1 in
		--socket=*)
			socket="${1#--socket=}"
			shift
			;;
		--socket)
			shift
			socket="$1"
			shift
			;;
		*)
			shift
			;;
	esac
done

if [[ -z "$socket" ]]; then
	echo "didn't find socket path in args"
	exit 1
fi

ln -s "$TS_TEST_SOCKET" "$socket"
trap 'rm -f "$socket"' EXIT

while sleep 10; do :; done