#!/bin/sh
set -eu

PATH="/command:${PATH}"
export PATH

BOOTSTRAP_CONFIG=/var/lib/sellable-agent-bootstrap/bootstrap.json
BOOTSTRAP_BIN=/opt/sellable-agent/install-root/node_modules/.bin/sellable-agent-host-bootstrap

test "$(id -u)" = "0"
test "$(id -g)" = "0"
install -d -m 0755 -o root -g root /run/s6/container_environment
test -x "${BOOTSTRAP_BIN}"
test -f "${BOOTSTRAP_CONFIG}"

"${BOOTSTRAP_BIN}" --config "${BOOTSTRAP_CONFIG}"
exec /command/s6-svscan /etc/services.d
