feat: migrate releases to git.awaioi.com
This commit is contained in:
@@ -8,6 +8,44 @@ CONFIG_FILE="${ERP_CONFIG_FILE:-$INSTALL_ROOT/config/erp.env}"
|
||||
say() { printf '[ERP] %s\n' "$*"; }
|
||||
fail() { printf '[ERP] ERROR: %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
migrate_legacy_update_source() {
|
||||
local legacy_url='http://38.76.196.225:10099'
|
||||
local official_url='https://git.awaioi.com'
|
||||
local configured_url="${OA_UPDATE_GITEA_BASE_URL:-}"
|
||||
[[ "${configured_url%/}" == "$legacy_url" ]] || return 0
|
||||
|
||||
local temporary
|
||||
temporary="$(mktemp "${CONFIG_FILE}.migration.XXXXXX")" \
|
||||
|| fail 'unable to create the update-source migration file'
|
||||
if awk -v official_url="$official_url" '
|
||||
BEGIN { base_url_written = 0; insecure_written = 0 }
|
||||
/^OA_UPDATE_GITEA_BASE_URL=/ {
|
||||
if (!base_url_written) print "OA_UPDATE_GITEA_BASE_URL=\047" official_url "\047"
|
||||
base_url_written = 1
|
||||
next
|
||||
}
|
||||
/^OA_UPDATE_ALLOW_INSECURE_HTTP=/ {
|
||||
if (!insecure_written) print "OA_UPDATE_ALLOW_INSECURE_HTTP=\047false\047"
|
||||
insecure_written = 1
|
||||
next
|
||||
}
|
||||
{ print }
|
||||
END {
|
||||
if (!base_url_written) print "OA_UPDATE_GITEA_BASE_URL=\047" official_url "\047"
|
||||
if (!insecure_written) print "OA_UPDATE_ALLOW_INSECURE_HTTP=\047false\047"
|
||||
}
|
||||
' "$CONFIG_FILE" > "$temporary" && chmod 600 "$temporary" && mv -f "$temporary" "$CONFIG_FILE"; then
|
||||
say "Update source migrated to $official_url"
|
||||
else
|
||||
rm -f "$temporary"
|
||||
say "WARNING: could not persist the update source migration; using $official_url for this process"
|
||||
fi
|
||||
|
||||
OA_UPDATE_GITEA_BASE_URL="$official_url"
|
||||
OA_UPDATE_ALLOW_INSECURE_HTTP=false
|
||||
export OA_UPDATE_GITEA_BASE_URL OA_UPDATE_ALLOW_INSECURE_HTTP
|
||||
}
|
||||
|
||||
load_configuration() {
|
||||
[[ -r "$CONFIG_FILE" ]] || fail "configuration not readable: $CONFIG_FILE"
|
||||
set -a
|
||||
@@ -15,6 +53,7 @@ load_configuration() {
|
||||
# shellcheck disable=SC1090
|
||||
source "$CONFIG_FILE"
|
||||
set +a
|
||||
migrate_legacy_update_source
|
||||
|
||||
RUN_DIR="${ERP_RUN_DIR:-$INSTALL_ROOT/run}"
|
||||
JAR_PATH="${ERP_JAR_PATH:-$INSTALL_ROOT/current/app/kaidi-erp.jar}"
|
||||
|
||||
Reference in New Issue
Block a user