1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-07-07 23:50:55 +00:00

fix comparing states on upgrade

This commit is contained in:
downtownallday 2025-03-23 18:25:12 -04:00
parent 6ff983e8c3
commit 4712704fe0

View File

@ -138,6 +138,7 @@ installed_state_compare() {
RELEASE_A="${RELEASE:-0}" RELEASE_A="${RELEASE:-0}"
PROD_A="miab" PROD_A="miab"
grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_A="miabldap" grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_A="miabldap"
MIGRATION_VERSION_A="${MIGRATION_VERSION:-0}"
MIGRATION_ML_VERSION_A="${MIGRATION_ML_VERSION:-0}" MIGRATION_ML_VERSION_A="${MIGRATION_ML_VERSION:-0}"
source "$s2/info.txt" source "$s2/info.txt"
@ -146,6 +147,7 @@ installed_state_compare() {
RELEASE_B="${RELEASE:-0}" RELEASE_B="${RELEASE:-0}"
PROD_B="miab" PROD_B="miab"
grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_B="miabldap" grep "mailinabox-ldap" <<<"$GIT_ORIGIN" >/dev/null && PROD_B="miabldap"
MIGRATION_VERSION_B="${MIGRATION_VERSION:-0}"
MIGRATION_ML_VERSION_B="${MIGRATION_ML_VERSION:-0}" MIGRATION_ML_VERSION_B="${MIGRATION_ML_VERSION:-0}"
cmptype="${PROD_A}2${PROD_B}" cmptype="${PROD_A}2${PROD_B}"
@ -178,14 +180,17 @@ installed_state_compare() {
# s2: re-sort aliases # 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" 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 # before quota support to one with it
# miabldap migration level <=2 does not have quota fields, so if [ "$cmptype" = "miabldap2miabldap" -a $MIGRATION_ML_VERSION_A -le 2 -a $MIGRATION_ML_VERSION_B -ge 3
# remove them from the comparison -o "$cmdtype" = "miab2miabldap" -a $MIGRATION_VERSION_A -lt 15 -a $MIGRATION_ML_VERSION_B -ge 3 ]; then
# miabldap migration level <=2 does not have quota fields
# miab migration level <15 does not have quota fields
# ... remove them from the comparison
grep -vE '"(quota|box_quota|box_size|percent)":' "$s2/users-cmp.json" > "$s2/users-cmp2.json" || changed="true" grep -vE '"(quota|box_quota|box_size|percent)":' "$s2/users-cmp.json" > "$s2/users-cmp2.json" || changed="true"
cp "$s2/users-cmp2.json" "$s2/users-cmp.json" && rm -f "$s2/users-cmp2.json" cp "$s2/users-cmp2.json" "$s2/users-cmp.json" && rm -f "$s2/users-cmp2.json"
fi fi
fi
# #