forked from ss/sovereign-stack
Refactor
This commit is contained in:
parent
b23d60a6ad
commit
fac6ab0ecf
@ -85,15 +85,66 @@ done
|
|||||||
./stop_docker_stacks.sh
|
./stop_docker_stacks.sh
|
||||||
|
|
||||||
|
|
||||||
|
# TODO check if there are any other stacks that are left running (other than reverse proxy)
|
||||||
|
# if so, this may mean the user has disabled one or more domains and that existing sites/services
|
||||||
|
# are still running. We should prompt the user of this and quit. They have to go manually docker stack remove these.
|
||||||
|
if [[ $(docker stack ls | wc -l) -gt 2 ]]; then
|
||||||
|
echo "WARNING! You still have stacks running. If you have modified the SITES list, you may need to go remove the docker stacks runnong the remote machine."
|
||||||
|
echo "exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ok, the backend stacks are stopped.
|
||||||
|
if [ "$RESTART_FRONT_END" = true ]; then
|
||||||
|
# remove the nginx stack
|
||||||
|
if docker stack list --format "{{.Name}}" | grep -q reverse-proxy; then
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
docker stack rm reverse-proxy
|
||||||
|
|
||||||
|
# wait for all docker containers to stop.
|
||||||
|
# TODO see if there's a way to check for this.
|
||||||
|
sleep 15
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
# generate the certs and grab a backup
|
||||||
|
if [ "$RUN_CERT_RENEWAL" = true ]; then
|
||||||
|
./generate_certs.sh
|
||||||
|
fi
|
||||||
|
|
||||||
|
# let's backup all our letsencrypt certs
|
||||||
|
export APP="letsencrypt"
|
||||||
|
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 "$RESPOSITORY_PATH/reset_env.sh"
|
||||||
|
source "$SITE_PATH/site_definition"
|
||||||
|
source "$RESPOSITORY_PATH/domain_env.sh"
|
||||||
|
|
||||||
|
# these variable are used by both backup/restore scripts.
|
||||||
|
export REMOTE_BACKUP_PATH="$REMOTE_HOME/backups/www/$APP/$DOMAIN_IDENTIFIER"
|
||||||
|
export REMOTE_SOURCE_BACKUP_PATH="$REMOTE_HOME/$APP/$DOMAIN_NAME"
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
mkdir -p "$LOCAL_BACKUP_PATH"
|
||||||
|
|
||||||
|
if [ "$RESTORE_WWW" = true ]; then
|
||||||
|
sleep 5
|
||||||
|
echo "STARTING restore_path.sh for letsencrypt."
|
||||||
|
./restore_path.sh
|
||||||
|
#ssh "$PRIMARY_WWW_FQDN" sudo chown ubuntu:ubuntu "$REMOTE_HOME/$APP"
|
||||||
|
elif [ "$BACKUP_APPS" = true ]; then
|
||||||
|
# if we're not restoring, then we may or may not back up.
|
||||||
|
./backup_path.sh
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# if [ "$DEPLOY_ONION_SITE" = true ]; then
|
# if [ "$DEPLOY_ONION_SITE" = true ]; then
|
||||||
|
@ -47,52 +47,3 @@ for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ "$RESTART_FRONT_END" = true ]; then
|
|
||||||
# remove the nginx stack
|
|
||||||
if docker stack list --format "{{.Name}}" | grep -q reverse-proxy; then
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
docker stack rm reverse-proxy
|
|
||||||
|
|
||||||
# wait for all docker containers to stop.
|
|
||||||
# TODO see if there's a way to check for this.
|
|
||||||
sleep 15
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
# generate the certs and grab a backup
|
|
||||||
if [ "$RUN_CERT_RENEWAL" = true ]; then
|
|
||||||
./generate_certs.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
# let's backup all our letsencrypt certs
|
|
||||||
export APP="letsencrypt"
|
|
||||||
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 "$RESPOSITORY_PATH/reset_env.sh"
|
|
||||||
source "$SITE_PATH/site_definition"
|
|
||||||
source "$RESPOSITORY_PATH/domain_env.sh"
|
|
||||||
|
|
||||||
# these variable are used by both backup/restore scripts.
|
|
||||||
export REMOTE_BACKUP_PATH="$REMOTE_HOME/backups/www/$APP/$DOMAIN_IDENTIFIER"
|
|
||||||
export REMOTE_SOURCE_BACKUP_PATH="$REMOTE_HOME/$APP/$DOMAIN_NAME"
|
|
||||||
|
|
||||||
# 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"
|
|
||||||
mkdir -p "$LOCAL_BACKUP_PATH"
|
|
||||||
|
|
||||||
if [ "$RESTORE_WWW" = true ]; then
|
|
||||||
sleep 5
|
|
||||||
echo "STARTING restore_path.sh for letsencrypt."
|
|
||||||
./restore_path.sh
|
|
||||||
#ssh "$PRIMARY_WWW_FQDN" sudo chown ubuntu:ubuntu "$REMOTE_HOME/$APP"
|
|
||||||
elif [ "$BACKUP_APPS" = true ]; then
|
|
||||||
# if we're not restoring, then we may or may not back up.
|
|
||||||
./backup_path.sh
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
Loading…
Reference in New Issue
Block a user