2023-03-06 19:30:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-08-12 16:03:23 +00:00
|
|
|
set -eu
|
2023-03-06 19:30:56 +00:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
2023-03-20 14:24:33 +00:00
|
|
|
# Create the nginx config file which covers all domainys.
|
2023-03-06 19:30:56 +00:00
|
|
|
bash -c ./stub/nginx_config.sh
|
|
|
|
|
|
|
|
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-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
|
2023-04-14 16:49:13 +00:00
|
|
|
|
2023-03-06 19:30:56 +00:00
|
|
|
### Let's check to ensure all the requiredsettings are set.
|
|
|
|
if [ "$DEPLOY_GHOST" = true ]; then
|
|
|
|
if [ -z "$GHOST_MYSQL_PASSWORD" ]; then
|
2023-03-13 18:43:23 +00:00
|
|
|
echo "ERROR: Ensure GHOST_MYSQL_PASSWORD is configured in your site.conf."
|
2023-03-06 19:30:56 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$GHOST_MYSQL_ROOT_PASSWORD" ]; then
|
2023-03-13 18:43:23 +00:00
|
|
|
echo "ERROR: Ensure GHOST_MYSQL_ROOT_PASSWORD is configured in your site.conf."
|
2023-03-06 19:30:56 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$DEPLOY_GITEA" = true ]; then
|
|
|
|
if [ -z "$GITEA_MYSQL_PASSWORD" ]; then
|
2023-03-13 18:43:23 +00:00
|
|
|
echo "ERROR: Ensure GITEA_MYSQL_PASSWORD is configured in your site.conf."
|
2023-03-06 19:30:56 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -z "$GITEA_MYSQL_ROOT_PASSWORD" ]; then
|
2023-03-13 18:43:23 +00:00
|
|
|
echo "ERROR: Ensure GITEA_MYSQL_ROOT_PASSWORD is configured in your site.conf."
|
2023-03-06 19:30:56 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$DEPLOY_NEXTCLOUD" = true ]; then
|
|
|
|
if [ -z "$NEXTCLOUD_MYSQL_ROOT_PASSWORD" ]; then
|
2023-03-13 18:43:23 +00:00
|
|
|
echo "ERROR: Ensure NEXTCLOUD_MYSQL_ROOT_PASSWORD is configured in your site.conf."
|
2023-03-06 19:30:56 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$NEXTCLOUD_MYSQL_PASSWORD" ]; then
|
2023-03-13 18:43:23 +00:00
|
|
|
echo "ERROR: Ensure NEXTCLOUD_MYSQL_PASSWORD is configured in your site.conf."
|
2023-03-06 19:30:56 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-04-04 15:10:38 +00:00
|
|
|
|
|
|
|
if [ "$DEPLOY_NOSTR" = true ]; then
|
|
|
|
if [ -z "$NOSTR_ACCOUNT_PUBKEY" ]; then
|
|
|
|
echo "ERROR: When deploying nostr, you MUST specify NOSTR_ACCOUNT_PUBKEY."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2023-03-06 19:30:56 +00:00
|
|
|
if [ -z "$DUPLICITY_BACKUP_PASSPHRASE" ]; then
|
2023-03-13 18:43:23 +00:00
|
|
|
echo "ERROR: Ensure DUPLICITY_BACKUP_PASSPHRASE is configured in your site.conf."
|
2023-03-06 19:30:56 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$DOMAIN_NAME" ]; then
|
2023-03-13 18:43:23 +00:00
|
|
|
echo "ERROR: Ensure DOMAIN_NAME is configured in your site.conf."
|
2023-03-06 19:30:56 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
# 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.
|
2023-08-11 13:55:57 +00:00
|
|
|
STACKS_STILL_RUNNING=false
|
2023-03-19 17:44:37 +00:00
|
|
|
if [[ $(docker stack list | wc -l) -gt 2 ]]; then
|
2023-08-11 13:55:57 +00:00
|
|
|
echo "WARNING! You still have stacks running. If you have modified the SITES list,"
|
|
|
|
echo " you may need to go remove the docker stacks running the remote machine."
|
|
|
|
STACKS_STILL_RUNNING=true
|
2023-03-06 19:30:56 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-11 13:55:57 +00:00
|
|
|
# generate the certs and grab a backup
|
|
|
|
if [ "$RUN_CERT_RENEWAL" = true ] && [ "$RESTORE_CERTS" = false ] && [ "$STACKS_STILL_RUNNING" = false ]; then
|
|
|
|
./generate_certs.sh
|
|
|
|
fi
|
2023-03-06 19:30:56 +00:00
|
|
|
|
|
|
|
# nginx gets deployed first since it "owns" the docker networks of downstream services.
|
|
|
|
./stub/nginx_yml.sh
|
|
|
|
|
|
|
|
# next run our application stub logic. These deploy the apps too if configured to do so.
|
|
|
|
./stub/ghost_yml.sh
|
|
|
|
./stub/nextcloud_yml.sh
|
|
|
|
./stub/gitea_yml.sh
|
|
|
|
./stub/nostr_yml.sh
|