#!/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: debian-edu-hd-warn,v 1.2 2004/04/25 19:56:23 pere Exp $


# Old location for the configuration. [pere 2004-04-25]
if [ -f /etc/skolelinux/hd-warn.conf ] ; then
  mv /etc/skolelinux/hd-warn.conf /etc/debian-edu/hd-warn.conf
fi

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 +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_DE@euro")
    MESSAGE="Festplatte ist voll!"
     ;;

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

xmessage "$MESSAGE 
$MSG
"
