#!/bin/sh
#
# Restart the daemons which might have changed the configuration
# during install

set -e

cd /etc/init.d

# Workaround for apache problem.  Somethign is killing the parent
# process but leaving the kids running.  This make it impossible to
# restart apache the normal way.  This is skolelinux
# bug #636. [pere 2004-03-18]
if kill -0 `cat /var/run/apache.pid 2>/dev/null` > /dev/null 2>&1 ; then
    :
else
    echo "warning: Failed to find apache parent process.  Killing all of them."
    pkill apache
fi

for service in \
    networking \
    sysklogd \
    ntpdate ntp-refclock \
    inetd \
    bind9 \
    slapd \
    nscd \
    dhcp3-server \
    courier-authdaemon courier-imap \
    apache \
    samba \
    squid \
    webmin \
    nfs-common nfs-kernel-server \
    autofs \
    ssh \
    mysql postgresql \
    xfs \
    nagios \
    ;
    do
  if test -x $service ; then
      echo "info: Restarting '$service'."
      # Andreas claimed that 'restart' do not work for slapd.  Use stop/start
      # instead. [pere 2002-08-28]
      ./$service stop || true
      sleep 1
      ./$service start || true
  else
      echo "warning: Not restarting '$service', as init.d script is missing."
  fi
done

exit 0
