Code

- Added triggers
[gosa.git] / gosa-core / debian / gosa.postinst
index ae1081d9382b71442a7c5841902027606b9ef640..8aa3db73fb2be2ce4716e1d26f01a754a77a6501 100644 (file)
@@ -12,6 +12,11 @@ case "$1" in
   abort-upgrade|abort-remove|abort-deconfigure)
       ;;
 
+  triggered)
+      /usr/sbin/update-gosa
+      exit 0
+      ;;
+
   *)
       echo "postinst called with unknown argument \`$1'" >&2
       exit 1
@@ -30,20 +35,60 @@ if [ ! -f /etc/gosa/gosa.secrets ]; then
     chmod 600 /etc/gosa/gosa.secrets
 fi
 
-# Copy GOsa configuration to conf.d directories
-if [ ! -L /etc/apache2/conf.d/gosa.conf ]; then
+if [ -d /etc/apache2/conf.d ]; then
+
+  # Copy GOsa configuration to conf.d directories
+  if [ ! -L /etc/apache2/conf.d/gosa.conf ]; then
 
-  # Remove old instances of this file
-  if [ -f /etc/apache2/conf.d/gosa.conf ]; then
-    echo "Found old gosa apache configuration in /etc/apache2/conf.d - moving it to gosa.conf.orig..."
-    echo "Please check for changes in /etc/gosa/gosa-apache.conf if you modified this file!"
-    mv /etc/apache2/conf.d/gosa.conf /etc/apache2/conf.d/gosa.conf.orig
+    # Remove old instances of this file
+    if [ -f /etc/apache2/conf.d/gosa.conf ]; then
+      echo "Found old gosa apache configuration in /etc/apache2/conf.d - moving it to gosa.conf.orig..."
+      echo "Please check for changes in /etc/gosa/gosa-apache.conf if you modified this file!"
+      mv /etc/apache2/conf.d/gosa.conf /etc/apache2/conf.d/gosa.conf.orig
+    fi
+
+    echo "Making /gosa available in /etc/apache2/conf.d"
+
+    # Add GOsa include file
+    ln -s /etc/gosa/gosa-apache.conf /etc/apache2/conf.d/gosa.conf
+  fi
+  
+  # Add support for RequestHeader
+  a2enmod headers
+
+  # Finally restart servers
+  if [ -x /usr/sbin/invoke-rc.d ]; then
+    invoke-rc.d apache2 reload
+  else
+    /etc/init.d/apache2 reload
   fi
+fi
+
+if [ -d /etc/lighttpd/conf-available ]; then
+
+  # Copy GOsa configuration to conf-available directories /etc/lighttpd/conf-available
+  if [ ! -L /etc/lighttpd/conf-enabled/99gosa-lighttpd.conf ]; then
 
-  echo "Making /gosa available in /etc/apache2/conf.d"
+    # Remove old instances of this file
+    if [ -f /etc/lighttpd/conf-enabled/99gosa-lighttpd.conf ]; then
+      echo "Found old gosa apache configuration in /etc/lighttpd/conf-enabled - moving it to orig.gosa-lighttpd.conf ..."
+      echo "Please check for changes in /etc/lighttpd/conf-available/orig.99gosa-lighttpd.conf if you modified this file!"
+      mv /etc/lighttpd/conf-enabled/99gosa-lighttpd.conf /etc/lighttpd/conf-available/orig.gosa-lighttpd.conf
+    fi
+
+    echo "Making /gosa available in /etc/lighttpd/conf-enabled/"
+
+    # Add GOsa include file
+    ln -s /etc/gosa/gosa-lighttpd.conf /etc/lighttpd/conf-enabled/99gosa-lighttpd.conf
+  fi
+
+  # Finally restart servers
+  if [ -x /usr/sbin/invoke-rc.d ]; then
+    invoke-rc.d lighttpd reload
+  else
+    /etc/init.d/lighttpd reload
+  fi
 
-  # Add GOsa include file
-  ln -s /etc/gosa/gosa-apache.conf /etc/apache2/conf.d/gosa.conf
 fi
 
 # Add links for safe mode
@@ -61,17 +106,30 @@ chmod 770 -R /var/spool/gosa
 chown root.$WEBGROUP -R /var/cache/gosa
 chmod 770 -R /var/cache/gosa
 
-# Add support for RequestHeader
-a2enmod headers
-
-update-gosa
-
-# Finally restart servers
-if [ -x /usr/sbin/invoke-rc.d ]; then
-  invoke-rc.d apache2 reload
-else
-  /etc/init.d/apache2 reload
+# Activating triggers
+echo DEBUG: triggertest postinst called, $# args: "$@"
+
+if [ "$1" = "configure" ]; then
+  # in the general case, update-foo and update-bar should always be called
+  # when the central package is updated
+  update-gosa
+
+elif [ "$1" = "triggered" ]; then
+  # since the example ships two triggers, we should determine how to act
+  # based on which trigger was activated.
+  for triggername in $2; do
+    echo DEBUG: processing trigger "'$triggername'"
+    case "$triggername" in
+    "/usr/share/gosa")
+      update-gosa
+      ;;
+    *)
+      echo "unhandled/unknown trigger!"
+      exit 1
+      ;;
+    esac
+  done
 fi
 
-exit 0
 
+exit 0