#!/sbin/runscript # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License, v2 or later opts="${opts} reload" [ "x${SERVERROOT}" != "x" ] && APACHE2_OPTS="${APACHE2_OPTS} -d ${SERVERROOT}" [ "x${CONFIGFILE}" != "x" ] && APACHE2_OPTS="${APACHE2_OPTS} -f ${CONFIGFILE}" [ "x${STARTUPERRORLOG}" != "x" ] && APACHE2_OPTS="${APACHE2_OPTS} -E ${STARTUPERRORLOG}" # set a default for PIDFILE/RESTARTSTYLE for those that FAILED to follow # instructiosn and update the conf.d/apache2 file. # (bug #38787) [ -z "${APACHE2_PIDFILE}" ] && APACHE2_PIDFILE=/var/run/apache2.pid [ -z "${RESTARTSTYLE}" ] && RESTARTSTYLE="graceful" apache_checkconfig() { local myconf="/etc/apache2/conf/apache2.conf" if [ "x${CONFIGFILE}" != "x" ]; then if [ ${CONFIGFILE:0:1} = "/" ]; then myconf="${CONFIGFILE}" else myconf="${SERVERROOT:-/usr/lib/apache2}/${CONFIGFILE}" fi fi if [ ! -r "${myconf}" ]; then eerror "Unable to read configuration file: ${myconf}" return 1 fi if [ -z "${APACHE2_PIDFILE}" ]; then eerror "\$APACHE2_PIDFILE is not set!" eerror "Did you etc-update /etc/conf.d/apache2?" return 1 fi if [ -z "${RESTARTSTYLE}" ]; then eerror "\$RESTARTSTYLE is not set!" eerror "Did you etc-update /etc/conf.d/apache2?" return 1 fi /usr/sbin/apache2 -t ${APACHE2_OPTS} 1>/dev/null 2>&1 ret=$? if [ $ret -ne 0 ]; then eerror "Apache2 has detected a syntax error in your configuration files:" /usr/sbin/apache2 -t ${APACHE2_OPTS} fi return $ret } depend() { need net use mysql dns logger netmount postgres ypbind after sshd } start { ebegin "Starting ldap-server" eval start-stop-daemon --start --quiet --pidfile /var/run/openldap/slapd.pid --exec /usr/lib/openldap/slapd -- -u ldap -g ldap "${SLAPD_OPTS}" eend $? ebegin "Starting slurpd" start-stop-daemon --start --quiet --exec /usr/lib/openldap/slurpd eend $? ebegin "Starting saslauthd ..." start-stop-daemon --start --quiet --exec /usr/sbin/saslauthd -- ${SASLAUTHD_OPTS} eend $? ebegin "Starting Cyrus imapd" start-stop-daemon --start --quiet --background --make-pidfile --pidfile /var/run/cyrus.pid --exec /usr/cyrus/bin/cyrusmaster eend $? apache_checkconfig || return 1 ebegin "Starting apache2" [ -f /var/log/apache2/ssl_scache ] && rm /var/log/apache2/ssl_scache [ -f /usr/lib/apache2/build/envvars ] && . /usr/lib/apache2/build/envvars env -i PATH=$PATH /sbin/start-stop-daemon --quiet \ --start --startas /usr/sbin/apache2 \ --pidfile ${APACHE2_PIDFILE} -- -k start ${APACHE2_OPTS} eend $? echo "starting postfix ..." /usr/sbin/postfix start ebegin "Starting kolab backend ..." start-stop-daemon -o --quiet --start --pidfile /var/run/kolab.pid --exec /etc/kolab/kolab eend $? # sleep 5 # if [ -f /var/run/kolab.pid ]; then # PID=`cat /var/kolab/kolab.pid | awk '{print $1}'` # KOLABS=`ps -p $PID 2>/dev/null | grep -c kolab | awk '{print $1}'` # if [ $KOLABS -gt 0 ]; then # echo "Warning: kolab is already running under pid $PID!" # else # /etc/kolab/kolab & # fi # else # /etc/kolab/kolab & # fi } stop () { echo "Stopping kolab backend ..." start-stop-daemon -o --quiet --stop --pidfile /var/run/kolab.pid eend $? ebegin "Stopping postfix" /usr/sbin/postfix stop &>/dev/null eend $? ebegin "Stopping apache2" /usr/sbin/apache2ctl stop >/dev/null start-stop-daemon -o --quiet --stop --pidfile ${APACHE2_PIDFILE} eend $? ebegin "Stopping Cyrus imapd" start-stop-daemon --stop --quiet --pidfile /var/run/cyrus.pid rm /var/run/cyrus.pid eend $? ebegin "Stopping saslauthd" start-stop-daemon --stop --quiet --pidfile /var/lib/sasl2/saslauthd.pid eend $? ebegin "Stopping ldap-server" start-stop-daemon --stop --quiet --pidfile /var/run/openldap/slapd.pid eend $? ebegin "Stopping slurpd" start-stop-daemon --stop --quiet --exec /usr/lib/openldap/slurpd eend $? ebegin "Stopping proftpd" start-stop-daemon --stop --retry 20 --quiet --pidfile /var/run/proftpd.pid eend $? } reload() { ebegin "Reloading kolab server configuration" ebegin "Stopping ldap-server" start-stop-daemon --stop --quiet --pidfile /var/run/openldap/slapd.pid eend $? ebegin "Stopping slurpd" start-stop-daemon --stop --quiet --exec /usr/lib/openldap/slurpd eend $? ebegin "Starting ldap-server" eval start-stop-daemon --start --quiet --pidfile /var/run/openldap/slapd.pid --exec /usr/lib/openldap/slapd -- -u ldap -g ldap "${SLAPD_OPTS}" eend $? ebegin "Starting slurpd" start-stop-daemon --start --quiet --exec /usr/lib/openldap/slurpd eend $? ebegin "Starting saslauthd ..." start-stop-daemon --start --quiet --exec /usr/sbin/saslauthd -- ${SASLAUTHD_OPTS} eend $? ebegin "Stopping saslauthd" start-stop-daemon --stop --quiet --pidfile /var/lib/sasl2/saslauthd.pid eend $? echo "Reload cyrus imapd ..." if [ -f /var/run/cyrus.pid ]; then kill -HUP `cat /var/run/cyrus.pid` 2>/dev/null fi ebegin "Reloading postfix" /usr/sbin/postfix reload &>/dev/null eend $? # restarting apache2 is much easier than apache1. The server handles most of the work for us. # see http://httpd.apache.org/docs-2.0/stopping.html for more details ebegin "Restarting apache2" /usr/sbin/apache2 ${APACHE2_OPTS} -k ${RESTARTSTYLE} eend $? echo "reload proftpd (if running) ..." if [ -f /var/run/proftpd.pid ]; then kill -HUP `cat /var/run/proftpd.pid` 2>/dev/null fi echo "reload kolab ..." if [ -f /var/run/kolab.pid ]; then kill -HUP `cat /var/run/kolab.pid` 2>/dev/null fi }