#!/bin/sh
#
# Check that we are using ext3, not ext2

if test -r /etc/debian-edu/config ; then
    . /etc/debian-edu/config
fi

LANG=C
export LANG

awk "/ext2/ { print \"error: $0: Using ext2 on\",\$2 }" /proc/mounts
awk "/ext3|ext4/ { print \"success: $0: Using ext3 on\",\$2 }" /proc/mounts

# Make sure all ext3 mount points are online resizable
for p in `(df -Pt ext3 2>/dev/null;df -Pt ext4 2>/dev/null) | grep -v ^Filesystem |awk '{print $1}'`; do 
    if tune2fs -l $p| grep features | grep -q resize_inode ; then
	:
    else
	echo "error: $0: Missing resize_inode in ext3/ext4 fs $p"
    fi
done

# Make sure autofs do not hide the real file systems
if echo "$PROFILE" | grep -q Main-Server ; then
    if [ -d /skole/tjener/home0/lost+found ] ; then
	echo "success: $0: Found lost+found in /skole/tjener/home0/"
    else
	echo "error: $0: No lost+found in /skole/tjener/home0/.  Blocked by autofs?"
    fi
fi

# Report too full file systems.  Should have at least 10% free,
# preferably between 10% and 20%.
df -m -P -x tmpfs |
  awk '/\/dev\// { if ($3/$2 >= 0.90) print "error: Too full file system", $1, "uses", $3, "of", $2, "MiB" }'
