50 lines
1.8 KiB
Bash
50 lines
1.8 KiB
Bash
#!/usr/bin/with-contenv bashio
|
|
# Starts Bamboo with the address and token from the add-on's configuration.
|
|
set -e
|
|
|
|
url="$(bashio::config 'hammerhead_url')"
|
|
token="$(bashio::config 'token')"
|
|
|
|
if [ -z "${url}" ] || [ -z "${token}" ]; then
|
|
bashio::log.fatal "Set the Hammerhead address and the site token in this add-on's Configuration tab, then start it again."
|
|
bashio::exit.nok
|
|
fi
|
|
|
|
# Settings go in through the environment so the token does not show up in the process list.
|
|
export BAMBOO_HAMMERHEAD="${url%/}"
|
|
export BAMBOO_TOKEN="${token}"
|
|
|
|
# The SSH server is opt-in. The keys listed in the configuration are the only ones that may sign in.
|
|
if bashio::config.true 'ssh'; then
|
|
keys_file=/data/authorized_keys
|
|
jq -r '.ssh_keys[]? | select(. != null and . != "")' /data/options.json > "${keys_file}"
|
|
if [ ! -s "${keys_file}" ]; then
|
|
bashio::log.fatal "SSH is turned on but no public keys are listed. Add at least one in the SSH public keys setting, then start the add-on again."
|
|
bashio::exit.nok
|
|
fi
|
|
export BAMBOO_SSH=1
|
|
export BAMBOO_SSH_KEYS="${keys_file}"
|
|
export SHELL=/bin/bash
|
|
fi
|
|
|
|
# Service discovery is opt-in: Bamboo reports what it finds as suggested targets in Hammerhead.
|
|
if bashio::config.true 'discover'; then
|
|
export BAMBOO_DISCOVER=1
|
|
fi
|
|
subnets="$(bashio::config 'discover_subnets')"
|
|
if [ -n "${subnets}" ]; then
|
|
export BAMBOO_DISCOVER_SUBNETS="${subnets}"
|
|
fi
|
|
ports="$(bashio::config 'discover_ports')"
|
|
if [ -n "${ports}" ]; then
|
|
export BAMBOO_DISCOVER_PORTS="${ports}"
|
|
fi
|
|
rate="$(bashio::config 'discover_rate')"
|
|
if [ -n "${rate}" ]; then
|
|
export BAMBOO_DISCOVER_RATE="${rate}"
|
|
fi
|
|
|
|
bashio::log.info "Starting $(bamboo -version), connecting to ${BAMBOO_HAMMERHEAD}"
|
|
# /data survives restarts and updates; it holds this site's WireGuard key.
|
|
exec bamboo -data /data
|