#!/bin/sh

echo "check for uni-klu network environment ..."
CHECK="$(nmap -p 389 143.205.64.84 | grep 389 | grep open)"
if [ -z "$CHECK" ]; then
    # no uniklu environment, revert to offline configuration
    echo "deactivating uni-klu network configuration"
    files=$(dpkg -L uniklu-config)
    for f in $files; do
        F=${f%.uniklu}
        if [ "$f" != "$F" ]; then
            if [ -f "$F.ubuntu" ]; then
                cp -p $F.ubuntu $F
            fi
        fi
    done
fi
if [ -x /etc/init.d/nscd ]; then
  /etc/init.d/nscd stop
  rm -f /var/cache/nscd/*
  /etc/init.d/nscd start
fi
