mailcow/port-check.sh

21 lines
483 B
Bash
Raw Normal View History

2016-12-12 16:26:08 +08:00
#!/bin/bash
. mailcow.conf
2016-12-13 04:53:58 +08:00
if [[ -z $(which ss) ]]; then echo "Please install the ss util first."; exit 1; fi
2016-12-12 16:26:08 +08:00
for port in ${SMTP_PORT} ${SMTPS_PORT} ${SUBMISSION_PORT} ${IMAP_PORT} ${IMAPS_PORT} ${POP_PORT} ${POPS_PORT} ${SIEVE_PORT} 443; do
if [[ ! -z $(ss -tlnp "( sport = :$port )" 2> /dev/null | grep LISTEN | grep -vi docker) ]]; then
2016-12-13 04:53:58 +08:00
echo "Port $port is in use by another process."
2016-12-12 16:26:08 +08:00
err=1
fi
done
if [[ ${err} == "1" ]]; then
echo
echo "Exiting."
exit 1
fi
exit 0