You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
2.0 KiB
73 lines
2.0 KiB
#!/bin/sh
|
|
|
|
CONFIG_FILE="${1:-/opt/freedmr/freedmr.cfg}"
|
|
REQUIRED_VERSION=2
|
|
UPGRADE_SCRIPT_URL='https://gitlab.hacknix.net/hacknix/FreeDMR/-/raw/master/docker-configs/upgrade-daprs-to-data-gateway.sh'
|
|
|
|
installed_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
|
|
}
|
|
' "$CONFIG_FILE" 2>/dev/null)
|
|
status=$?
|
|
|
|
if [ "$status" -ne 0 ]
|
|
then
|
|
installed_version=invalid
|
|
fi
|
|
|
|
case "$installed_version" in
|
|
''|*[!0-9]*) upgrade_required=1 ;;
|
|
*)
|
|
if [ "$installed_version" -lt "$REQUIRED_VERSION" ]
|
|
then
|
|
upgrade_required=1
|
|
else
|
|
upgrade_required=0
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
if [ "$upgrade_required" -eq 0 ]
|
|
then
|
|
exit 0
|
|
fi
|
|
|
|
cat >&2 <<EOF
|
|
FreeDMR deployment upgrade required.
|
|
Installed deployment version: $installed_version
|
|
Required deployment version: $REQUIRED_VERSION
|
|
|
|
Pulling a new container image does not update the mounted FreeDMR configuration.
|
|
Download and run the deployment upgrade script before starting this image:
|
|
curl -fsSL $UPGRADE_SCRIPT_URL -o /tmp/upgrade-daprs-to-data-gateway.sh
|
|
sudo /bin/bash /tmp/upgrade-daprs-to-data-gateway.sh --dry-run
|
|
sudo /bin/bash /tmp/upgrade-daprs-to-data-gateway.sh
|
|
|
|
For a deliberate custom deployment only, set
|
|
FREEDMR_ALLOW_UNMIGRATED_START=1 to start without applying the upgrade.
|
|
EOF
|
|
|
|
case "${FREEDMR_ALLOW_UNMIGRATED_START:-0}" in
|
|
1|true|TRUE|yes|YES)
|
|
echo 'WARNING: starting with an unverified deployment configuration because FREEDMR_ALLOW_UNMIGRATED_START is set.' >&2
|
|
exit 0
|
|
;;
|
|
esac
|
|
|
|
echo 'FreeDMR startup stopped until the deployment upgrade is applied.' >&2
|
|
exit 78
|