Join networks by touching a file

Signed-off-by: Erik Hollensbe <git@hollensbe.org>
This commit is contained in:
Erik Hollensbe 2022-03-23 17:56:09 -07:00
parent 2388c9f4e4
commit c30a1f60ea
No known key found for this signature in database
GPG Key ID: 4BB0E241A863B389

View File

@ -40,30 +40,35 @@ killzerotier() {
trap killzerotier INT TERM
echo "Configuring networks to join"
mkdir -p /var/lib/zerotier-one/networks.d
echo "joining networks: $@"
for i in "$@"
do
echo "Configuring join for $i"
touch "/var/lib/zerotier-one/networks.d/${i}.conf"
done
echo "starting zerotier"
nohup /usr/sbin/zerotier-one &
while ! grepzt
do
echo "zerotier hasn't started, waiting a second"
tail -n 10 nohup.out
if [ -f nohup.out ]
then
tail -n 10 nohup.out
fi
sleep 1
done
echo "joining networks: $@"
echo "Ensuring status for networks: $@"
for i in "$@"
do
echo "joining $i"
zerotier-cli join "$i"
if [ $? -ne 0 ]
then
echo >&2 "ZeroTier could not be started; did you pass the right arguments to \`docker run\`?"
exit 1
fi
while [ "$(zerotier-cli get $i status)" != "OK" ]
do
echo "joining $i failed (are they added in central?); trying again in 1s"