#!/bin/bash set -e echo "Start Kopano container with paramater : $@" trap sig_term SIGTERM sig_term() { echo "CATCH SIGTERM" pkill -SIGTERM kopano-server pkill -SIGTERM kopano-dagent pkill -SIGTERM kopano-gateway pkill -SIGTERM kopano-ical pkill -SIGTERM kopano-monitor pkill -SIGTERM kopano-search pkill -SIGTERM kopano-spooler pkill -SIGTERM kopano-statsd /etc/init.d/saslauthd stop /usr/sbin/postfix stop /usr/sbin/apachectl stop wait exit 0 } # Make configuration. /root/packages/config.sh # Wait for service to start. while mysqladmin -h $SERVER_MYSQL_HOST -u $SERVER_MYSQL_USER status -p$SERVER_MYSQL_PASSWORD [ $? -ne 0 ] do sleep 5 done # Start services. /usr/sbin/apachectl start /usr/sbin/postfix start /etc/init.d/saslauthd start /usr/sbin/kopano-server & /usr/sbin/kopano-dagent -l & /usr/sbin/kopano-gateway & /usr/sbin/kopano-ical & /usr/sbin/kopano-monitor & /usr/sbin/kopano-search & /usr/sbin/kopano-spooler & /usr/lib/x86_64-linux-gnu/kopano/kopano-statsd & while /etc/init.d/saslauthd status [ $? -ne 0 ] do sleep 3 done saslauthd -a rimap -O 127.0.0.1 -c # Execute parameter. exec "$@" # Add first user. /root/packages/addfirstuser.sh # Infinite loop. while : ; do sleep 1 ; done