This commit is contained in:
Your Name 2025-05-03 19:56:12 +12:00
parent 2fbe5307da
commit ec779e51c2
5 changed files with 29 additions and 18 deletions

View File

@ -8,7 +8,7 @@
source "$(dirname "$0")/_common.sh" source "$(dirname "$0")/_common.sh"
# Required environment variables # Required environment variables
check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "VOLUME_NAME" "HOST_NAME" "HOST_PORT" check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "VOLUME_NAME" "HOST_NAME"
# Create volume if it doesn't exist # Create volume if it doesn't exist
if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then
@ -32,4 +32,12 @@ _remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER
bash ./start.sh || die "Failed to start container ${CONTAINER_NAME}" bash ./start.sh || die "Failed to start container ${CONTAINER_NAME}"
echo "Installation of ${CONTAINER_NAME} complete" echo "Installation of ${CONTAINER_NAME} complete"
echo "You can access the service at http://${HOST_NAME}:${HOST_PORT}"
# determine port.
command -v jq &> /dev/null || die "jq could not be found, please install it"
[ -f "${CONFIG_PATH}/sos_config.json" ] || die "sos_config.json does not exist"
PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json")
echo "You can access the service at http://${HOST_NAME}:${PORT}"

View File

@ -8,19 +8,12 @@
source "$(dirname "$0")/_common.sh" source "$(dirname "$0")/_common.sh"
# Required environment variables # Required environment variables
# check_required_env_vars "HOST_PORT" check_required_env_vars "CONFIG_PATH"
# check if jq is installed # determine port.
if ! command -v jq &> /dev/null; then command -v jq &> /dev/null || die "jq could not be found, please install it"
die "jq could not be found, please install it" [ -f "${CONFIG_PATH}/sos_config.json" ] || die "sos_config.json does not exist"
fi
# check if sos_config.json exists
if [ ! -f "${CONFIG_PATH}/sos_config.json" ]; then
die "sos_config.json does not exist"
fi
# extract port from sos_config.json
PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json") PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json")
echo $PORT echo $PORT

View File

@ -43,4 +43,4 @@ docker run --rm \
# reinstall service - ensure everything is latest. # reinstall service - ensure everything is latest.
bash ./install.sh || die "Failed to reinstall service after restore" bash ./install.sh || die "Failed to reinstall service after restore"
echo "Restore complete! Service is running again on port $HOST_PORT with restored content." echo "Restore complete! Service is running again."

View File

@ -6,18 +6,23 @@
# It is called with the path to the server specific env file as an argument. # It is called with the path to the server specific env file as an argument.
source "$(dirname "$0")/_common.sh" source "$(dirname "$0")/_common.sh"
check_required_env_vars "CONTAINER_NAME" "HOST_PORT" "VOLUME_NAME" "WRITE_TOKENS" "CONFIG_PATH" check_required_env_vars "CONTAINER_NAME" "VOLUME_NAME" "CONFIG_PATH"
# check volume exists. # check volume exists.
if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then if ! docker volume inspect "${VOLUME_NAME}" &>/dev/null; then
die "Docker volume ${VOLUME_NAME} does not exist" die "Docker volume ${VOLUME_NAME} does not exist"
fi fi
# determine port.
command -v jq &> /dev/null || die "jq could not be found, please install it"
[ -f "${CONFIG_PATH}/sos_config.json" ] || die "sos_config.json does not exist"
PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json")
DOCKER_RUN_CMD="docker run -d \ DOCKER_RUN_CMD="docker run -d \
--restart unless-stopped \ --restart unless-stopped \
--name ${CONTAINER_NAME} \ --name ${CONTAINER_NAME} \
-p ${HOST_PORT}:80 \ -p ${PORT}:${PORT} \
-v ${VOLUME_NAME}:/data/storage \ -v ${VOLUME_NAME}:/data/storage \
-v ${CONFIG_PATH}/sos_config.json:/data/sos_config.json:ro \ -v ${CONFIG_PATH}/sos_config.json:/data/sos_config.json:ro \
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}" ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"

View File

@ -13,8 +13,13 @@ check_required_env_vars "CONTAINER_NAME"
# check if the service is running # check if the service is running
_is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME." _is_container_running $CONTAINER_NAME || die "Service is not running - did not find container $CONTAINER_NAME."
# determine port.
command -v jq &> /dev/null || die "jq could not be found, please install it"
[ -f "${CONFIG_PATH}/sos_config.json" ] || die "sos_config.json does not exist"
PORT=$(jq -r '.port' "${CONFIG_PATH}/sos_config.json")
# check if the service is healthy # check if the service is healthy
curl -s -X GET http://localhost:${HOST_PORT}/status | jq -e '.result == "success"' \ curl -s -X GET http://localhost:${PORT}/status | jq -e '.result == "success"' \
|| die "Service is not healthy - did not get OK response from /status endpoint." || die "Service is not healthy - did not get OK response from /status endpoint."
echo "Service is healthy" echo "Service is healthy"