toolkit/func/core/pkg_dovecot/11-imap-test.sh
2021-07-04 23:50:25 -07:00

31 lines
704 B
Bash
Executable file

#!/bin/bash
r_log "dovecot" "Testing basic IMAP"
# Note that nmap-nc appears to be the default, even in fedora
NC_OPTS="-w 5 -d 3"
r_log "dovecot" "Add imapper user and maildir"
if ! id imapper > /dev/null 2>&1; then
useradd imapper
echo imaptest | passwd --stdin imapper
fi
# shellcheck disable=SC2174
mkdir -m 700 -p /home/imapper/mail/.imap/INBOX
chown -R imapper:imapper /home/imapper/mail
r_log "dovecot" "Test basic IMAP login"
# shellcheck disable=SC2086
echo -e "01 LOGIN imapper imaptest\n" | nc ${NC_OPTS} localhost 143 | grep -q "Logged in."
ret_val=$?
if [ "$ret_val" -ne 0 ]; then
tail /var/log/secure
tail /var/log/maillog
fi
r_checkExitStatus $ret_val
userdel -rf imapper