mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-10 01:17:19 +00:00
Fix the installed state version parsing logic
This commit is contained in:
parent
1622b326d5
commit
65a393cb3f
@ -6,6 +6,29 @@
|
|||||||
# installations to a subsequent MiaB-LDAP upgrade
|
# installations to a subsequent MiaB-LDAP upgrade
|
||||||
#
|
#
|
||||||
|
|
||||||
|
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]+[a-z]$/ { print "MAJOR="substr($1,2,length($1)-2); print "MINOR="substr($1,length($1))-"a"+1; print "RELEASE="; next }
|
||||||
|
|
||||||
|
/^v[0-9]+[A-Z]$/ { print "MAJOR="substr($1,2,length($1)-2); print "MINOR="substr($1,length($1))-"A"+1; print "RELEASE="; next }
|
||||||
|
|
||||||
|
/^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
|
||||||
|
fi
|
||||||
|
source "$tmpfile"
|
||||||
|
rm -f "$tmpfile"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
installed_state_capture() {
|
installed_state_capture() {
|
||||||
# users and aliases
|
# users and aliases
|
||||||
@ -29,8 +52,18 @@ installed_state_capture() {
|
|||||||
fi
|
fi
|
||||||
H2 "create info.txt"
|
H2 "create info.txt"
|
||||||
echo "STATE_VERSION=1" > "$info"
|
echo "STATE_VERSION=1" > "$info"
|
||||||
echo "GIT_VERSION='$(git describe)'" >>"$info"
|
local gitver=$(git describe)
|
||||||
git describe | awk -F- '{ split($1,a,"."); print "MAJOR="substr(a[1],2); print "MINOR="a[2]; print "RELEASE="$2 }' >>"$info"
|
echo "GIT_VERSION='$gitver'" >>"$info"
|
||||||
|
|
||||||
|
parse_miab_version_string "$gitver"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Unable to parse version string: $gitver"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
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 "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_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"
|
echo "MIGRATION_ML_VERSION=$([ -e "$STORAGE_ROOT/mailinabox-ldap.version" ] && cat "$STORAGE_ROOT/mailinabox-ldap.version")" >>"$info"
|
||||||
@ -85,14 +118,14 @@ installed_state_compare() {
|
|||||||
#
|
#
|
||||||
source "$s1/info.txt"
|
source "$s1/info.txt"
|
||||||
MAJOR_A="$MAJOR"
|
MAJOR_A="$MAJOR"
|
||||||
MINOR_A="$MINOR"
|
MINOR_A="${MINOR:-0}"
|
||||||
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"
|
||||||
|
|
||||||
source "$s2/info.txt"
|
source "$s2/info.txt"
|
||||||
MAJOR_B="$MAJOR"
|
MAJOR_B="$MAJOR"
|
||||||
MINOR_B="$MINOR"
|
MINOR_B="${MINOR:-0}"
|
||||||
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"
|
||||||
|
Loading…
Reference in New Issue
Block a user