Compare commits
3 Commits
c08260a2d4
...
cc6bdef20d
Author | SHA1 | Date | |
---|---|---|---|
cc6bdef20d | |||
514ae6ce24 | |||
d283dfb353 |
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
@ -14,11 +14,11 @@
|
|||||||
"-x"
|
"-x"
|
||||||
],
|
],
|
||||||
"shellcheck.ignorePatterns": {},
|
"shellcheck.ignorePatterns": {},
|
||||||
"shellcheck.exclude": [
|
// "shellcheck.exclude": [
|
||||||
"SC1090",
|
// "SC1090",
|
||||||
"SC1091",
|
// "SC1091",
|
||||||
"SC2029"
|
// "SC2029"
|
||||||
],
|
// ],
|
||||||
"terminal.integrated.fontFamily": "monospace",
|
"terminal.integrated.fontFamily": "monospace",
|
||||||
"workbench.colorCustomizations": {
|
"workbench.colorCustomizations": {
|
||||||
"activityBar.background": "#1900a565",
|
"activityBar.background": "#1900a565",
|
||||||
|
@ -101,4 +101,4 @@ export PRIMARY_DOMAIN=
|
|||||||
# this is the git commit of the project/ sub git repo.
|
# this is the git commit of the project/ sub git repo.
|
||||||
# used in the migration script to switch into past for backup
|
# used in the migration script to switch into past for backup
|
||||||
# then back to present (TARGET_PROJECT_GIT_COMMIT) for restore.
|
# then back to present (TARGET_PROJECT_GIT_COMMIT) for restore.
|
||||||
export TARGET_PROJECT_GIT_COMMIT=bdd80779227775ad64c761a9f2deed2e878e76d1
|
export TARGET_PROJECT_GIT_COMMIT=c042ff404f02d3fc1739b325660411c68e3bf0b3
|
||||||
|
@ -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
|
|
@ -8,10 +8,11 @@ cd "$(dirname "$0")"
|
|||||||
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
|
PROJECT_NAME="$PROJECT_PREFIX-$BITCOIN_CHAIN"
|
||||||
export PROJECT_NAME="$PROJECT_NAME"
|
export PROJECT_NAME="$PROJECT_NAME"
|
||||||
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME"
|
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME"
|
||||||
PROJECT_DEFINITION_PATH="$PROJECT_PATH/project_definition"
|
export PROJECT_PATH="$PROJECT_PATH"
|
||||||
|
PROJECT_DEFINITION_PATH="$PROJECT_PATH/project.conf"
|
||||||
|
|
||||||
if [ ! -f "$PROJECT_DEFINITION_PATH" ]; then
|
if [ ! -f "$PROJECT_DEFINITION_PATH" ]; then
|
||||||
echo "ERROR: 'project_definition' not found $PROJECT_DEFINITION_PATH not found."
|
echo "ERROR: 'project.conf' not found $PROJECT_DEFINITION_PATH not found."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -22,28 +22,25 @@ fi
|
|||||||
source ../defaults.sh
|
source ../defaults.sh
|
||||||
|
|
||||||
export REMOTE_PATH="$REMOTES_DIR/$REMOTE_NAME"
|
export REMOTE_PATH="$REMOTES_DIR/$REMOTE_NAME"
|
||||||
REMOTE_DEFINITION="$REMOTE_PATH/remote_definition"
|
REMOTE_DEFINITION="$REMOTE_PATH/remote.conf"
|
||||||
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
||||||
|
|
||||||
mkdir -p "$REMOTE_PATH"
|
mkdir -p "$REMOTE_PATH"
|
||||||
if [ ! -f "$REMOTE_DEFINITION" ]; then
|
if [ ! -f "$REMOTE_DEFINITION" ]; then
|
||||||
# stub out a remote_definition.
|
# stub out a remote.conf.
|
||||||
cat >"$REMOTE_DEFINITION" <<EOL
|
cat >"$REMOTE_DEFINITION" <<EOL
|
||||||
#!/bin/bash
|
# https://www.sovereign-stack.org/ss-remote
|
||||||
|
|
||||||
# see https://www.sovereign-stack.org/remote for more info!
|
LXD_REMOTE_PASSWORD="$(gpg --gen-random --armor 1 14)"
|
||||||
|
DEPLOYMENT_STRING="(dev|regtest),(staging|testnet)"
|
||||||
export LXD_REMOTE_PASSWORD="$(gpg --gen-random --armor 1 14)"
|
# REGISTRY_URL=http://registry.domain.tld:5000
|
||||||
export BITCOIN_CHAIN="regtest"
|
|
||||||
export PROJECT_PREFIX="$REMOTE_NAME"
|
|
||||||
#export REGISTRY_URL=http://registry.domain.tld:5000
|
|
||||||
|
|
||||||
EOL
|
EOL
|
||||||
|
|
||||||
chmod 0744 "$REMOTE_DEFINITION"
|
chmod 0744 "$REMOTE_DEFINITION"
|
||||||
echo "We stubbed out a '$REMOTE_DEFINITION' file for you."
|
echo "We stubbed out a '$REMOTE_DEFINITION' file for you."
|
||||||
echo "Use this file to customize your remote deployment;"
|
echo "Use this file to customize your remote deployment;"
|
||||||
echo "Check out 'https://www.sovereign-stack.org/remote' for more information."
|
echo "Check out 'https://www.sovereign-stack.org/ss-remote' for more information."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -140,7 +137,7 @@ IP_OF_MGMT_MACHINE="$(echo "$IP_OF_MGMT_MACHINE" | cut -d: -f1)"
|
|||||||
|
|
||||||
# error out if the remote password is unset.
|
# error out if the remote password is unset.
|
||||||
if [ -z "$LXD_REMOTE_PASSWORD" ]; then
|
if [ -z "$LXD_REMOTE_PASSWORD" ]; then
|
||||||
echo "ERROR: LXD_REMOTE_PASSWORD must be set in your remote_definition."
|
echo "ERROR: LXD_REMOTE_PASSWORD must be set in your remote.conf file."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -27,13 +27,13 @@ if echo "$CURRENT_REMOTE" | grep -q "production"; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
export REMOTE_PATH="$REMOTES_DIR/$CURRENT_REMOTE"
|
export REMOTE_PATH="$REMOTES_DIR/$CURRENT_REMOTE"
|
||||||
REMOTE_DEFINITION="$REMOTE_PATH/remote_definition"
|
REMOTE_DEFINITION="$REMOTE_PATH/remote.conf"
|
||||||
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
||||||
|
|
||||||
# ensure the remote definition exists.
|
# ensure the remote definition exists.
|
||||||
if [ ! -f "$REMOTE_DEFINITION" ]; then
|
if [ ! -f "$REMOTE_DEFINITION" ]; then
|
||||||
echo "ERROR: The remote definition could not be found. You may need to run 'ss-remote'."
|
echo "ERROR: The remote definition could not be found. You may need to run 'ss-remote'."
|
||||||
echo "INFO: Consult https://www.sovereign-stack.org/remote for more information."
|
echo "INFO: Consult https://www.sovereign-stack.org/ss-remote for more information."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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