#! /bin/sh # postinst script for gforge # # see: dh_installdeb(1) set -e # set -x # Be verbose, be very verbose. # summary of how this script can be called: # * `configure' # * `abort-upgrade' # * `abort-remove' `in-favour' # # * `abort-deconfigure' `in-favour' # `removing' # # for details, see /usr/share/doc/packaging-manual/ # # quoting from the policy: # Any necessary prompting should almost always be confined to the # post-installation script, and should be protected with a conditional # so that unnecessary prompting doesn't happen if a package's # installation fails and the `postinst' is called with `abort-upgrade', # `abort-remove' or `abort-deconfigure'. . /usr/share/debconf/confmodule #DSFHELPER:replace-files# case "$1" in configure) db_stop /usr/sbin/gforge-config # Patch Slapd configuration files creation .gforge-new ones /usr/lib/gforge/bin/install-ldap.sh configure-files replace_file /etc/libnss-ldap.conf replace_file /etc/nsswitch.conf replace_file /etc/ldap/slapd.conf # Setup our LDAP err=0 if [ -f /etc/ldap/slapd.conf.gforge-old ] then /usr/lib/gforge/bin/install-ldap.sh configure || err=$? case $err in 0) exit $err ;; 1) echo "WARNING WARNING WARNING: LDAP Configuration Failed" echo "It seems the LDAP server can't be started, for some reason." echo "Please report this bug, and include the previous messages, if any." exit $err ;; 2) echo "WARNING WARNING WARNING: LDAP Configuration Failed" sf_ldap_base_dn=$(grep ^ldap_base_dn= /etc/gforge/gforge.conf | cut -d= -f2-) server_base_dn=$(eval "ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts $DEVNULL2" | grep "namingContexts:" | cut -d" " -f2) echo "It seems the LDAP base DN you provided ($sf_ldap_base_dn) is not" echo "under the base DN of your LDAP directory ($server_base_dn)." echo "Please reconfigure slapd or gforge-ldap-openldap according to what you wish to change." perl -pi -e "s/^ldap_base_dn=.*\n// /etc/gforge/gforge.conf" db_fset seen false exit $err ;; 3) echo "WARNING WARNING WARNING: LDAP Configuration Failed" sf_ldap_base_dn=$(grep ^ldap_base_dn= /etc/gforge/gforge.conf | cut -d= -f2-) needednc=$(echo $sf_ldap_base_dn | cut -d, -f2-) echo "It seems the LDAP base DN you provided ($sf_ldap_base_dn) cannot be used." echo "Please make sure the father node ($needednc) exists in your directory." perl -pi -e "s/^ldap_base_dn=.*\n// /etc/gforge/gforge.conf" db_fset gforge/shared/ldap_base_dn seen false exit $err ;; 5) echo "WARNING WARNING WARNING: LDAP Configuration Failed" sf_ldap_base_dn=$(grep ^ldap_base_dn= /etc/gforge/gforge.conf | cut -d= -f2-) echo "It seems the LDAP load failed, possibly due to a password mismatch" echo "Please check your passwords (especially /etc/ldap.secret) and try again." exit $err ;; 99) echo "WARNING WARNING WARNING: LDAP Configuration Failed" sf_ldap_base_dn=$(grep ^ldap_base_dn= /etc/gforge/gforge.conf | cut -d= -f2-) echo "It seems the LDAP load failed for some unknown reason." echo "Please submit a bug report" exit $err ;; *) echo "WARNING WARNING WARNING: LDAP Configuration Failed" echo "An unknown error happened (code $err)." echo "Please report this bug, and include the previous messages, if any." exit $err ;; esac fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument \`$1'" >&2 exit 0 ;; esac # dh_installdeb will replace this with shell code automatically # generated by other debhelper scripts. #DEBHELPER# exit 0