blob: 5590274f9181422e5d8ccaf1b0eddb7d3efebf80 [file] [log] [blame]
#!/bin/bash
# Copyright 2015 The Vanadium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# Starts an instance of measured and required services.
#
# mounttabled is started locally with syncbased. measured connects to it
# and bootstraps the syncgroup joinable at:
# /$IPADDR_PORT/$PREFIX/$DEVID/syncbased.
# measured drops most permissions on prefixes in the syncgroup. Full admin
# permissions are granted to $ADMIN (as a blessing extension of the same
# default blessing as the one running this script).
set -eu
source "${JIRI_ROOT}/experimental/projects/sensorlog_lite/src/v.io/x/sensorlog_lite/scripts/runner_lib.sh"
# Must be run with V23_CREDENTIALS set or through the agent.
# Optional environment variables: SL_PREFIX, SL_DEVID, SL_ADMIN, SL_IPADDR_PORT, SL_TMPDIR
function main() {
local -r PREFIX="${SL_PREFIX:-sl/measured}"
local -r DEVID="${SL_DEVID:-$(gen_uuid)}"
local -r ADMIN="${SL_ADMIN:-sl/client}"
local -r NAME="${PREFIX}/${DEVID}"
local -r IPADDR_PORT="${SL_IPADDR_PORT:-$(dig $(hostname) +short):8707}"
local -r TMPDIR="${SL_TMPDIR:-sltmp}/${NAME}"
mkdir -p "${TMPDIR}"
trap "kill_child_processes; exit 1" ERR EXIT
run_mounttabled "${NAME}" "${IPADDR_PORT}"
run_syncbased "/${IPADDR_PORT}" "${NAME}" "${TMPDIR}"
run_measured "/${IPADDR_PORT}" "${NAME}" "${DEVID}" "${ADMIN}"
# Wait for signal.
while true; do
sleep 10
done
}
main "$@"