summaryrefslogtreecommitdiff
path: root/doc/ext/kubernetes/entrypoint.sh
blob: 8ec7312aab09c87b0baa2483b7a2a55ecc79cc7e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
echo '*** ZeroTier-Kubernetes self-auth test script'
chown -R daemon /var/lib/zerotier-one
chgrp -R daemon /var/lib/zerotier-one
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
virtip4=""
while [ -z "$virtip4" ]; do
	sleep 0.2
	virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
	dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
done
echo '*** Up and running at' $virtip4 ' on network: ' $nwid

echo '*** Self-Authorizing to deployment network'
nwconf=$(ls *.conf)
nwid="${nwconf%.*}"
AUTHTOKEN="(cat /var/lib/zerotier-one/authtoken.secret)"

grep -rl 'local_service_auth_token' ./ | xargs sed -i 's/local_service_auth_token/' $AUTHTOKEN '/g'

./zerotier-cli join $(nwid).conf
./zerotier-cli net-auth $(nwid) $(dev)

# node server.js