|
|
|
|
@ -6,6 +6,9 @@ set -eu
|
|
|
|
|
CONFIG_DIR=/etc/freedmr
|
|
|
|
|
DRY_RUN=0
|
|
|
|
|
ASSUME_YES=0
|
|
|
|
|
TARGET_DEPLOYMENT_VERSION=1
|
|
|
|
|
LOCK_DIR=
|
|
|
|
|
WORK_DIR=
|
|
|
|
|
|
|
|
|
|
usage()
|
|
|
|
|
{
|
|
|
|
|
@ -13,7 +16,8 @@ usage()
|
|
|
|
|
Usage: upgrade-daprs-to-data-gateway.sh [--config-dir DIR] [--dry-run] [--yes]
|
|
|
|
|
|
|
|
|
|
Migrates a recognised legacy D-APRS service in docker-compose.yml to the native
|
|
|
|
|
FreeDMR Data Gateway and enables its FBP v5 relationship in freedmr.cfg.
|
|
|
|
|
FreeDMR Data Gateway and enables its FBP v5 relationship in freedmr.cfg. The
|
|
|
|
|
operation is idempotent and can resume an unambiguous partial migration.
|
|
|
|
|
|
|
|
|
|
Existing server, HDStack and APRS values are read from freedmr.cfg and the
|
|
|
|
|
legacy D-APRS service in docker-compose.yml. A new private FBP key is generated
|
|
|
|
|
@ -21,6 +25,12 @@ unless freedmr.cfg already contains a non-placeholder Data Gateway passphrase.
|
|
|
|
|
USAGE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cleanup()
|
|
|
|
|
{
|
|
|
|
|
[ -z "$WORK_DIR" ] || rm -rf "$WORK_DIR"
|
|
|
|
|
[ -z "$LOCK_DIR" ] || rmdir "$LOCK_DIR" 2>/dev/null || true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fail()
|
|
|
|
|
{
|
|
|
|
|
echo "Upgrade aborted: $*" >&2
|
|
|
|
|
@ -82,10 +92,22 @@ config_value()
|
|
|
|
|
|
|
|
|
|
compose_environment_value()
|
|
|
|
|
{
|
|
|
|
|
wanted="$1"
|
|
|
|
|
awk -v wanted="$wanted" '
|
|
|
|
|
wanted_service="$1"
|
|
|
|
|
wanted="$2"
|
|
|
|
|
awk -v wanted_service="$wanted_service" -v wanted="$wanted" '
|
|
|
|
|
{
|
|
|
|
|
line = $0
|
|
|
|
|
sub(/[[:space:]]+$/, "", line)
|
|
|
|
|
if (line == " " wanted_service ":") {
|
|
|
|
|
in_service = 1
|
|
|
|
|
next
|
|
|
|
|
}
|
|
|
|
|
if (in_service &&
|
|
|
|
|
(line ~ /^ [A-Za-z0-9_.-]+:[[:space:]]*$/ ||
|
|
|
|
|
line ~ /^[^[:space:]#][^:]*:[[:space:]]*$/))
|
|
|
|
|
exit
|
|
|
|
|
if (!in_service)
|
|
|
|
|
next
|
|
|
|
|
sub(/^[[:space:]]*-[[:space:]]*/, "", line)
|
|
|
|
|
sub(/^[[:space:]]*/, "", line)
|
|
|
|
|
if (index(line, wanted "=") == 1) {
|
|
|
|
|
@ -104,6 +126,42 @@ compose_environment_value()
|
|
|
|
|
' "$COMPOSE_FILE"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deployment_version()
|
|
|
|
|
{
|
|
|
|
|
awk '
|
|
|
|
|
BEGIN { prefix = "# FREEDMR_DEPLOYMENT_VERSION=" }
|
|
|
|
|
index($0, prefix) == 1 {
|
|
|
|
|
count++
|
|
|
|
|
value = substr($0, length(prefix) + 1)
|
|
|
|
|
gsub(/[[:space:]]/, "", value)
|
|
|
|
|
if (value !~ /^[0-9]+$/)
|
|
|
|
|
invalid = 1
|
|
|
|
|
}
|
|
|
|
|
END {
|
|
|
|
|
if (count == 0)
|
|
|
|
|
print 0
|
|
|
|
|
else if (count == 1 && !invalid)
|
|
|
|
|
print value
|
|
|
|
|
else
|
|
|
|
|
exit 2
|
|
|
|
|
}
|
|
|
|
|
' "$FREEDMR_CONFIG"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json_string_value()
|
|
|
|
|
{
|
|
|
|
|
field_name="$1"
|
|
|
|
|
printf '%s\n' "$2" | sed 's/}.*$/}/' | sed -n \
|
|
|
|
|
"s/.*\"$field_name\"[[:space:]]*:[[:space:]]*\"\([^\"]*\)\".*/\1/p"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
json_number_value()
|
|
|
|
|
{
|
|
|
|
|
field_name="$1"
|
|
|
|
|
printf '%s\n' "$2" | sed 's/}.*$/}/' | sed -n \
|
|
|
|
|
"s/.*\"$field_name\"[[:space:]]*:[[:space:]]*\([0-9][0-9]*\).*/\1/p"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
build_relationships()
|
|
|
|
|
{
|
|
|
|
|
count="$1"
|
|
|
|
|
@ -170,6 +228,14 @@ COMPOSE_FILE="$CONFIG_DIR/docker-compose.yml"
|
|
|
|
|
[ -w "$FREEDMR_CONFIG" ] || fail "$FREEDMR_CONFIG is not writable"
|
|
|
|
|
[ -w "$COMPOSE_FILE" ] || fail "$COMPOSE_FILE is not writable"
|
|
|
|
|
|
|
|
|
|
LOCK_DIR="$CONFIG_DIR/.freedmr-upgrade.lock"
|
|
|
|
|
if ! mkdir "$LOCK_DIR" 2>/dev/null
|
|
|
|
|
then
|
|
|
|
|
fail "another FreeDMR deployment upgrade appears to be running: $LOCK_DIR"
|
|
|
|
|
fi
|
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
trap 'cleanup; exit 130' HUP INT TERM
|
|
|
|
|
|
|
|
|
|
grep -q '^\[GLOBAL\][[:space:]]*$' "$FREEDMR_CONFIG" || \
|
|
|
|
|
fail "$FREEDMR_CONFIG has no [GLOBAL] section"
|
|
|
|
|
grep -q '^services:[[:space:]]*$' "$COMPOSE_FILE" || \
|
|
|
|
|
@ -179,24 +245,36 @@ grep -q '^ freedmr:[[:space:]]*$' "$COMPOSE_FILE" || \
|
|
|
|
|
|
|
|
|
|
legacy_count=$(grep -Ec '^ D-APRS:[[:space:]]*$' "$COMPOSE_FILE" || true)
|
|
|
|
|
native_count=$(grep -Ec '^ data-gateway:[[:space:]]*$' "$COMPOSE_FILE" || true)
|
|
|
|
|
[ "$native_count" -eq 0 ] || \
|
|
|
|
|
fail "a native data-gateway service already exists; no files were changed"
|
|
|
|
|
[ "$legacy_count" -eq 1 ] || \
|
|
|
|
|
fail "expected exactly one legacy D-APRS service, found $legacy_count"
|
|
|
|
|
|
|
|
|
|
legacy_block=$(awk '
|
|
|
|
|
/^ D-APRS:[[:space:]]*$/ { active = 1 }
|
|
|
|
|
active && NR > 1 && (/^ [A-Za-z0-9_.-]+:[[:space:]]*$/ || /^[^[:space:]#][^:]*:[[:space:]]*$/) && $0 !~ /^ D-APRS:/ { exit }
|
|
|
|
|
active { print }
|
|
|
|
|
' "$COMPOSE_FILE")
|
|
|
|
|
printf '%s\n' "$legacy_block" | grep -q 'container_name:[[:space:]]*D-APRS' || \
|
|
|
|
|
fail "the D-APRS service is not the recognised legacy container shape"
|
|
|
|
|
printf '%s\n' "$legacy_block" | grep -q 'APRS_CALL' || \
|
|
|
|
|
fail "the D-APRS service has no recognised APRS_CALL setting"
|
|
|
|
|
printf '%s\n' "$legacy_block" | grep -q 'APRS_PASSCODE' || \
|
|
|
|
|
fail "the D-APRS service has no recognised APRS_PASSCODE setting"
|
|
|
|
|
|
|
|
|
|
HDSTACK_COUNT=$(compose_environment_value HDSTACK)
|
|
|
|
|
[ "$legacy_count" -le 1 ] || fail "found more than one legacy D-APRS service"
|
|
|
|
|
[ "$native_count" -le 1 ] || fail "found more than one native data-gateway service"
|
|
|
|
|
if [ "$legacy_count" -eq 0 ] && [ "$native_count" -eq 0 ]
|
|
|
|
|
then
|
|
|
|
|
fail "neither a recognised legacy D-APRS service nor a native data-gateway service was found"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$legacy_count" -eq 1 ]
|
|
|
|
|
then
|
|
|
|
|
legacy_block=$(awk '
|
|
|
|
|
/^ D-APRS:[[:space:]]*$/ { active = 1 }
|
|
|
|
|
active && NR > 1 && (/^ [A-Za-z0-9_.-]+:[[:space:]]*$/ || /^[^[:space:]#][^:]*:[[:space:]]*$/) && $0 !~ /^ D-APRS:/ { exit }
|
|
|
|
|
active { print }
|
|
|
|
|
' "$COMPOSE_FILE")
|
|
|
|
|
printf '%s\n' "$legacy_block" | grep -q 'container_name:[[:space:]]*D-APRS' || \
|
|
|
|
|
fail "the D-APRS service is not the recognised legacy container shape"
|
|
|
|
|
printf '%s\n' "$legacy_block" | grep -q 'APRS_CALL' || \
|
|
|
|
|
fail "the D-APRS service has no recognised APRS_CALL setting"
|
|
|
|
|
printf '%s\n' "$legacy_block" | grep -q 'APRS_PASSCODE' || \
|
|
|
|
|
fail "the D-APRS service has no recognised APRS_PASSCODE setting"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
CURRENT_DEPLOYMENT_VERSION=$(deployment_version) || \
|
|
|
|
|
fail "freedmr.cfg has an invalid or duplicate deployment-version marker"
|
|
|
|
|
if [ "$CURRENT_DEPLOYMENT_VERSION" -gt "$TARGET_DEPLOYMENT_VERSION" ]
|
|
|
|
|
then
|
|
|
|
|
fail "deployment version $CURRENT_DEPLOYMENT_VERSION is newer than this upgrader supports"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
HDSTACK_COUNT=$(compose_environment_value freedmr HDSTACK)
|
|
|
|
|
if [ -z "$HDSTACK_COUNT" ]
|
|
|
|
|
then
|
|
|
|
|
CPU_COUNT=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || CPU_COUNT=2
|
|
|
|
|
@ -219,7 +297,7 @@ then
|
|
|
|
|
fail "HDSTACK must be an integer from 1 to 5"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
BASE_ID=$(compose_environment_value HDSTACK_BASEID)
|
|
|
|
|
BASE_ID=$(compose_environment_value freedmr HDSTACK_BASEID)
|
|
|
|
|
if [ -z "$BASE_ID" ]
|
|
|
|
|
then
|
|
|
|
|
BASE_ID=$(config_value GLOBAL SERVER_ID)
|
|
|
|
|
@ -234,20 +312,51 @@ then
|
|
|
|
|
fail "the base server ID plus worker IDs exceeds the supported range"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
APRS_CALL=$(compose_environment_value APRS_CALL)
|
|
|
|
|
[ -n "$APRS_CALL" ] || fail "the legacy D-APRS service has no usable APRS_CALL value"
|
|
|
|
|
if [ "$native_count" -eq 1 ]
|
|
|
|
|
then
|
|
|
|
|
APRS_CALL=$(compose_environment_value data-gateway FREEDMR_GATEWAY_APRS_LOGIN_CALL)
|
|
|
|
|
APRS_PASSCODE=$(compose_environment_value data-gateway FREEDMR_GATEWAY_APRS_PASSCODE)
|
|
|
|
|
NATIVE_RELATIONSHIPS=$(compose_environment_value data-gateway FREEDMR_GATEWAY_FBP_RELATIONSHIPS)
|
|
|
|
|
[ -n "$NATIVE_RELATIONSHIPS" ] || \
|
|
|
|
|
fail "the native data-gateway service has no FBP relationship configuration"
|
|
|
|
|
NATIVE_FBP_KEY=$(json_string_value key "$NATIVE_RELATIONSHIPS")
|
|
|
|
|
NATIVE_GATEWAY_BIND_PORT=$(json_number_value bind_port "$NATIVE_RELATIONSHIPS")
|
|
|
|
|
NATIVE_GATEWAY_PEER_PORT=$(json_number_value peer_port "$NATIVE_RELATIONSHIPS")
|
|
|
|
|
[ -n "$NATIVE_FBP_KEY" ] || \
|
|
|
|
|
fail "the native data-gateway relationship has no usable key"
|
|
|
|
|
[ -n "$NATIVE_GATEWAY_BIND_PORT" ] || \
|
|
|
|
|
fail "the native data-gateway relationship has no usable bind port"
|
|
|
|
|
[ -n "$NATIVE_GATEWAY_PEER_PORT" ] || \
|
|
|
|
|
fail "the native data-gateway relationship has no usable peer port"
|
|
|
|
|
else
|
|
|
|
|
APRS_CALL=$(compose_environment_value D-APRS APRS_CALL)
|
|
|
|
|
APRS_PASSCODE=$(compose_environment_value D-APRS APRS_PASSCODE)
|
|
|
|
|
NATIVE_RELATIONSHIPS=
|
|
|
|
|
NATIVE_FBP_KEY=
|
|
|
|
|
NATIVE_GATEWAY_BIND_PORT=
|
|
|
|
|
NATIVE_GATEWAY_PEER_PORT=
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
[ -n "$APRS_CALL" ] || fail "the reporting service has no usable APRS-IS login callsign"
|
|
|
|
|
case "$APRS_CALL" in
|
|
|
|
|
''|*[!A-Za-z0-9-]*) fail "APRS-IS login callsign contains invalid characters" ;;
|
|
|
|
|
esac
|
|
|
|
|
[ "${#APRS_CALL}" -le 9 ] || fail "APRS-IS login callsign must not exceed 9 characters"
|
|
|
|
|
|
|
|
|
|
APRS_PASSCODE=$(compose_environment_value APRS_PASSCODE)
|
|
|
|
|
[ -n "$APRS_PASSCODE" ] || \
|
|
|
|
|
fail "the legacy D-APRS service has no usable APRS_PASSCODE value"
|
|
|
|
|
fail "the reporting service has no usable APRS-IS passcode"
|
|
|
|
|
is_unsigned_integer "$APRS_PASSCODE" || fail "APRS-IS passcode must be numeric"
|
|
|
|
|
|
|
|
|
|
FBP_KEY=$(config_value DATA-GATEWAY PASSPHRASE)
|
|
|
|
|
if [ -z "$FBP_KEY" ] || [ "$FBP_KEY" = "change-this" ]
|
|
|
|
|
if [ -n "$NATIVE_FBP_KEY" ]
|
|
|
|
|
then
|
|
|
|
|
if [ -n "$FBP_KEY" ] && [ "$FBP_KEY" != "change-this" ] && \
|
|
|
|
|
[ "$FBP_KEY" != "$NATIVE_FBP_KEY" ]
|
|
|
|
|
then
|
|
|
|
|
fail "freedmr.cfg and the native data-gateway service use different FBP keys"
|
|
|
|
|
fi
|
|
|
|
|
FBP_KEY="$NATIVE_FBP_KEY"
|
|
|
|
|
elif [ -z "$FBP_KEY" ] || [ "$FBP_KEY" = "change-this" ]
|
|
|
|
|
then
|
|
|
|
|
FBP_KEY=$(od -An -N10 -tx1 /dev/urandom | tr -d ' \n')
|
|
|
|
|
fi
|
|
|
|
|
@ -257,9 +366,21 @@ esac
|
|
|
|
|
[ "${#FBP_KEY}" -le 20 ] || fail "the Data Gateway FBP key must not exceed 20 characters"
|
|
|
|
|
|
|
|
|
|
GATEWAY_PEER_PORT=$(config_value DATA-GATEWAY PORT)
|
|
|
|
|
[ -n "$GATEWAY_PEER_PORT" ] || GATEWAY_PEER_PORT="$NATIVE_GATEWAY_PEER_PORT"
|
|
|
|
|
[ -n "$GATEWAY_PEER_PORT" ] || GATEWAY_PEER_PORT=62041
|
|
|
|
|
if [ -n "$NATIVE_GATEWAY_PEER_PORT" ] && \
|
|
|
|
|
[ "$GATEWAY_PEER_PORT" != "$NATIVE_GATEWAY_PEER_PORT" ]
|
|
|
|
|
then
|
|
|
|
|
fail "freedmr.cfg and the native data-gateway service use different peer ports"
|
|
|
|
|
fi
|
|
|
|
|
GATEWAY_BIND_PORT=$(config_value DATA-GATEWAY TARGET_PORT)
|
|
|
|
|
[ -n "$GATEWAY_BIND_PORT" ] || GATEWAY_BIND_PORT="$NATIVE_GATEWAY_BIND_PORT"
|
|
|
|
|
[ -n "$GATEWAY_BIND_PORT" ] || GATEWAY_BIND_PORT=62031
|
|
|
|
|
if [ -n "$NATIVE_GATEWAY_BIND_PORT" ] && \
|
|
|
|
|
[ "$GATEWAY_BIND_PORT" != "$NATIVE_GATEWAY_BIND_PORT" ]
|
|
|
|
|
then
|
|
|
|
|
fail "freedmr.cfg and the native data-gateway service use different bind ports"
|
|
|
|
|
fi
|
|
|
|
|
for gateway_port in "$GATEWAY_PEER_PORT" "$GATEWAY_BIND_PORT"
|
|
|
|
|
do
|
|
|
|
|
if ! is_unsigned_integer "$gateway_port" || \
|
|
|
|
|
@ -276,14 +397,22 @@ done
|
|
|
|
|
RELATIONSHIPS=$(build_relationships \
|
|
|
|
|
"$HDSTACK_COUNT" "$BASE_ID" "$FBP_KEY" \
|
|
|
|
|
"$GATEWAY_BIND_PORT" "$GATEWAY_PEER_PORT")
|
|
|
|
|
if [ "$native_count" -eq 1 ] && [ "$NATIVE_RELATIONSHIPS" != "$RELATIONSHIPS" ]
|
|
|
|
|
then
|
|
|
|
|
fail "the native data-gateway relationships do not match the configured HDStack layout"
|
|
|
|
|
fi
|
|
|
|
|
WORK_DIR=$(mktemp -d "$CONFIG_DIR/.data-gateway-upgrade.XXXXXX")
|
|
|
|
|
trap 'rm -rf "$WORK_DIR"' EXIT
|
|
|
|
|
PROPOSED_CONFIG="$WORK_DIR/freedmr.cfg"
|
|
|
|
|
PROPOSED_COMPOSE="$WORK_DIR/docker-compose.yml"
|
|
|
|
|
|
|
|
|
|
awk -v gateway_key="$FBP_KEY" \
|
|
|
|
|
-v gateway_port="$GATEWAY_PEER_PORT" \
|
|
|
|
|
-v gateway_target_port="$GATEWAY_BIND_PORT" '
|
|
|
|
|
-v gateway_target_port="$GATEWAY_BIND_PORT" \
|
|
|
|
|
-v deployment_version="$TARGET_DEPLOYMENT_VERSION" '
|
|
|
|
|
BEGIN {
|
|
|
|
|
print "# FREEDMR_DEPLOYMENT_VERSION=" deployment_version
|
|
|
|
|
}
|
|
|
|
|
/^# FREEDMR_DEPLOYMENT_VERSION=/ { next }
|
|
|
|
|
function finish_section() {
|
|
|
|
|
if (section == "GLOBAL" && !global_value_seen)
|
|
|
|
|
print "DATA_GATEWAY: True"
|
|
|
|
|
@ -344,7 +473,9 @@ awk -v gateway_key="$FBP_KEY" \
|
|
|
|
|
}
|
|
|
|
|
' "$FREEDMR_CONFIG" > "$PROPOSED_CONFIG"
|
|
|
|
|
|
|
|
|
|
awk -v relationships="$RELATIONSHIPS" -v aprs_call="$APRS_CALL" -v aprs_passcode="$APRS_PASSCODE" '
|
|
|
|
|
if [ "$native_count" -eq 0 ]
|
|
|
|
|
then
|
|
|
|
|
awk -v relationships="$RELATIONSHIPS" -v aprs_call="$APRS_CALL" -v aprs_passcode="$APRS_PASSCODE" '
|
|
|
|
|
function print_gateway() {
|
|
|
|
|
print " data-gateway:"
|
|
|
|
|
print " container_name: freedmr-data-gateway"
|
|
|
|
|
@ -392,6 +523,25 @@ awk -v relationships="$RELATIONSHIPS" -v aprs_call="$APRS_CALL" -v aprs_passcode
|
|
|
|
|
print
|
|
|
|
|
}
|
|
|
|
|
' "$COMPOSE_FILE" > "$PROPOSED_COMPOSE"
|
|
|
|
|
else
|
|
|
|
|
awk '
|
|
|
|
|
{
|
|
|
|
|
if (skip_legacy) {
|
|
|
|
|
if ($0 ~ /^ [A-Za-z0-9_.-]+:[[:space:]]*$/ ||
|
|
|
|
|
$0 ~ /^[^[:space:]#][^:]*:[[:space:]]*$/) {
|
|
|
|
|
skip_legacy = 0
|
|
|
|
|
} else {
|
|
|
|
|
next
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if ($0 ~ /^ D-APRS:[[:space:]]*$/) {
|
|
|
|
|
skip_legacy = 1
|
|
|
|
|
next
|
|
|
|
|
}
|
|
|
|
|
print
|
|
|
|
|
}
|
|
|
|
|
' "$COMPOSE_FILE" > "$PROPOSED_COMPOSE"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
for required in \
|
|
|
|
|
'DATA_GATEWAY: True' \
|
|
|
|
|
@ -418,6 +568,13 @@ then
|
|
|
|
|
fail "Docker Compose rejected the generated configuration"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if cmp -s "$FREEDMR_CONFIG" "$PROPOSED_CONFIG" && \
|
|
|
|
|
cmp -s "$COMPOSE_FILE" "$PROPOSED_COMPOSE"
|
|
|
|
|
then
|
|
|
|
|
echo "FreeDMR deployment is already at version $TARGET_DEPLOYMENT_VERSION; no files were changed."
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ "$DRY_RUN" -eq 1 ]
|
|
|
|
|
then
|
|
|
|
|
echo "Dry run successful; no files were changed."
|
|
|
|
|
@ -437,7 +594,7 @@ then
|
|
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
stamp=$(date -u +%Y%m%dT%H%M%SZ)
|
|
|
|
|
stamp="$(date -u +%Y%m%dT%H%M%SZ)-$$"
|
|
|
|
|
CONFIG_BACKUP="$FREEDMR_CONFIG.before-data-gateway.$stamp"
|
|
|
|
|
COMPOSE_BACKUP="$COMPOSE_FILE.before-data-gateway.$stamp"
|
|
|
|
|
[ ! -e "$CONFIG_BACKUP" ] || fail "backup already exists: $CONFIG_BACKUP"
|
|
|
|
|
@ -451,10 +608,17 @@ then
|
|
|
|
|
chown --reference="$FREEDMR_CONFIG" "$PROPOSED_CONFIG"
|
|
|
|
|
chown --reference="$COMPOSE_FILE" "$PROPOSED_COMPOSE"
|
|
|
|
|
fi
|
|
|
|
|
mv "$PROPOSED_CONFIG" "$FREEDMR_CONFIG"
|
|
|
|
|
mv "$PROPOSED_COMPOSE" "$COMPOSE_FILE"
|
|
|
|
|
if ! mv "$PROPOSED_CONFIG" "$FREEDMR_CONFIG"
|
|
|
|
|
then
|
|
|
|
|
fail "could not install the upgraded FreeDMR configuration"
|
|
|
|
|
fi
|
|
|
|
|
if ! mv "$PROPOSED_COMPOSE" "$COMPOSE_FILE"
|
|
|
|
|
then
|
|
|
|
|
cp -p "$CONFIG_BACKUP" "$FREEDMR_CONFIG"
|
|
|
|
|
fail "could not install the upgraded Compose file; the FreeDMR configuration was restored"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "FreeDMR Data Gateway migration complete."
|
|
|
|
|
echo "FreeDMR deployment upgrade to version $TARGET_DEPLOYMENT_VERSION complete."
|
|
|
|
|
echo "Backups:"
|
|
|
|
|
echo " $CONFIG_BACKUP"
|
|
|
|
|
echo " $COMPOSE_BACKUP"
|
|
|
|
|
|