Deploy scripts: compose version check, ovpmon_backup.db in native backups
Docker: variant B needs Docker Compose 2.17+ (additional_contexts); install.sh and update.sh check it in the preflight. Native: backup.sh, update.sh, restore.sh and --rollback now copy and restore ovpmon_backup.db (Backup and Restore settings) as an optional file. Verified install, update, backup, restore and rollback on Debian 12 (systemd), Alpine 3.23 (OpenRC) and both container variants. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f8cdcd0fc6
commit
3fac8d70d8
11 files changed
+178
-7
No files matched your search
@@ -59,6 +59,7 @@ trap 'exit 143' TERM
|
||||
# ---------------------------------------------------------------------------------------------
|
||||
phase 0 "preflight"
|
||||
need_docker
|
||||
need_compose_version
|
||||
log "docker compose command: $DC_BIN; variant $VARIANT; project $PROJECT"
|
||||
check_other_variant_stopped
|
||||
check_name_clash
|
||||
|
||||
@@ -63,6 +63,45 @@ need_docker() {
|
||||
fi
|
||||
}
|
||||
|
||||
# Variant B (docker-compose.yml) uses additional_contexts: Docker Compose v2.17.0 or newer
|
||||
MIN_COMPOSE_VERSION="2.17.0"
|
||||
|
||||
# version_ge FOUND REQUIRED: pure comparison of MAJOR.MINOR[.PATCH] versions, no docker involved.
|
||||
# A leading 'v' and any suffix after the numbers (-desktop.1, +build, -rc1) are ignored.
|
||||
# Returns 0 if FOUND >= REQUIRED, 1 if FOUND < REQUIRED, 2 if either value cannot be parsed.
|
||||
version_ge() {
|
||||
local f r fa fb fc ra rb rc
|
||||
f=$(printf '%s' "$1" | sed -n 's/^[vV]\{0,1\}\([0-9][0-9]*\)\.\([0-9][0-9]*\)\(\.\([0-9][0-9]*\)\)\{0,1\}.*$/\1 \2 \4/p')
|
||||
r=$(printf '%s' "$2" | sed -n 's/^[vV]\{0,1\}\([0-9][0-9]*\)\.\([0-9][0-9]*\)\(\.\([0-9][0-9]*\)\)\{0,1\}.*$/\1 \2 \4/p')
|
||||
[ -n "$f" ] && [ -n "$r" ] || return 2
|
||||
set -- $f; fa=$1; fb=$2; fc=${3:-0}
|
||||
set -- $r; ra=$1; rb=$2; rc=${3:-0}
|
||||
[ "$fa" -gt "$ra" ] && return 0
|
||||
[ "$fa" -lt "$ra" ] && return 1
|
||||
[ "$fb" -gt "$rb" ] && return 0
|
||||
[ "$fb" -lt "$rb" ] && return 1
|
||||
[ "$fc" -ge "$rc" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
# need_compose_version: variant B needs Docker Compose v2.17+ (additional_contexts). Variant A works
|
||||
# with any compose. Call after need_docker (DC_BIN) and set_variant (VARIANT).
|
||||
need_compose_version() {
|
||||
local v rc
|
||||
[ "$VARIANT" = b ] || return 0
|
||||
if [ "$DC_BIN" != "docker compose" ]; then
|
||||
die "variant B needs the Docker Compose plugin v$MIN_COMPOSE_VERSION or newer ('docker compose', the build uses additional_contexts), but only the legacy 'docker-compose' (v1) was found. Install the plugin (docker-compose-plugin package, see https://docs.docker.com/compose/install/) or use variant A (--variant a), which works with any compose"
|
||||
fi
|
||||
v=$(docker compose version --short 2>/dev/null | head -n 1 || true)
|
||||
rc=0
|
||||
version_ge "$v" "$MIN_COMPOSE_VERSION" || rc=$?
|
||||
case "$rc" in
|
||||
0) log "docker compose version $v (required for variant B: $MIN_COMPOSE_VERSION or newer)" ;;
|
||||
1) die "variant B needs Docker Compose v$MIN_COMPOSE_VERSION or newer (the build uses additional_contexts), found v${v#v}. Update the Docker Compose plugin (docker-compose-plugin package, see https://docs.docker.com/compose/install/) or use variant A (--variant a), which works with any compose" ;;
|
||||
*) warn "cannot parse the docker compose version ('$v'); variant B needs v$MIN_COMPOSE_VERSION or newer, continuing without the check" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# set_variant a|b: compose file, service and container names of the variant
|
||||
set_variant() {
|
||||
case "$1" in
|
||||
|
||||
@@ -157,6 +157,7 @@ main() {
|
||||
CURRENT_PHASE="0 preflight"
|
||||
phase 0 "preflight"
|
||||
log "variant $VARIANT, project $PROJECT, compose file $(basename "$COMPOSE_FILE"), docker compose command: $DC_BIN"
|
||||
need_compose_version
|
||||
check_env_file
|
||||
dc config -q || die "the compose configuration is invalid (see the message above)"
|
||||
check_other_variant_stopped
|
||||
|
||||
Reference in new issue
Block a user