1
1
sovereign-stack/deployment/project_env.sh

34 lines
849 B
Bash
Raw Normal View History

2023-03-05 16:45:27 +00:00
#!/bin/bash
set -eu
cd "$(dirname "$0")"
2023-03-14 15:37:33 +00:00
2023-03-13 17:40:47 +00:00
PROJECT_DEFINITION_PATH="$PROJECT_PATH/project.conf"
2023-03-05 16:45:27 +00:00
if [ ! -f "$PROJECT_DEFINITION_PATH" ]; then
2023-03-13 17:40:47 +00:00
echo "ERROR: 'project.conf' not found $PROJECT_DEFINITION_PATH not found."
2023-03-05 16:45:27 +00:00
exit 1
fi
source "$PROJECT_DEFINITION_PATH"
2023-03-13 17:54:29 +00:00
export PRIMARY_SITE_DEFINITION_PATH="$SITES_PATH/$PRIMARY_DOMAIN/site.conf"
2023-03-11 16:12:19 +00:00
if [ ! -f "$PRIMARY_SITE_DEFINITION_PATH" ]; then
echo "ERROR: the site definition does not exist."
exit 1
fi
2023-03-05 16:45:27 +00:00
if [ -z "$PRIMARY_DOMAIN" ]; then
2023-03-11 03:40:50 +00:00
echo "ERROR: The PRIMARY_DOMAIN is not specified. Check your remote definition at '$PRIMARY_SITE_DEFINITION_PATH'."
2023-03-05 16:45:27 +00:00
exit 1
fi
2023-03-11 16:12:19 +00:00
source "$PRIMARY_SITE_DEFINITION_PATH"
if ! lxc info | grep "project:" | grep -q "$PROJECT_NAME"; then
if lxc project list | grep -q "$PROJECT_NAME"; then
lxc project switch "$PROJECT_NAME"
fi
fi