40 lines
1.5 KiB
Bash
40 lines
1.5 KiB
Bash
#!/bin/sh
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
#
|
|
# The image's entrypoint (deploy/docker/compose.yaml runs it twice):
|
|
# control write control.toml from the environment once (deploy/linux/setup.sh), then
|
|
# run the control plane on 127.0.0.1:7878 (in edge's network namespace)
|
|
# edge wait for control's first edge.json, then serve 80 and 443
|
|
# setup-link print the first admin's sign-in link
|
|
# <anything> run it (ianitor-control token create ..., a shell)
|
|
set -eu
|
|
|
|
ROOT=/var/lib/ianitor
|
|
export IANITOR_ROOT=$ROOT IANITOR_CONFIG=$ROOT/control.toml IANITOR_EDGE_SOCKET=/run/ianitor/admin.sock
|
|
|
|
case "${1:-edge}" in
|
|
control)
|
|
sh /usr/local/lib/ianitor/setup.sh
|
|
exec ianitor-control --config "$IANITOR_CONFIG"
|
|
;;
|
|
edge)
|
|
i=0
|
|
while [ ! -s "$ROOT/edge/edge.json" ]; do
|
|
i=$((i + 1))
|
|
[ $i -le 120 ] || { echo "edge: no edge.json from control after 120 s" >&2; exit 1; }
|
|
sleep 1
|
|
done
|
|
exec ianitor-edge --config "$ROOT/edge/edge.json" \
|
|
--admin-socket /run/ianitor/admin.sock \
|
|
--share-revocations "$ROOT/edge/share-revocations.json"
|
|
;;
|
|
setup-link)
|
|
exec ianitor-control team setup-link --config "$IANITOR_CONFIG"
|
|
;;
|
|
*)
|
|
exec "$@"
|
|
;;
|
|
esac
|