From fd0c615dac0236730deb4bc55c95aa8188a3f602 Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Thu, 29 Sep 2022 13:14:51 -0400 Subject: [PATCH] Trying to commit more often during Hurricane Ian. --- deployment/www/backup_path.sh | 10 ++++- deployment/www/go.sh | 4 -- deployment/www/stop_docker_stacks.sh | 11 +++--- deployment/www/stub/ghost_yml.sh | 12 +++--- deployment/www/stub/gitea_yml.sh | 56 ++++++++++++---------------- deployment/www/stub/nginx_config.sh | 15 ++++---- deployment/www/stub/nginx_yml.sh | 16 ++++++++ domain_env.sh | 2 +- reset_env.sh | 2 +- 9 files changed, 69 insertions(+), 59 deletions(-) mode change 100644 => 100755 deployment/www/stub/gitea_yml.sh diff --git a/deployment/www/backup_path.sh b/deployment/www/backup_path.sh index 33c8d5f..4e07848 100755 --- a/deployment/www/backup_path.sh +++ b/deployment/www/backup_path.sh @@ -22,7 +22,15 @@ REMOTE_BACKUP_LOCATION="$REMOTE_BACKUP_PATH/$1/$DOMAIN_NAME" # step 1: run duplicity on the remote system to backup all files to the remote system. # --allow-source-mismatch -ssh "$PRIMARY_WWW_FQDN" sudo PASSPHRASE="$DUPLICITY_BACKUP_PASSPHRASE" duplicity "$REMOTE_HOME/$1/$DOMAIN_NAME" "file://$REMOTE_BACKUP_LOCATION" +REMOTE_SOURCE_BACKUP_PATH="$REMOTE_HOME/$1/$DOMAIN_NAME" + +# if the source files to backup don't exist on the remote host, we return. +if ! ssh "$PRIMARY_WWW_FQDN" "[ -d $REMOTE_SOURCE_BACKUP_PATH"; then + echo "INFO: The path to backup does not exist. There's nothing to backup! That's ok, execution will continue." + exit 0 +fi + +ssh "$PRIMARY_WWW_FQDN" sudo PASSPHRASE="$DUPLICITY_BACKUP_PASSPHRASE" duplicity "$REMOTE_SOURCE_BACKUP_PATH" "file://$REMOTE_BACKUP_LOCATION" ssh "$PRIMARY_WWW_FQDN" sudo chown -R ubuntu:ubuntu "$REMOTE_BACKUP_LOCATION" diff --git a/deployment/www/go.sh b/deployment/www/go.sh index 335a8f1..6eaba49 100755 --- a/deployment/www/go.sh +++ b/deployment/www/go.sh @@ -91,9 +91,6 @@ for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do ssh "$PRIMARY_WWW_FQDN" "mkdir -p $REMOTE_NEXTCLOUD_PATH/html" fi - if [ "$DEPLOY_GITEA" = true ]; then - ssh "$FQDN" "mkdir -p $REMOTE_GITEA_PATH/data $REMOTE_GITEA_PATH/db" - fi done @@ -133,7 +130,6 @@ fi bash -c ./stub/nginx_yml.sh bash -c ./stub/ghost_yml.sh - bash -c ./stub/gitea_yml.sh diff --git a/deployment/www/stop_docker_stacks.sh b/deployment/www/stop_docker_stacks.sh index 3fa88a5..a11caad 100755 --- a/deployment/www/stop_docker_stacks.sh +++ b/deployment/www/stop_docker_stacks.sh @@ -14,20 +14,19 @@ for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do source ../../domain_env.sh ### Stop all services. - for APP in ghost; do + for APP in ghost gitea; do + # backup each language for each app. for LANGUAGE_CODE in ${SITE_LANGUAGE_CODES//,/ }; do - STACK_NAME="$DOCKER_STACK_SUFFIX-$LANGUAGE_CODE" + STACK_NAME="$DOCKER_STACK_SUFFIX-$APP-$LANGUAGE_CODE" + if docker stack list --format "{{.Name}}" | grep -q "$STACK_NAME"; then docker stack rm "$STACK_NAME" sleep 2 fi - if [ "$BACKUP_GHOST" = true ]; then - ./backup_path.sh "$APP" - fi + ./backup_path.sh "$APP" done done - done diff --git a/deployment/www/stub/ghost_yml.sh b/deployment/www/stub/ghost_yml.sh index 40648b4..779f1e5 100755 --- a/deployment/www/stub/ghost_yml.sh +++ b/deployment/www/stub/ghost_yml.sh @@ -1,16 +1,16 @@ #!/bin/bash +set -exu +cd "$(dirname "$0")" -domain_number=0 for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do export DOMAIN_NAME="$DOMAIN_NAME" export SITE_PATH="$SITES_PATH/$DOMAIN_NAME" - # source the site path so we know what features it has. - source ../../reset_env.sh + source ../../../reset_env.sh source "$SITE_PATH/site_definition" - source ../../domain_env.sh + source ../../../domain_env.sh # for each language specified in the site_definition, we spawn a separate ghost container # at https://www.domain.com/$LANGUAGE_CODE @@ -95,12 +95,10 @@ EOL EOL fi - docker stack deploy -c "$DOCKER_YAML_PATH" "$DOCKER_STACK_SUFFIX-$LANGUAGE_CODE" + docker stack deploy -c "$DOCKER_YAML_PATH" "$DOCKER_STACK_SUFFIX-ghost-$LANGUAGE_CODE" sleep 2 - domain_number=$((domain_number+1)) - done # language code done # domain list \ No newline at end of file diff --git a/deployment/www/stub/gitea_yml.sh b/deployment/www/stub/gitea_yml.sh old mode 100644 new mode 100755 index 4df3215..25db6c6 --- a/deployment/www/stub/gitea_yml.sh +++ b/deployment/www/stub/gitea_yml.sh @@ -3,32 +3,33 @@ set -exu cd "$(dirname "$0")" -domain_number=0 for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do export DOMAIN_NAME="$DOMAIN_NAME" export SITE_PATH="$SITES_PATH/$DOMAIN_NAME" # source the site path so we know what features it has. - source ../../reset_env.sh + source ../../../reset_env.sh source "$SITE_PATH/site_definition" - source ../../domain_env.sh + source ../../../domain_env.sh - if [ "$DEPLOY_GITEA" = true ]; then + GITEA_PATH="$REMOTE_GITEA_PATH/$DOMAIN_NAME/${LANGUAGE_CODE}" + + ssh "$PRIMARY_WWW_FQDN" mkdir -p "$GITEA_PATH" STACK_NAME="$DOCKER_STACK_SUFFIX-$LANGUAGE_CODE" - # ensure directories on remote host exist so we can mount them into the containers. - ssh "$PRIMARY_WWW_FQDN" mkdir -p "$REMOTE_HOME/gitea/$DOMAIN_NAME/en/gitea" - export STACK_TAG="gitea-$STACK_NAME" export DB_STACK_TAG="giteadb-$STACK_NAME" # todo append domain number or port number. WEBSTACK_PATH="$SITE_PATH/webstack" - mkdir -p "$WEBSTACK_PATH" + mkdir -p "$WEBSTACK_PATH" "$WEBSTACK_PATH/data" "$WEBSTACK_PATH/db" export DOCKER_YAML_PATH="$WEBSTACK_PATH/gitea-en.yml" + NET_NAME="giteanet-$DOCKER_STACK_SUFFIX" + DBNET_NAME="giteadbnet-$DOCKER_STACK_SUFFIX" + # here's the NGINX config. We support ghost and nextcloud. echo "" > "$DOCKER_YAML_PATH" cat >>"$DOCKER_YAML_PATH" <>"$DOCKER_YAML_PATH" <>"$DOCKER_YAML_PATH" <>"$DOCKER_YAML_PATH" <>"$NGINX_CONF_PATH" <>"$NGINX_CONF_PATH" <>"$NGINX_CONF_PATH" <> "$DOCKER_YAML_PATH" <> "$DOCKER_YAML_PATH" <> "$DOCKER_YAML_PATH" < /dev/null && pwd )" source "$SCRIPT_DIR/defaults.sh"