Created
January 25, 2020 20:59
-
-
Save raoulbhatia/03f6a39ba6e8ea95329f04873efc5c87 to your computer and use it in GitHub Desktop.
Unzip Dovecot emails crypted using zlib plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Unzip /var/vmail | |
find /var/vmail/ -type f -regextype egrep -regex '.*S=.*W=.*' | while read -r file; do | |
if [[ $(head -c11 "$file") == "Dovecot-LZ4" ]]; then | |
doveadm fs get compress lz4:0:posix:prefix=/ \ | |
"$file" > "/tmp/$(basename "$file")" | |
if [[ -s "/tmp/$(basename "$file")" ]]; then | |
chmod 600 "/tmp/$(basename "$file")" | |
chown 5000:5000 "/tmp/$(basename "$file")" | |
mv "/tmp/$(basename "$file")" "$file" | |
else | |
rm "/tmp/$(basename "$file")" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment