forked from ss/sovereign-stack
Add --project scope.
This commit is contained in:
parent
e2bfd5d090
commit
5da08eab26
@ -101,4 +101,4 @@ export PRIMARY_DOMAIN=
|
|||||||
# this is the git commit of the project/ sub git repo.
|
# this is the git commit of the project/ sub git repo.
|
||||||
# used in the migration script to switch into past for backup
|
# used in the migration script to switch into past for backup
|
||||||
# then back to present (TARGET_PROJECT_GIT_COMMIT) for restore.
|
# then back to present (TARGET_PROJECT_GIT_COMMIT) for restore.
|
||||||
export TARGET_PROJECT_GIT_COMMIT=2411067cd168aaa475f56179db26301b35194ce2
|
export TARGET_PROJECT_GIT_COMMIT=72c4df897af0a054ad938a5badf94cd13ef45ec5
|
||||||
|
@ -22,6 +22,23 @@ if [ "$RESPONSE" != "y" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
USER_TARGET_PROJECT=
|
||||||
|
|
||||||
|
# grab any modifications from the command line.
|
||||||
|
for i in "$@"; do
|
||||||
|
case $i in
|
||||||
|
--project=*)
|
||||||
|
USER_TARGET_PROJECT="${i#*=}"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
echo "Unexpected option: $1"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
. ../defaults.sh
|
. ../defaults.sh
|
||||||
|
|
||||||
. ./remote_env.sh
|
. ./remote_env.sh
|
||||||
@ -30,8 +47,25 @@ for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
|
|||||||
NO_PARENS="${PROJECT_CHAIN:1:${#PROJECT_CHAIN}-2}"
|
NO_PARENS="${PROJECT_CHAIN:1:${#PROJECT_CHAIN}-2}"
|
||||||
PROJECT_PREFIX=$(echo "$NO_PARENS" | cut -d'|' -f1)
|
PROJECT_PREFIX=$(echo "$NO_PARENS" | cut -d'|' -f1)
|
||||||
BITCOIN_CHAIN=$(echo "$NO_PARENS" | cut -d'|' -f2)
|
BITCOIN_CHAIN=$(echo "$NO_PARENS" | cut -d'|' -f2)
|
||||||
export PROJECT_PREFIX="$PROJECT_PREFIX"
|
|
||||||
export BITCOIN_CHAIN="$BITCOIN_CHAIN"
|
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
|
||||||
|
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME"
|
||||||
|
|
||||||
|
# if the user sets USER_TARGET_PROJECT, let's ensure the project exists.
|
||||||
|
if [ -n "$USER_TARGET_PROJECT" ]; then
|
||||||
|
if ! lxc project list | grep -q "$USER_TARGET_PROJECT"; then
|
||||||
|
echo "ERROR: the project does not exist! Nothing to destroy."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PROJECT_NAME" != "$USER_TARGET_PROJECT" ]; then
|
||||||
|
echo "INFO: Skipping project '$PROJECT_NAME' since the system owner has used the --project switch."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PROJECT_NAME="$PROJECT_NAME"
|
||||||
|
export PROJECT_PATH="$PROJECT_PATH"
|
||||||
|
|
||||||
. ./project_env.sh
|
. ./project_env.sh
|
||||||
|
|
||||||
|
@ -3,12 +3,7 @@
|
|||||||
set -eu
|
set -eu
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
# source project defition.
|
|
||||||
# Now let's load the project definition.
|
|
||||||
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
|
|
||||||
export PROJECT_NAME="$PROJECT_NAME"
|
|
||||||
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME"
|
|
||||||
export PROJECT_PATH="$PROJECT_PATH"
|
|
||||||
PROJECT_DEFINITION_PATH="$PROJECT_PATH/project.conf"
|
PROJECT_DEFINITION_PATH="$PROJECT_PATH/project.conf"
|
||||||
|
|
||||||
if [ ! -f "$PROJECT_DEFINITION_PATH" ]; then
|
if [ ! -f "$PROJECT_DEFINITION_PATH" ]; then
|
||||||
|
@ -23,6 +23,22 @@ for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
|
|||||||
export PROJECT_PREFIX="$PROJECT_PREFIX"
|
export PROJECT_PREFIX="$PROJECT_PREFIX"
|
||||||
export BITCOIN_CHAIN="$BITCOIN_CHAIN"
|
export BITCOIN_CHAIN="$BITCOIN_CHAIN"
|
||||||
|
|
||||||
|
# if the user sets USER_TARGET_PROJECT, let's ensure the project exists.
|
||||||
|
if [ -n "$USER_TARGET_PROJECT" ]; then
|
||||||
|
if ! lxc project list | grep -q "$USER_TARGET_PROJECT"; then
|
||||||
|
echo "ERROR: the project does not exist! Nothing to update."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PROJECT_NAME" != "$USER_TARGET_PROJECT" ]; then
|
||||||
|
echo "INFO: Skipping project '$PROJECT_NAME' since the system owner has used the --project switch."
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
export PROJECT_NAME="$PROJECT_NAME"
|
||||||
|
export PROJECT_PATH="$PROJECT_PATH"
|
||||||
|
|
||||||
. ./project_env.sh
|
. ./project_env.sh
|
||||||
|
|
||||||
# Check to see if any of the VMs actually don't exist.
|
# Check to see if any of the VMs actually don't exist.
|
||||||
|
Loading…
Reference in New Issue
Block a user