Add user_target_project to deploy.sh

This commit is contained in:
Derek Smith 2023-03-14 11:35:28 -04:00
parent 2411067cd1
commit 72c4df897a
Signed by: farscapian
GPG Key ID: B443E530A14E1C90

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -ex set -e
cd "$(dirname "$0")" cd "$(dirname "$0")"
LATEST_GIT_COMMIT="$(cat ./.git/refs/heads/main)" LATEST_GIT_COMMIT="$(cat ./.git/refs/heads/main)"
@ -56,6 +56,7 @@ REMOTE_NAME="$(lxc remote get-default)"
STOP_SERVICES=false STOP_SERVICES=false
USER_SAYS_YES=false USER_SAYS_YES=false
RESTART_FRONT_END=true RESTART_FRONT_END=true
USER_TARGET_PROJECT=
# grab any modifications from the command line. # grab any modifications from the command line.
for i in "$@"; do for i in "$@"; do
@ -91,6 +92,10 @@ for i in "$@"; do
BACKUP_BTCPAY_ARCHIVE_PATH="${i#*=}" BACKUP_BTCPAY_ARCHIVE_PATH="${i#*=}"
shift shift
;; ;;
--project=*)
USER_TARGET_PROJECT="${i#*=}"
shift
;;
--update-btcpay) --update-btcpay)
UPDATE_BTCPAY=true UPDATE_BTCPAY=true
shift shift
@ -188,7 +193,7 @@ function stub_site_definition {
# stub out a site.conf with new passwords. # stub out a site.conf with new passwords.
cat >"$SITE_DEFINITION_PATH" <<EOL cat >"$SITE_DEFINITION_PATH" <<EOL
#!/bin/bash # https://www.sovereign-stack.org/ss-deploy/#siteconf
export DOMAIN_NAME="${DOMAIN_NAME}" export DOMAIN_NAME="${DOMAIN_NAME}"
#export BTCPAY_ALT_NAMES="tip,store,pay,send" #export BTCPAY_ALT_NAMES="tip,store,pay,send"
@ -227,6 +232,18 @@ for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN" PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME" 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 [ "$PROJECT_NAME" != "$USER_TARGET_PROJECT" ]; then
echo "INFO: Skipping project '$PROJECT_NAME' since the system owner has used the --project switch."
continue
fi
fi
export PROJECT_NAME="$PROJECT_NAME"
export PROJECT_PATH="$PROJECT_PATH"
mkdir -p "$PROJECT_PATH" "$REMOTE_PATH/projects" mkdir -p "$PROJECT_PATH" "$REMOTE_PATH/projects"
# create a symlink from ./remotepath/projects/project # create a symlink from ./remotepath/projects/project
@ -240,7 +257,10 @@ if [ ! -f "$PROJECT_DEFINITION_PATH" ]; then
# stub out a project.conf # stub out a project.conf
cat >"$PROJECT_DEFINITION_PATH" <<EOL cat >"$PROJECT_DEFINITION_PATH" <<EOL
#!/bin/bash # see https://www.sovereign-stack.org/ss-deploy/#projectconf for more info.
PRIMARY_DOMAIN="domain0.tld"
# OTHER_SITES_LIST="domain1.tld,domain2.tld,domain3.tld"
WWW_SERVER_MAC_ADDRESS= WWW_SERVER_MAC_ADDRESS=
# WWW_SERVER_CPU_COUNT="6" # WWW_SERVER_CPU_COUNT="6"
@ -434,4 +454,5 @@ fi
ssh ubuntu@"$BTCPAY_FQDN" "echo $LATEST_GIT_COMMIT > /home/ubuntu/.ss-githead" ssh ubuntu@"$BTCPAY_FQDN" "echo $LATEST_GIT_COMMIT > /home/ubuntu/.ss-githead"
fi fi
done done