mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 10:13:58 +00:00
44 lines
1.1 KiB
Bash
Executable File
44 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# KNOE_HOME should be set by the caller
|
|
KNOE_CONF_DIR="${KNOE_HOME:-$HOME/.knoe}/conf"
|
|
mkdir -p "$KNOE_CONF_DIR"
|
|
VERSION_FILE="$KNOE_CONF_DIR/database_versions.json"
|
|
|
|
echo "Fetching latest database versions..."
|
|
|
|
# Fetch latest PG version from Docker Hub (best effort)
|
|
get_latest_pg() {
|
|
curl -s https://registry.hub.docker.com/v2/repositories/library/postgres/tags?page_size=100 | \
|
|
grep -o '"name": *"[0-9][0-9]*"' | cut -d'"' -f4 | sort -ur | head -n 1 || echo "17"
|
|
}
|
|
|
|
PG_LATEST=$(get_latest_pg)
|
|
PG_CURRENT=$((PG_LATEST - 1))
|
|
PG_STABLE=$((PG_LATEST - 2))
|
|
|
|
# For Percona, let's use similar logic or defaults
|
|
PERCONA_LATEST="$PG_LATEST"
|
|
PERCONA_CURRENT="$PG_CURRENT"
|
|
PERCONA_STABLE="$PG_STABLE"
|
|
PERCONA_18="18"
|
|
|
|
cat <<EOF > "$VERSION_FILE"
|
|
{
|
|
"postgresql": {
|
|
"stable": "$PG_STABLE",
|
|
"current": "$PG_CURRENT",
|
|
"latest": "$PG_LATEST"
|
|
},
|
|
"percona": {
|
|
"stable": "$PERCONA_STABLE",
|
|
"current": "$PERCONA_CURRENT",
|
|
"latest": "$PERCONA_LATEST",
|
|
"v18": "$PERCONA_18"
|
|
}
|
|
}
|
|
EOF
|
|
|
|
echo "Database versions updated in $VERSION_FILE"
|