port-check.sh 397 B

123456789101112131415161718
  1. #!/bin/bash
  2. . mailcow.conf
  3. for port in ${SMTP_PORT} ${SMTPS_PORT} ${SUBMISSION_PORT} ${IMAP_PORT} ${IMAPS_PORT} ${POP_PORT} ${POPS_PORT} ${SIEVE_PORT} 443; do
  4. if [[ ! -z $(ss -tlnp "( sport = :$port )" 2> /dev/null | grep LISTEN | grep -vi docker) ]]; then
  5. echo "Port $port is in use by other process."
  6. err=1
  7. fi
  8. done
  9. if [[ ${err} == "1" ]]; then
  10. echo
  11. echo "Exiting."
  12. exit 1
  13. fi
  14. exit 0