2023-02-01 19:44:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-04-07 18:04:43 +00:00
|
|
|
set -eu
|
2023-02-01 19:44:05 +00:00
|
|
|
|
2023-09-22 23:46:07 +00:00
|
|
|
CURRENT_REMOTE="$(incus remote get-default)"
|
2023-11-30 21:34:44 +00:00
|
|
|
DEPLOYMENT_STRING=
|
|
|
|
|
|
|
|
SS_ROOT_PATH="$HOME/ss"
|
|
|
|
REMOTES_PATH="$SS_ROOT_PATH/remotes"
|
|
|
|
PROJECTS_PATH="$SS_ROOT_PATH/projects"
|
|
|
|
SITES_PATH="$SS_ROOT_PATH/sites"
|
|
|
|
INCUS_CONFIG_PATH="$SS_ROOT_PATH/incus"
|
|
|
|
SS_CACHE_PATH="$SS_ROOT_PATH/cache"
|
|
|
|
|
|
|
|
|
2023-02-01 19:44:05 +00:00
|
|
|
|
2024-02-09 16:33:01 +00:00
|
|
|
if echo "$CURRENT_REMOTE" | grep -q "prod"; then
|
2023-02-01 19:44:05 +00:00
|
|
|
echo "WARNING: You are running a migration procedure on a production system."
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
RESPONSE=
|
|
|
|
read -r -p " Are you sure you want to continue (y) ": RESPONSE
|
|
|
|
if [ "$RESPONSE" != "y" ]; then
|
|
|
|
echo "STOPPING."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check if there are any uncommited changes. It's dangerous to
|
|
|
|
# alter production systems when you have commits to make or changes to stash.
|
|
|
|
if git update-index --refresh | grep -q "needs update"; then
|
|
|
|
echo "ERROR: You have uncommited changes! Better stash your work with 'git stash'."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2023-04-07 14:23:04 +00:00
|
|
|
. ./deployment_defaults.sh
|
|
|
|
|
2023-04-04 15:30:07 +00:00
|
|
|
export REMOTE_PATH="$REMOTES_PATH/$CURRENT_REMOTE"
|
2023-03-13 17:40:47 +00:00
|
|
|
REMOTE_DEFINITION="$REMOTE_PATH/remote.conf"
|
2023-03-09 14:55:40 +00:00
|
|
|
export REMOTE_DEFINITION="$REMOTE_DEFINITION"
|
2023-02-01 19:44:05 +00:00
|
|
|
|
2023-03-09 14:55:40 +00:00
|
|
|
# ensure the remote definition exists.
|
|
|
|
if [ ! -f "$REMOTE_DEFINITION" ]; then
|
|
|
|
echo "ERROR: The remote definition could not be found. You may need to run 'ss-remote'."
|
2023-03-13 17:40:47 +00:00
|
|
|
echo "INFO: Consult https://www.sovereign-stack.org/ss-remote for more information."
|
2023-02-01 19:44:05 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-09 14:55:40 +00:00
|
|
|
source "$REMOTE_DEFINITION"
|
2023-04-04 15:32:54 +00:00
|
|
|
|