#!/bin/bash

# (c) m.herweg@gmx.de
# License: GPL
# Version 0.1   16.7.2003
# Version 0.2   2003-11-04 faj@bzz.no
# $Id$


if [ -f /etc/debian-edu/hd-warn.conf ] ; then 
  . /etc/debian-edu/hd-warn.conf 
fi

MSG="$( df -h | grep % | tr -d "%" | cut -c40- | tail -n +2 | while read USE MOUNT ; do 
  LIMIT=$(echo -e "$ALLOW" | grep " $MOUNT$" | awk '{ print $1 }' ) 
  if [ -z "$LIMIT" ] ; then 
    LIMIT=80
  fi
  if [ $USE -gt $LIMIT ] ; then 
    echo "${USE}% ${MOUNT}"
  fi
done)"

if [ -z "${MSG}" ] ; then 
  exit 0
fi

echo -e "${MSG}"

MESSAGE="You may not be able to login because some disk is near full!"

# no LANG here :-(
# xmessage LANG $LANG

case ${LANG} in

de_*)
    MESSAGE="Es ist mögliche, dass Sie sich nicht mehr anmelden können, da ein Laufwerk recht voll ist."
     ;;

no_*|nn_*|nb_*)
    MESSAGE="Det kan hende at du ikke klarer å logge inn fordi noen disker nesten er fulle!"
    ;;
esac

# If X is running, let a message pop up
#  -- Maximilian Wilhelm <max@skolelinux.de>  Thu, 01 Jul 2004 22:10:00 +0200
if [ "${DISPLAY}" ]; then
    xmessage "${MESSAGE}
    ${MSG}
    "
else
    echo ${MESSAGE}
fi
