Skip to content

Commit

Permalink
Added tagged-zimbra-downgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangibanelbtactic committed May 24, 2024
1 parent 20d1903 commit fc5da4d
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tools/tagged-zimbra-downgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Tagged Zimbra Downgrade

## Introduction

Have you tried to downgrade from a develop-branch build (i.e. ianw1974 builds) to a tagged build (i.e. Maldua builds) and found out that the installation abruptly ended with this message:

```
Creating server entry for mail.zimbrademo.net...already exists.
Setting Zimbra IP Mode...done.
Saving CA in ldap...failed.
```

?

Here there is an script to fix it.

## How to fix this

Make sure that Zimbra has started:
```
sudo su - zimbra -c 'zmcontrol start'
```

Download and apply the fix:
```
sudo su - zimbra
cd /tmp
wget 'https://github.com/maldua/zimbra-foss-builder/raw/main/tools/tagged-zimbra-downgrade/tagged-zimbra-downgrade.sh'
chmod +x tagged-zimbra-downgrade.sh
./tagged-zimbra-downgrade.sh
```

Say **y** to the question and press enter

Finally end the zimbra session thanks to:
```
exit
```

## Now just install/upgrade again

Use your tagged installation (i.e. Maldua installation):
```
./install.sh
```
to install/upgrade so that the installation is properly completed.
52 changes: 52 additions & 0 deletions tools/tagged-zimbra-downgrade/tagged-zimbra-downgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

LDAP_DOWNGRADE_FIX_DIR="/opt/zimbra/conf/scripts/LDAP_DOWNGRADE_FIX"

function usage {

$0

}

function fixBorkedLdap {

mkdir -p ${LDAP_DOWNGRADE_FIX_DIR}
/opt/zimbra/libexec/zmslapcat ${LDAP_DOWNGRADE_FIX_DIR}
echo 'You can ignore xxxxxxx UNKNOWN attributeDescription "ZIMBRAxxxxxxxxxxxx" inserted. messages from above.'

# Actual fix
cp ${LDAP_DOWNGRADE_FIX_DIR}/ldap.bak ${LDAP_DOWNGRADE_FIX_DIR}/ldap_TO-BE-FIXED.bak
cat ${LDAP_DOWNGRADE_FIX_DIR}/ldap_TO-BE-FIXED.bak | grep -v -E '^ZIMBRA' > ${LDAP_DOWNGRADE_FIX_DIR}/ldap.bak

# Extra dumps not actually needed
/opt/zimbra/libexec/zmslapcat -c ${LDAP_DOWNGRADE_FIX_DIR}
/opt/zimbra/libexec/zmslapcat -a ${LDAP_DOWNGRADE_FIX_DIR}

# Stop zimbra and remove old ldap database
zmcontrol stop

mv /opt/zimbra/data/ldap/mdb /opt/zimbra/data/ldap/mdb.old_LDAP_DOWNGRADE_FIX
mkdir -p /opt/zimbra/data/ldap/mdb/db

# Import sanitized ldap dump
/opt/zimbra/libexec/zmslapadd ${LDAP_DOWNGRADE_FIX_DIR}/ldap.bak
}

if [ "x$(id -u -n)" != "xzimbra" ]; then
echo "Please run as ZIMBRA user"
echo "Exiting..."
exit 1
fi

###

read -p "This will restart Zimbra. Are you sure?" -r restart_choice
if [[ $restart_choice =~ ^[Yy]$ ]] ; then
echo "Processing..."
fixBorkedLdap
echo "...Done."
echo "Now starting Zimbra..."
zmcontrol start
else
echo "Aborted by the user."
fi

0 comments on commit fc5da4d

Please sign in to comment.