Add RESTORE_CERTS

This commit is contained in:
Derek Smith 2023-03-18 11:04:59 -04:00
parent 8ca7faa0bb
commit 423db12add
Signed by: farscapian
GPG Key ID: B443E530A14E1C90
3 changed files with 16 additions and 7 deletions

View File

@ -44,6 +44,7 @@ DOMAIN_NAME=
RUN_CERT_RENEWAL=true RUN_CERT_RENEWAL=true
SKIP_WWW=false SKIP_WWW=false
RESTORE_WWW=false RESTORE_WWW=false
RESTORE_CERTS=false
BACKUP_CERTS=true BACKUP_CERTS=true
BACKUP_APPS=true BACKUP_APPS=true
BACKUP_BTCPAY=true BACKUP_BTCPAY=true
@ -61,6 +62,10 @@ USER_TARGET_PROJECT=
# grab any modifications from the command line. # grab any modifications from the command line.
for i in "$@"; do for i in "$@"; do
case $i in case $i in
--restore-certs)
RESTORE_CERTS=true
shift
;;
--restore-www) --restore-www)
RESTORE_WWW=true RESTORE_WWW=true
BACKUP_APPS=false BACKUP_APPS=false
@ -149,6 +154,8 @@ export REMOTE_PATH="$REMOTES_DIR/$REMOTE_NAME"
export USER_SAYS_YES="$USER_SAYS_YES" export USER_SAYS_YES="$USER_SAYS_YES"
export BACKUP_BTCPAY_ARCHIVE_PATH="$BACKUP_BTCPAY_ARCHIVE_PATH" export BACKUP_BTCPAY_ARCHIVE_PATH="$BACKUP_BTCPAY_ARCHIVE_PATH"
export RESTART_FRONT_END="$RESTART_FRONT_END" export RESTART_FRONT_END="$RESTART_FRONT_END"
export RESTORE_CERTS="$RESTORE_CERTS"
# todo convert this to Trezor-T # todo convert this to Trezor-T
SSH_PUBKEY_PATH="$SSH_HOME/id_rsa.pub" SSH_PUBKEY_PATH="$SSH_HOME/id_rsa.pub"

View File

@ -98,7 +98,7 @@ if [ "$RESTART_FRONT_END" = true ]; then
fi fi
# generate the certs and grab a backup # generate the certs and grab a backup
if [ "$RUN_CERT_RENEWAL" = true ]; then if [ "$RUN_CERT_RENEWAL" = true ] && [ "$RESTORE_CERTS" = false ]; then
./generate_certs.sh ./generate_certs.sh
fi fi
@ -121,13 +121,10 @@ if [ "$RESTART_FRONT_END" = true ]; then
export LOCAL_BACKUP_PATH="$SITE_PATH/backups/www/$APP" export LOCAL_BACKUP_PATH="$SITE_PATH/backups/www/$APP"
mkdir -p "$LOCAL_BACKUP_PATH" mkdir -p "$LOCAL_BACKUP_PATH"
if [ "$RESTORE_WWW" = true ]; then # we grab a backup of the certs unless we're restoring.
sleep 5 if [ "$RESTORE_CERTS" = true ]; then
echo "STARTING restore_path.sh for letsencrypt."
./restore_path.sh ./restore_path.sh
#ssh "$PRIMARY_WWW_FQDN" sudo chown ubuntu:ubuntu "$REMOTE_HOME/$APP" else
elif [ "$BACKUP_APPS" = true ]; then
# if we're not restoring, then we may or may not back up.
./backup_path.sh ./backup_path.sh
fi fi
done done

View File

@ -8,6 +8,11 @@ if [ "$FILE_COUNT" = 0 ]; then
exit 0 exit 0
fi fi
# if the user specified --restore-certs then we'll go forward on letsencrypt
if [ "$APP" = letsencrypt ] && [ "$RESTORE_CERTS" = true ]; then
USER_SAYS_YES=true
fi
# if the user said -y at the cli, we can skip this. # if the user said -y at the cli, we can skip this.
if [ "$USER_SAYS_YES" = false ]; then if [ "$USER_SAYS_YES" = false ]; then