1
1

Trying to commit more often during Hurricane Ian.

This commit is contained in:
Derek Smith 2022-09-29 13:14:51 -04:00
parent f671fce58f
commit fd0c615dac
Signed by: farscapian
GPG Key ID: 8F1CD799CCA516CC
9 changed files with 69 additions and 59 deletions

View File

@ -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. # step 1: run duplicity on the remote system to backup all files to the remote system.
# --allow-source-mismatch # --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" ssh "$PRIMARY_WWW_FQDN" sudo chown -R ubuntu:ubuntu "$REMOTE_BACKUP_LOCATION"

View File

@ -91,9 +91,6 @@ for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
ssh "$PRIMARY_WWW_FQDN" "mkdir -p $REMOTE_NEXTCLOUD_PATH/html" ssh "$PRIMARY_WWW_FQDN" "mkdir -p $REMOTE_NEXTCLOUD_PATH/html"
fi fi
if [ "$DEPLOY_GITEA" = true ]; then
ssh "$FQDN" "mkdir -p $REMOTE_GITEA_PATH/data $REMOTE_GITEA_PATH/db"
fi
done done
@ -133,7 +130,6 @@ fi
bash -c ./stub/nginx_yml.sh bash -c ./stub/nginx_yml.sh
bash -c ./stub/ghost_yml.sh bash -c ./stub/ghost_yml.sh
bash -c ./stub/gitea_yml.sh bash -c ./stub/gitea_yml.sh

View File

@ -14,20 +14,19 @@ for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
source ../../domain_env.sh source ../../domain_env.sh
### Stop all services. ### 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 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 if docker stack list --format "{{.Name}}" | grep -q "$STACK_NAME"; then
docker stack rm "$STACK_NAME" docker stack rm "$STACK_NAME"
sleep 2 sleep 2
fi fi
if [ "$BACKUP_GHOST" = true ]; then
./backup_path.sh "$APP" ./backup_path.sh "$APP"
fi
done done
done done
done done

View File

@ -1,16 +1,16 @@
#!/bin/bash #!/bin/bash
set -exu
cd "$(dirname "$0")"
domain_number=0
for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
export DOMAIN_NAME="$DOMAIN_NAME" export DOMAIN_NAME="$DOMAIN_NAME"
export SITE_PATH="$SITES_PATH/$DOMAIN_NAME" export SITE_PATH="$SITES_PATH/$DOMAIN_NAME"
# source the site path so we know what features it has. # 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 "$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 # for each language specified in the site_definition, we spawn a separate ghost container
# at https://www.domain.com/$LANGUAGE_CODE # at https://www.domain.com/$LANGUAGE_CODE
@ -95,12 +95,10 @@ EOL
EOL EOL
fi 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 sleep 2
domain_number=$((domain_number+1))
done # language code done # language code
done # domain list done # domain list

54
deployment/www/stub/gitea_yml.sh Normal file → Executable file
View File

@ -3,32 +3,33 @@
set -exu set -exu
cd "$(dirname "$0")" cd "$(dirname "$0")"
domain_number=0
for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
export DOMAIN_NAME="$DOMAIN_NAME" export DOMAIN_NAME="$DOMAIN_NAME"
export SITE_PATH="$SITES_PATH/$DOMAIN_NAME" export SITE_PATH="$SITES_PATH/$DOMAIN_NAME"
# source the site path so we know what features it has. # 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 "$SITE_PATH/site_definition"
source ../../domain_env.sh source ../../../domain_env.sh
if [ "$DEPLOY_GITEA" = true ]; then 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" 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 STACK_TAG="gitea-$STACK_NAME"
export DB_STACK_TAG="giteadb-$STACK_NAME" export DB_STACK_TAG="giteadb-$STACK_NAME"
# todo append domain number or port number. # todo append domain number or port number.
WEBSTACK_PATH="$SITE_PATH/webstack" 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" 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. # here's the NGINX config. We support ghost and nextcloud.
echo "" > "$DOCKER_YAML_PATH" echo "" > "$DOCKER_YAML_PATH"
cat >>"$DOCKER_YAML_PATH" <<EOL cat >>"$DOCKER_YAML_PATH" <<EOL
@ -38,7 +39,7 @@ services:
${STACK_TAG}: ${STACK_TAG}:
image: ${GITEA_IMAGE} image: ${GITEA_IMAGE}
volumes: volumes:
- ${REMOTE_GITEA_PATH}/data:/data - ${GITEA_PATH}/data:/data
- /etc/timezone:/etc/timezone:ro - /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro - /etc/localtime:/etc/localtime:ro
environment: environment:
@ -51,8 +52,8 @@ services:
- GITEA__database__USER=gitea - GITEA__database__USER=gitea
- GITEA__PASSWD=\${GITEA_MYSQL_PASSWORD} - GITEA__PASSWD=\${GITEA_MYSQL_PASSWORD}
networks: networks:
- giteanet-${DOCKER_STACK_SUFFIX} - ${NET_NAME}
- giteadbnet-${DOCKER_STACK_SUFFIX} - ${DBNET_NAME}
deploy: deploy:
restart_policy: restart_policy:
condition: on-failure condition: on-failure
@ -60,9 +61,9 @@ services:
${DB_STACK_TAG}: ${DB_STACK_TAG}:
image: ${GITEA_DB_IMAGE} image: ${GITEA_DB_IMAGE}
networks: networks:
- giteadbnet-${DOCKER_STACK_SUFFIX} - ${DBNET_NAME}
volumes: volumes:
- ${REMOTE_GITEA_PATH}/db:/var/lib/mysql - ${GITEA_PATH}/db:/var/lib/mysql
environment: environment:
- MYSQL_ROOT_PASSWORD=\${GITEA_MYSQL_ROOT_PASSWORD} - MYSQL_ROOT_PASSWORD=\${GITEA_MYSQL_ROOT_PASSWORD}
- MYSQL_PASSWORD=\${GITEA_MYSQL_PASSWORD} - MYSQL_PASSWORD=\${GITEA_MYSQL_PASSWORD}
@ -71,30 +72,21 @@ services:
deploy: deploy:
restart_policy: restart_policy:
condition: on-failure condition: on-failure
EOL
fi
# if [ "$DEPLOY_GITEA" = true ]; then
# cat >>"$DOCKER_YAML_PATH" <<EOL
# gitea-net:
# giteadb-net:
# EOL
# fi
cat >>"$DOCKER_YAML_PATH" <<EOL
networks: networks:
EOL EOL
docker stack deploy -c "$DOCKER_YAML_PATH" "$DOCKER_STACK_SUFFIX-$LANGUAGE_CODE" cat >>"$DOCKER_YAML_PATH" <<EOL
${NET_NAME}:
name: "reverse-proxy_${NET_NAME}-${LANGUAGE_CODE}"
external: true
${DBNET_NAME}:
EOL
docker stack deploy -c "$DOCKER_YAML_PATH" "$DOCKER_STACK_SUFFIX-gitea-$LANGUAGE_CODE"
sleep 1 sleep 1
done
fi fi
domain_number=$((domain_number+1))
done done

View File

@ -362,7 +362,13 @@ EOL
EOL EOL
# this is the closing server block for the ghost HTTPS segment
cat >>"$NGINX_CONF_PATH" <<EOL
}
EOL
# this piece is for GITEA.
cat >>"$NGINX_CONF_PATH" <<EOL cat >>"$NGINX_CONF_PATH" <<EOL
# TLS listener for ${GITEA_FQDN} # TLS listener for ${GITEA_FQDN}
server { server {
@ -382,6 +388,7 @@ EOL
proxy_pass http://gitea:3000; proxy_pass http://gitea:3000;
} }
}
EOL EOL
@ -398,12 +405,6 @@ EOL
# proxy_pass http://ghost-${DOCKER_STACK_SUFFIX}-${SITE_LANGUAGE_CODES}::2368\$og_prefix\$request_uri; # proxy_pass http://ghost-${DOCKER_STACK_SUFFIX}-${SITE_LANGUAGE_CODES}::2368\$og_prefix\$request_uri;
# } # }
# this is the closing server block for the ghost HTTPS segment
cat >>"$NGINX_CONF_PATH" <<EOL
}
EOL
iteration=$((iteration+1)) iteration=$((iteration+1))
done done

View File

@ -38,6 +38,12 @@ EOL
done done
done done
if [ "$DEPLOY_GITEA" = true ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
- giteanet-$DOCKER_STACK_SUFFIX-$LANGUAGE_CODE
EOL
fi
cat >> "$DOCKER_YAML_PATH" <<EOL cat >> "$DOCKER_YAML_PATH" <<EOL
volumes: volumes:
- ${REMOTE_HOME}/letsencrypt:/etc/letsencrypt:ro - ${REMOTE_HOME}/letsencrypt:/etc/letsencrypt:ro
@ -82,6 +88,16 @@ EOL
EOL EOL
done done
if [ "$DEPLOY_GITEA" = true ]; then
cat >> "$DOCKER_YAML_PATH" <<EOL
giteanet-$DOCKER_STACK_SUFFIX-$LANGUAGE_CODE:
attachable: true
EOL
fi
done done
docker stack deploy -c "$DOCKER_YAML_PATH" "reverse-proxy" docker stack deploy -c "$DOCKER_YAML_PATH" "reverse-proxy"

View File

@ -18,7 +18,7 @@ export NEXTCLOUD_MYSQL_ROOT_PASSWORD=
export GITEA_MYSQL_PASSWORD= export GITEA_MYSQL_PASSWORD=
export GITEA_MYSQL_ROOT_PASSWORD= export GITEA_MYSQL_ROOT_PASSWORD=
export SITE_LANGUAGE_CODES="en" export SITE_LANGUAGE_CODES="en"
export LANGUAGE_CODE= export LANGUAGE_CODE="en"
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$SCRIPT_DIR/defaults.sh" source "$SCRIPT_DIR/defaults.sh"