mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-10 01:17:19 +00:00
Make installed state comparisons ignore new user and alias attributes when comparing MiaB to MiaB-LDAP
This commit is contained in:
parent
5eb008cae9
commit
07d83d1e5c
@ -25,6 +25,7 @@ installed_state_capture() {
|
|||||||
H2 "create info.txt"
|
H2 "create info.txt"
|
||||||
echo "STATE_VERSION=1" > "$info"
|
echo "STATE_VERSION=1" > "$info"
|
||||||
echo "GIT_VERSION='$(git describe --abbrev=0)'" >>"$info"
|
echo "GIT_VERSION='$(git describe --abbrev=0)'" >>"$info"
|
||||||
|
echo "GIT_ORIGIN='$(git remote -v | grep ^origin | grep 'fetch)$' | awk '{print $2}')'" >>"$info"
|
||||||
echo "MIGRATION_VERSION=$(cat "$STORAGE_ROOT/mailinabox.version")" >>"$info"
|
echo "MIGRATION_VERSION=$(cat "$STORAGE_ROOT/mailinabox.version")" >>"$info"
|
||||||
|
|
||||||
# record users
|
# record users
|
||||||
@ -43,8 +44,7 @@ installed_state_capture() {
|
|||||||
echo "Unable to get aliases: rc=$? err=$REST_ERROR" 1>&2
|
echo "Unable to get aliases: rc=$? err=$REST_ERROR" 1>&2
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
# ignore/exclude the alias description field
|
echo "$REST_OUTPUT" > "$state_dir/aliases.json"
|
||||||
echo "$REST_OUTPUT" | grep -v '"description":' > "$state_dir/aliases.json"
|
|
||||||
|
|
||||||
# record dns config
|
# record dns config
|
||||||
H2 "record dns details"
|
H2 "record dns details"
|
||||||
@ -71,9 +71,46 @@ installed_state_compare() {
|
|||||||
local changed="false"
|
local changed="false"
|
||||||
|
|
||||||
H1 "COMPARE STATES: $(basename "$s1") VS $(basename "$2")"
|
H1 "COMPARE STATES: $(basename "$s1") VS $(basename "$2")"
|
||||||
H2 "Users"
|
|
||||||
|
#
|
||||||
|
# determine compare type id (incorporating repo, branch, version, etc)
|
||||||
|
#
|
||||||
|
local compare_type="all"
|
||||||
|
|
||||||
|
source "$s2/info.txt"
|
||||||
|
if grep "mailinabox-ldap.git" <<<"$GIT_ORIGIN" >/dev/null; then
|
||||||
|
GIT_ORIGIN=""
|
||||||
|
source "$s1/info.txt"
|
||||||
|
if ! grep "mailinabox-ldap.git" <<<"$GIT_ORIGIN" >/dev/null; then
|
||||||
|
compare_type="miab2miab-ldap"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "Compare type: $compare_type"
|
||||||
|
|
||||||
|
#
|
||||||
|
# filter data for compare type
|
||||||
|
#
|
||||||
|
cp "$s1/users.json" "$s1/users-cmp.json" || changed="true"
|
||||||
|
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 [ "$compare_type" == "miab2miab-ldap" ]
|
||||||
|
then
|
||||||
|
# user display names is a feature added to MiaB-LDAP that is
|
||||||
|
# not in MiaB
|
||||||
|
grep -v '"display_name":' "$s2/users.json" > "$s2/users-cmp.json" || changed="true"
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
# users
|
# users
|
||||||
output="$(diff "$s1/users.json" "$s2/users.json" 2>&1)"
|
#
|
||||||
|
H2 "Users"
|
||||||
|
output="$(diff "$s1/users-cmp.json" "$s2/users-cmp.json" 2>&1)"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
changed="true"
|
changed="true"
|
||||||
echo "USERS ARE DIFFERENT!"
|
echo "USERS ARE DIFFERENT!"
|
||||||
@ -82,8 +119,11 @@ installed_state_compare() {
|
|||||||
echo "No change"
|
echo "No change"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#
|
||||||
|
# aliases
|
||||||
|
#
|
||||||
H2 "Aliases"
|
H2 "Aliases"
|
||||||
output="$(diff "$s1/aliases.json" "$s2/aliases.json" 2>&1)"
|
output="$(diff "$s1/aliases-cmp.json" "$s2/aliases-cmp.json" 2>&1)"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
changed="true"
|
changed="true"
|
||||||
echo "ALIASES ARE DIFFERENT!"
|
echo "ALIASES ARE DIFFERENT!"
|
||||||
|
@ -39,7 +39,7 @@ init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
upstream_install() {
|
upstream_install() {
|
||||||
local upstream_dir="$HOME/mailinabox-upstream"
|
local upstream_dir="$1"
|
||||||
H1 "INSTALL UPSTREAM"
|
H1 "INSTALL UPSTREAM"
|
||||||
[ ! -x /usr/bin/git ] && apt-get install -y -qq git
|
[ ! -x /usr/bin/git ] && apt-get install -y -qq git
|
||||||
|
|
||||||
@ -132,14 +132,17 @@ then
|
|||||||
echo "Warning: MiaB-LDAP is already installed! Skipping installation of upstream"
|
echo "Warning: MiaB-LDAP is already installed! Skipping installation of upstream"
|
||||||
else
|
else
|
||||||
# install upstream
|
# install upstream
|
||||||
upstream_install
|
upstream_dir="$HOME/mailinabox-upstream"
|
||||||
|
upstream_install "$upstream_dir"
|
||||||
. /etc/mailinabox.conf
|
. /etc/mailinabox.conf
|
||||||
|
|
||||||
# populate some data
|
# populate some data
|
||||||
populate_by_name "${1:-basic}"
|
populate_by_name "${1:-basic}"
|
||||||
|
|
||||||
# capture upstream state
|
# capture upstream state
|
||||||
|
pushd "$upstream_dir" >/dev/null
|
||||||
installed_state_capture "/tmp/state/upstream"
|
installed_state_capture "/tmp/state/upstream"
|
||||||
|
popd >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# install miab-ldap and capture state
|
# install miab-ldap and capture state
|
||||||
|
Loading…
Reference in New Issue
Block a user