#!/usr/bin/with-contenv bash

cd /app/synclounge || exit

export \
	WEB_ACCESSURL="${EXTERNAL_URL:-$(curl icanhazip.com)}/slweb" \
	SERVERS=$(cat /defaults/servers.json)

if [ "${AUTOJOIN_ENABLED}" == "true" ]; then
	export AUTOJOIN_SERVERURL="${EXTERNAL_URL:-$(curl icanhazip.com)}/slserver"
fi
if [ -n "${AUTH_LIST}" ]; then
	export AUTHENTICATION=$(cat /defaults/authentication.json)
fi

exec \
	s6-setuidgid abc node webapp.js
