From 0264d4a2981f376b6cefbb9c727291c0e89d7218 Mon Sep 17 00:00:00 2001 From: Derek Smith Date: Fri, 21 Oct 2022 20:04:03 -0400 Subject: [PATCH] Added Nextcloud yml generation. --- defaults.sh | 6 +- deploy.sh | 14 +-- deployment/www/go.sh | 12 ++- deployment/www/stop_docker_stacks.sh | 7 +- deployment/www/stub/nextcloud_yml.sh | 122 +++++++++++++++++---------- deployment/www/stub/nginx_config.sh | 42 +++++++++ deployment/www/stub/nginx_yml.sh | 17 +++- deployment/www/stub_docker_yml.sh | 2 +- domain_env.sh | 4 + reset_env.sh | 2 +- 10 files changed, 166 insertions(+), 62 deletions(-) mode change 100644 => 100755 deployment/www/stub/nextcloud_yml.sh diff --git a/defaults.sh b/defaults.sh index 0b09dfc..e4468c3 100755 --- a/defaults.sh +++ b/defaults.sh @@ -111,7 +111,9 @@ DEFAULT_DB_IMAGE="mariadb:10.9.3-jammy" export GHOST_IMAGE="ghost:5.18.0" export GHOST_DB_IMAGE="$DEFAULT_DB_IMAGE" export NGINX_IMAGE="nginx:1.23.1" -export NEXTCLOUD_IMAGE="nextcloud:24.0.5" + +# version of backup is 24.0.3 +export NEXTCLOUD_IMAGE="nextcloud:25.0.0" export NEXTCLOUD_DB_IMAGE="$DEFAULT_DB_IMAGE" # TODO PIN the gitea version number. @@ -140,4 +142,4 @@ export BTCPAY_SERVER_APPPATH="$REMOTE_HOME/btcpayserver-docker" export REMOTE_CERT_BASE_DIR="$REMOTE_HOME/.certs" # this space is for OS, docker images, etc. DOES NOT INCLUDE USER DATA. -export ROOT_DISK_SIZE_GB=20 \ No newline at end of file +export ROOT_DISK_SIZE_GB=20 diff --git a/deploy.sh b/deploy.sh index 79727cd..21226ff 100755 --- a/deploy.sh +++ b/deploy.sh @@ -23,13 +23,12 @@ if ! lsb_release -d | grep -q "Ubuntu 22.04"; then exit 1 fi - DOMAIN_NAME= RESTORE_ARCHIVE= VPS_HOSTING_TARGET=lxd RUN_CERT_RENEWAL=false RESTORE_WWW=false -BACKUP_CERTS=true +BACKUP_CERTS=false BACKUP_APPS=true BACKUP_BTCPAY=false RESTORE_BTCPAY=false @@ -41,6 +40,7 @@ UPDATE_BTCPAY=false RECONFIGURE_BTCPAY_SERVER=false DEPLOY_BTCPAY_SERVER=false CLUSTER_NAME="$(lxc remote get-default)" +STOP_SERVICES=false # grab any modifications from the command line. for i in "$@"; do @@ -65,6 +65,10 @@ for i in "$@"; do BACKUP_CERTS=true shift ;; + --stop) + STOP_SERVICES=true + shift + ;; --archive=*) RESTORE_ARCHIVE="${i#*=}" shift @@ -126,7 +130,7 @@ export DOMAIN_NAME="$DOMAIN_NAME" export REGISTRY_DOCKER_IMAGE="registry:2" export RESTORE_ARCHIVE="$RESTORE_ARCHIVE" export RESTORE_WWW="$RESTORE_WWW" - +export STOP_SERVICES="$STOP_SERVICES" export BACKUP_CERTS="$BACKUP_CERTS" export BACKUP_APPS="$BACKUP_APPS" export RESTORE_BTCPAY="$RESTORE_BTCPAY" @@ -435,9 +439,9 @@ export SITE_LANGUAGE_CODES="en" export DUPLICITY_BACKUP_PASSPHRASE="$(new_pass)" #export BTCPAY_HOSTNAME_IN_CERT="store" export DEPLOY_GHOST=true -export DEPLOY_NEXTCLOUD=true +export DEPLOY_NEXTCLOUD=false export DEPLOY_NOSTR_RELAY=true -export NOSTR_ACCOUNT_PUBKEY="CHANGE_ME" +export NOSTR_ACCOUNT_PUBKEY="NOSTR_IDENTITY_PUBKEY_GOES_HERE" export DEPLOY_GITEA=false #export DEPLOY_ONION_SITE=false export GHOST_MYSQL_PASSWORD="$(new_pass)" diff --git a/deployment/www/go.sh b/deployment/www/go.sh index 41744e8..c83ac9e 100755 --- a/deployment/www/go.sh +++ b/deployment/www/go.sh @@ -64,7 +64,7 @@ for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do if [ -z "$NOSTR_ACCOUNT_PUBKEY" ]; then echo "ERROR: Ensure NOSTR_ACCOUNT_PUBKEY is configured in your site_definition." exit 1 - fi + fi fi if [ -z "$DUPLICITY_BACKUP_PASSPHRASE" ]; then @@ -114,15 +114,13 @@ if [ "$DEPLOY_ONION_SITE" = true ]; then # fi fi -bash -c ./stub/nginx_yml.sh +./stub/nginx_yml.sh -sleep 3 +./stub/ghost_yml.sh -bash -c ./stub/ghost_yml.sh +./stub/nextcloud_yml.sh -sleep 3 - -bash -c ./stub/gitea_yml.sh +./stub/gitea_yml.sh # # start a browser session; point it to port 80 to ensure HTTPS redirect. diff --git a/deployment/www/stop_docker_stacks.sh b/deployment/www/stop_docker_stacks.sh index a6999fb..0d4d27c 100755 --- a/deployment/www/stop_docker_stacks.sh +++ b/deployment/www/stop_docker_stacks.sh @@ -14,7 +14,7 @@ for DOMAIN_NAME in ${DOMAIN_LIST//,/ }; do source ../../domain_env.sh ### Stop all services. - for APP in ghost gitea; do + for APP in ghost nextcloud gitea; do # backup each language for each app. for LANGUAGE_CODE in ${SITE_LANGUAGE_CODES//,/ }; do STACK_NAME="$DOMAIN_IDENTIFIER-$APP-$LANGUAGE_CODE" @@ -52,6 +52,11 @@ done if docker stack list --format "{{.Name}}" | grep -q reverse-proxy; then docker stack rm reverse-proxy + if [ "$STOP_SERVICES" = true ]; then + echo "STOPPING as indicated by the --stop flag." + exit 1 + fi + # wait for all docker containers to stop. # TODO see if there's a way to check for this. sleep 10 diff --git a/deployment/www/stub/nextcloud_yml.sh b/deployment/www/stub/nextcloud_yml.sh old mode 100644 new mode 100755 index 818f81d..d427231 --- a/deployment/www/stub/nextcloud_yml.sh +++ b/deployment/www/stub/nextcloud_yml.sh @@ -1,48 +1,82 @@ +#!/bin/bash + +set -exu +cd "$(dirname "$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 "$SITE_PATH/site_definition" + source ../../../domain_env.sh + + # ensure remote directories exist if [ "$DEPLOY_NEXTCLOUD" = true ]; then - ssh "$PRIMARY_WWW_FQDN" "mkdir -p $REMOTE_NEXTCLOUD_PATH/db/data" - ssh "$PRIMARY_WWW_FQDN" "mkdir -p $REMOTE_NEXTCLOUD_PATH/db/logs" - ssh "$PRIMARY_WWW_FQDN" "mkdir -p $REMOTE_NEXTCLOUD_PATH/html" + + ssh "$PRIMARY_WWW_FQDN" "mkdir -p $REMOTE_NEXTCLOUD_PATH/$DOMAIN_NAME/en/db" + ssh "$PRIMARY_WWW_FQDN" "mkdir -p $REMOTE_NEXTCLOUD_PATH/$DOMAIN_NAME/en/html" + + sleep 2 + + WEBSTACK_PATH="$SITE_PATH/webstack" + mkdir -p "$WEBSTACK_PATH" + export DOCKER_YAML_PATH="$WEBSTACK_PATH/nextcloud-en.yml" + + # here's the NGINX config. We support ghost and nextcloud. + cat > "$DOCKER_YAML_PATH" <>"$NGINX_CONF_PATH" <>"$NGINX_CONF_PATH" <> "$DOCKER_YAML_PATH" <> "$DOCKER_YAML_PATH" <> "$DOCKER_YAML_PATH" <> "$DOCKER_YAML_PATH" <>"$DOCKER_YAML_PATH" <