Add iterate over DEPLOYMENT_STRING
This commit is contained in:
parent
c08260a2d4
commit
d283dfb353
@ -26,46 +26,52 @@ fi
|
|||||||
|
|
||||||
. ./remote_env.sh
|
. ./remote_env.sh
|
||||||
|
|
||||||
. ./project_env.sh
|
for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
|
||||||
|
NO_PARENS="${PROJECT_CHAIN:1:${#PROJECT_CHAIN}-2}"
|
||||||
|
PROJECT_PREFIX=$(echo "$NO_PARENS" | cut -d'|' -f1)
|
||||||
|
BITCOIN_CHAIN=$(echo "$NO_PARENS" | cut -d'|' -f2)
|
||||||
|
export PROJECT_PREFIX="$PROJECT_PREFIX"
|
||||||
|
export BITCOIN_CHAIN="$BITCOIN_CHAIN"
|
||||||
|
|
||||||
if ! lxc info | grep "project:" | grep -q "$PROJECT_NAME"; then
|
. ./project_env.sh
|
||||||
if lxc project list | grep -q "$PROJECT_NAME"; then
|
|
||||||
lxc project switch "$PROJECT_NAME"
|
if ! lxc info | grep "project:" | grep -q "$PROJECT_NAME"; then
|
||||||
|
if lxc project list | grep -q "$PROJECT_NAME"; then
|
||||||
|
lxc project switch "$PROJECT_NAME"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
for VM in www btcpayserver; do
|
for VM in www btcpayserver; do
|
||||||
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
||||||
|
|
||||||
if lxc list | grep -q "$LXD_NAME"; then
|
if lxc list | grep -q "$LXD_NAME"; then
|
||||||
lxc delete -f "$LXD_NAME"
|
lxc delete -f "$LXD_NAME"
|
||||||
|
|
||||||
|
# remove the ssh known endpoint else we get warnings.
|
||||||
|
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$LXD_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if lxc profile list | grep -q "$LXD_NAME"; then
|
||||||
|
lxc profile delete "$LXD_NAME"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if lxc network list -q | grep -q ss-ovn; then
|
||||||
|
lxc network delete ss-ovn
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! lxc info | grep "project:" | grep -q default; then
|
||||||
|
lxc project switch default
|
||||||
|
fi
|
||||||
|
|
||||||
|
if lxc project list | grep -q "$PROJECT_NAME"; then
|
||||||
|
lxc project delete "$PROJECT_NAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# delete the base image so it can be created.
|
||||||
|
if lxc list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
||||||
|
lxc delete -f "$BASE_IMAGE_VM_NAME"
|
||||||
# remove the ssh known endpoint else we get warnings.
|
# remove the ssh known endpoint else we get warnings.
|
||||||
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$LXD_NAME"
|
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$LXD_NAME"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
if lxc profile list | grep -q "$LXD_NAME"; then
|
|
||||||
lxc profile delete "$LXD_NAME"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
if lxc network list -q | grep -q ss-ovn; then
|
|
||||||
lxc network delete ss-ovn
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! lxc info | grep "project:" | grep -q default; then
|
|
||||||
lxc project switch default
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if lxc project list | grep -q "$PROJECT_NAME"; then
|
|
||||||
lxc project delete "$PROJECT_NAME"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# delete the base image so it can be created.
|
|
||||||
if lxc list | grep -q "$BASE_IMAGE_VM_NAME"; then
|
|
||||||
lxc delete -f "$BASE_IMAGE_VM_NAME"
|
|
||||||
# remove the ssh known endpoint else we get warnings.
|
|
||||||
ssh-keygen -f "$SSH_HOME/known_hosts" -R "$LXD_NAME"
|
|
||||||
fi
|
|
@ -16,58 +16,64 @@ fi
|
|||||||
|
|
||||||
. ./remote_env.sh
|
. ./remote_env.sh
|
||||||
|
|
||||||
. ./project_env.sh
|
for PROJECT_CHAIN in ${DEPLOYMENT_STRING//,/ }; do
|
||||||
|
NO_PARENS="${PROJECT_CHAIN:1:${#PROJECT_CHAIN}-2}"
|
||||||
|
PROJECT_PREFIX=$(echo "$NO_PARENS" | cut -d'|' -f1)
|
||||||
|
BITCOIN_CHAIN=$(echo "$NO_PARENS" | cut -d'|' -f2)
|
||||||
|
export PROJECT_PREFIX="$PROJECT_PREFIX"
|
||||||
|
export BITCOIN_CHAIN="$BITCOIN_CHAIN"
|
||||||
|
|
||||||
|
. ./project_env.sh
|
||||||
|
|
||||||
|
# Check to see if any of the VMs actually don't exist.
|
||||||
|
# (we only migrate instantiated vms)
|
||||||
|
for VM in www btcpayserver; do
|
||||||
|
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
||||||
|
|
||||||
# Check to see if any of the VMs actually don't exist.
|
# if the VM doesn't exist, the we emit an error message and hard quit.
|
||||||
# (we only migrate instantiated vms)
|
if ! lxc list --format csv | grep -q "$LXD_NAME"; then
|
||||||
for VM in www btcpayserver; do
|
echo "ERROR: there is no VM named '$LXD_NAME'. You probably need to run ss-deploy again."
|
||||||
LXD_NAME="$VM-${DOMAIN_NAME//./-}"
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# if the VM doesn't exist, the we emit an error message and hard quit.
|
BTCPAY_RESTORE_ARCHIVE_PATH="$SITES_PATH/$PRIMARY_DOMAIN/backups/btcpayserver/$(date +%s).tar.gz"
|
||||||
if ! lxc list --format csv | grep -q "$LXD_NAME"; then
|
echo "INFO: The BTCPAY_RESTORE_ARCHIVE_PATH for this migration will be: $BTCPAY_RESTORE_ARCHIVE_PATH"
|
||||||
echo "ERROR: there is no VM named '$LXD_NAME'. You probably need to run ss-deploy again."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
BTCPAY_RESTORE_ARCHIVE_PATH="$SITES_PATH/$PRIMARY_DOMAIN/backups/btcpayserver/$(date +%s).tar.gz"
|
# first we run ss-deploy --stop
|
||||||
echo "INFO: The BTCPAY_RESTORE_ARCHIVE_PATH for this migration will be: $BTCPAY_RESTORE_ARCHIVE_PATH"
|
# this grabs a backup of all data (backups are on by default) and saves them to the management machine
|
||||||
|
# the --stop flag ensures that services do NOT come back online.
|
||||||
|
# by default, we grab a backup.
|
||||||
|
|
||||||
# first we run ss-deploy --stop
|
# first, let's grab the GIT commit from the remote machine.
|
||||||
# this grabs a backup of all data (backups are on by default) and saves them to the management machine
|
export DOMAIN_NAME="$PRIMARY_DOMAIN"
|
||||||
# the --stop flag ensures that services do NOT come back online.
|
export SITE_PATH="$SITES_PATH/$PRIMARY_DOMAIN"
|
||||||
# by default, we grab a backup.
|
|
||||||
|
|
||||||
# first, let's grab the GIT commit from the remote machine.
|
# source the site path so we know what features it has.
|
||||||
export DOMAIN_NAME="$PRIMARY_DOMAIN"
|
source ../defaults.sh
|
||||||
export SITE_PATH="$SITES_PATH/$PRIMARY_DOMAIN"
|
source "$SITE_PATH/site_definition"
|
||||||
|
source ./project/domain_env.sh
|
||||||
|
|
||||||
# source the site path so we know what features it has.
|
# now we want to switch the git HEAD of the project subdirectory to the
|
||||||
source ../defaults.sh
|
# version of code that was last used
|
||||||
source "$SITE_PATH/site_definition"
|
GIT_COMMIT_ON_REMOTE_HOST="$(ssh ubuntu@$BTCPAY_FQDN cat /home/ubuntu/.ss-githead)"
|
||||||
source ./project/domain_env.sh
|
cd project/
|
||||||
|
git checkout "$GIT_COMMIT_ON_REMOTE_HOST"
|
||||||
|
cd -
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
# run deploy which backups up everything, but doesnt restart any services.
|
||||||
|
bash -c "./project/deploy.sh --stop --no-cert-renew --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH"
|
||||||
|
|
||||||
# now we want to switch the git HEAD of the project subdirectory to the
|
# call the destroy script. If user proceed, then user data is DESTROYED!
|
||||||
# version of code that was last used
|
./destroy.sh
|
||||||
GIT_COMMIT_ON_REMOTE_HOST="$(ssh ubuntu@$BTCPAY_FQDN cat /home/ubuntu/.ss-githead)"
|
|
||||||
cd project/
|
|
||||||
git checkout "$GIT_COMMIT_ON_REMOTE_HOST"
|
|
||||||
cd -
|
|
||||||
sleep 5
|
|
||||||
|
|
||||||
# run deploy which backups up everything, but doesnt restart any services.
|
cd project/
|
||||||
bash -c "./project/deploy.sh --stop --no-cert-renew --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH"
|
git checkout "$TARGET_PROJECT_GIT_COMMIT"
|
||||||
|
cd -
|
||||||
|
|
||||||
# call the destroy script. If user proceed, then user data is DESTROYED!
|
sleep 5
|
||||||
./destroy.sh
|
# Then we can run a restore operation and specify the backup archive at the CLI.
|
||||||
|
bash -c "./project/deploy.sh -y --restore-www --restore-btcpay --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH"
|
||||||
|
|
||||||
cd project/
|
done
|
||||||
git checkout "$TARGET_PROJECT_GIT_COMMIT"
|
|
||||||
cd -
|
|
||||||
|
|
||||||
sleep 5
|
|
||||||
# Then we can run a restore operation and specify the backup archive at the CLI.
|
|
||||||
bash -c "./project/deploy.sh -y --restore-www --restore-btcpay --backup-archive-path=$BTCPAY_RESTORE_ARCHIVE_PATH"
|
|
Loading…
Reference in New Issue
Block a user