1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-04-01 23:57:05 +00:00

don't compare quota fields when comparing states against older miab

This commit is contained in:
downtownallday 2024-09-07 15:29:42 -04:00
parent 97080b1c2a
commit 555acc7703
2 changed files with 26 additions and 15 deletions

View File

@ -19,16 +19,16 @@ parse_miab_version_string() {
local tmpfile
tmpfile=$(mktemp)
awk -F- '
/^v[0-9]+\./ { split($1,a,"."); print "MAJOR="substr(a[1],2); print "MINOR="a[2]; print "RELEASE="$2; next }
/^v[0-9]+\./ { split($1,a,"."); print "MAJOR="substr(a[1],2); print "MINOR="a[2]; print "RELEASE="$2; next }
$1 ~ /^v[0-9]+[a-z]$/ { print "MAJOR="substr($1,2,length($1)-2); print "MINOR="substr($1,length($1))-"a"+1; print "RELEASE="; next }
$1 ~ /^v[0-9]+[A-Z]$/ { print "MAJOR="substr($1,2,length($1)-2); print "MINOR="substr($1,length($1))-"A"+1; print "RELEASE="; next }
$1 ~ /^v[0-9]+$/ { print "MAJOR="substr($1,2); print "MINOR="; print "RELEASE="; next }
$1 ~ /^v[0-9]+$/ { print "MAJOR="substr($1,2); print "MINOR="; print "RELEASE="; next }
{ exit 1 }' >> "$tmpfile" <<< "$1"
if [ $? -ne 0 ]; then
rm -f "$tmpfile"
return 1
@ -79,7 +79,7 @@ installed_state_capture() {
echo "MAJOR=$MAJOR" >>"$info"
echo "MINOR=$MINOR" >>"$info"
echo "RELEASE=$RELEASE" >>"$info"
echo "GIT_ORIGIN='$(git remote -v | grep ^origin | grep 'fetch)$' | awk '{print $2}')'" >>"$info"
echo "MIGRATION_VERSION=$([ -e "$STORAGE_ROOT/mailinabox.version" ] && cat "$STORAGE_ROOT/mailinabox.version")" >>"$info"
echo "MIGRATION_ML_VERSION=$([ -e "$STORAGE_ROOT/mailinabox-ldap.version" ] && cat "$STORAGE_ROOT/mailinabox-ldap.version")" >>"$info"
@ -114,7 +114,7 @@ installed_state_capture() {
return 3
fi
done
return 0
}
@ -123,7 +123,7 @@ installed_state_capture() {
installed_state_compare() {
local s1="$1"
local s2="$2"
local output
local changed="false"
@ -138,13 +138,15 @@ installed_state_compare() {
RELEASE_A="${RELEASE:-0}"
PROD_A="miab"
grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_A="miabldap"
MIGRATION_ML_VERSION_A="${MIGRATION_ML_VERSION:-0}"
source "$s2/info.txt"
MAJOR_B="$MAJOR"
MINOR_B="${MINOR:-0}"
RELEASE_B="${RELEASE:-0}"
PROD_B="miab"
grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_B="miabldap"
MIGRATION_ML_VERSION_B="${MIGRATION_ML_VERSION:-0}"
cmptype="${PROD_A}2${PROD_B}"
@ -155,7 +157,7 @@ installed_state_compare() {
cp "$s1/aliases.json" "$s1/aliases-cmp.json" || changed="true"
cp "$s2/users.json" "$s2/users-cmp.json" || changed="true"
cp "$s2/aliases.json" "$s2/aliases-cmp.json" || changed="true"
if [ "$cmptype" = "miab2miabldap" ]
then
# user display names is a feature added to MiaB-LDAP that is
@ -164,7 +166,7 @@ installed_state_compare() {
# alias descriptions is a feature added to MiaB-LDAP that is
# not in MiaB
grep -v '"description":' "$s2/aliases.json" > "$s2/aliases-cmp.json" || changed="true"
grep -v '"description":' "$s2/aliases.json" > "$s2/aliases-cmp.json" || changed="true"
fi
# cmp: v0.54 to current
@ -177,8 +179,16 @@ installed_state_compare() {
# s2: re-sort aliases
jq -c ".[] | .aliases | sort_by(.address) | .[] | {address:.address, forwards_to:.forwards_to, permitted_senders:.permitted_senders, auto:.auto, description:.description}" "$s2/aliases.json" > "$s2/aliases-cmp.json"
fi
if [ $MIGRATION_ML_VERSION_A -le 2 -a $MIGRATION_ML_VERSION_B -ge 3 ]; then
# miabldap migration level <=2 does not have quota fields, so
# remove them from the comparison
grep -vE '"(quota|box_quota|box_size|percent)":' "$s2/users.json" > "$s2/users-cmp2.json" || changed="true"
cp "$s2/users-cmp2.json" "$s2/users-cmp.json" && rm -f "$s2/users-cmp2.json"
fi
#
# users
#
@ -195,7 +205,7 @@ installed_state_compare() {
#
# aliases
#
H2 "Aliases"
output="$(diff "$s1/aliases-cmp.json" "$s2/aliases-cmp.json" 2>&1)"
if [ $? -ne 0 ]; then
@ -241,13 +251,13 @@ installed_state_compare() {
# $4 == "SOA" { print $1" "$3" "$4" "$5" "$6" "$8" "$10" "$12; next } \
# { for(i=1;i<=NF;i++) if (i!=2) printf("%s ",$i); print ""; }' \
# "$s1/zones/$zone" > "$t1"
# awk '\
# $4 == "RRSIG" || $4 == "NSEC3" { next; } \
# $4 == "SOA" { print $1" "$3" "$4" "$5" "$6" "$8" "$10" "$12; next } \
# { for(i=1;i<=NF;i++) if (i!=2) printf("%s ",$i); print ""; }' \
# "$s2/zones/$zone" > "$t2"
# output="$(diff "$t1" "$t2" 2>&1)"
# if [ $? -ne 0 ]; then
# echo "CHANGED zone: $zone"

View File

@ -64,7 +64,7 @@ export UPSTREAM_TAG="${UPSTREAM_TAG:-}"
# For setup scripts that install miabldap releases (eg. upgrade tests)
export MIABLDAP_GIT="${MIABLDAP_GIT:-https://github.com/downtownallday/mailinabox-ldap.git}"
export MIABLDAP_RELEASE_TAG="${MIABLDAP_RELEASE_TAG:-v60}"
export MIABLDAP_RELEASE_TAG="${MIABLDAP_RELEASE_TAG:-v70}"
# When running tests that require php, use this version of php. This
# should be the same as what's in setup/functions.sh.
@ -73,3 +73,4 @@ export PHP_VER=8.0
# Tag of last version supported on Ubuntu Bionic 18.04
UPSTREAM_FINAL_RELEASE_TAG_BIONIC64=v57a
MIABLDAP_FINAL_RELEASE_TAG_BIONIC64=f6cd8f56c3bcb20969c6cf66c040c8efa3773f3a
MIABLDAP_INITIAL_RELEASE_TAG_JAMMY64=v60