29 lines
1.2 KiB
Bash
Executable File
29 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -o pipefail -o nounset -o errexit
|
|
|
|
CONFIG_FILE="/home/offlineimap/.offlineimaprc"
|
|
|
|
if [ -n "${GMAIL_USER:-}" ]; then
|
|
echo "Using Gmail configuration mode..."
|
|
cp "/home/offlineimap/offlineimaprc.gmail.tmpl" "$CONFIG_FILE"
|
|
|
|
# Gmail IMAP server
|
|
IMAP_SRV="imap.gmail.com"
|
|
|
|
# Récupère le fingerprint SHA1 du certificat
|
|
IMAP_CERT="$(echo | (openssl s_client -connect "${IMAP_SRV}:993" 2>/dev/null || true) | openssl x509 -fingerprint -sha1 -noout | cut -d'=' -f2 | sed 's/://g')"
|
|
|
|
sed -i "s|XXX_REPLACE_USER_XXX|${GMAIL_USER}|g;s|XXX_REPLACE_PASS_XXX|${GMAIL_PASS}|g;s|XXX_REPLACE_FINGERPRINT_XXX|${IMAP_CERT:-}|g" "$CONFIG_FILE"
|
|
else
|
|
echo "Using standard IMAP configuration mode..."
|
|
cp "/home/offlineimap/offlineimaprc.imap.tmpl" "$CONFIG_FILE"
|
|
|
|
# Récupère le fingerprint SHA1 du certificat fourni par le serveur
|
|
IMAP_CERT="$(echo | (openssl s_client -connect "${IMAP_SRV}:993" 2>/dev/null || true) | openssl x509 -fingerprint -sha1 -noout | cut -d'=' -f2 | sed 's/://g')"
|
|
|
|
sed -i "s|XXX_REPLACE_USER_XXX|${IMAP_USER}|g;s|XXX_REPLACE_PASS_XXX|${IMAP_PASS}|g;s|XXX_REPLACE_SRV_XXX|${IMAP_SRV}|g;s|XXX_REPLACE_FINGERPRINT_XXX|${IMAP_CERT:-}|g" "$CONFIG_FILE"
|
|
fi
|
|
|
|
exec offlineimap -c "$CONFIG_FILE"
|