project/www/stop_docker_stacks.sh

52 lines
1.6 KiB
Bash
Raw Permalink Normal View History

2023-03-06 19:30:56 +00:00
#!/bin/bash
2023-12-15 00:53:26 +00:00
set -exu
2023-03-06 19:30:56 +00:00
cd "$(dirname "$0")"
2023-08-11 14:00:21 +00:00
# this scripts brings down the docker stacks on www
2023-03-06 19:30:56 +00:00
# bring down ghost instances.
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.
2023-04-12 13:56:59 +00:00
source ../../deployment_defaults.sh
2023-04-07 14:20:15 +00:00
source ../project_defaults.sh
2023-03-13 18:43:23 +00:00
source "$SITE_PATH/site.conf"
2023-03-06 19:30:56 +00:00
source ../domain_env.sh
### Stop all services.
for APP in ghost nextcloud gitea nostr; do
# backup each language for each app.
for LANGUAGE_CODE in ${SITE_LANGUAGE_CODES//,/ }; do
STACK_NAME="$DOMAIN_IDENTIFIER-$APP-$LANGUAGE_CODE"
if docker stack list --format "{{.Name}}" | grep -q "$STACK_NAME"; then
2023-03-20 16:58:33 +00:00
docker stack rm "$STACK_NAME"
2023-03-06 19:30:56 +00:00
sleep 2
fi
# these variable are used by both backup/restore scripts.
export APP="$APP"
2023-04-04 14:52:09 +00:00
export REMOTE_BACKUP_PATH="$REMOTE_BACKUP_PATH/www/$APP/$DOMAIN_IDENTIFIER-$LANGUAGE_CODE"
2023-04-02 13:28:42 +00:00
export REMOTE_SOURCE_BACKUP_PATH="$REMOTE_DATA_PATH/$APP/$DOMAIN_NAME"
2023-03-06 19:30:56 +00:00
# ensure our local backup path exists so we can pull down the duplicity archive to the management machine.
export LOCAL_BACKUP_PATH="$SITE_PATH/backups/www/$APP"
# ensure our local backup path exists.
if [ ! -d "$LOCAL_BACKUP_PATH" ]; then
mkdir -p "$LOCAL_BACKUP_PATH"
fi
done
done
done
2023-04-04 15:08:22 +00:00
# remove the nginx stack
if docker stack list --format "{{.Name}}" | grep -q reverse-proxy; then
docker stack rm reverse-proxy
2023-04-06 19:08:34 +00:00
sleep 10
2023-04-04 15:08:22 +00:00
fi