#!/bin/bash -e
# debian-edu-nscd-netgroup-cache
#
# 2016-23-05, workaround for bug #791562

if [ -z $1 ] ; then
  echo "usage: $0 (disable|enable)"
  exit 0
fi

# Get profile.
. /etc/debian-edu/config

# Disable/enable nscd netgroup caching.
if echo "$PROFILE" | grep -q 'Main-Server' ; then
    systemctl stop nscd.service
    sleep 1
    case "$1" in
	disable)
	    if [ -e /var/cache/nscd/netgroup ] ; then
		rm /var/cache/nscd/netgroup
	    fi
	    sed -i '/netgroup/ s=yes=no=' /etc/nscd.conf
	;;
	enable)
	    sed -i '/netgroup/ s=no=yes=' /etc/nscd.conf
	;;
    esac
    systemctl start nscd.service
fi

# Further information:  https://wiki.debian.org/DebianEdu/Status/Jessie
