quotamail.in 1.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
#!/bin/sh

# Found on the internet, and customized for Emulab

#
# This script must run as root on ops, and should be run from cron daily, 
# with an entry in /etc/crontab (on ops) something like this:
# 
# 0   6   *   *   *   root   /usr/testbed/sbin/quotamail
#
# Some sites may wish to change the CC to a different list, or 
# possibly even remove it all together.
#
14 15 16
# Note that if FS_NODE != USERNODE, having a user check their quota won't
# work unless the rpc.rquotad(8) daemon is running on FS_NODE.  Our fs node
# installation script/directions should take care of this now.
17 18
#

19 20 21 22 23 24 25 26 27 28
PROJSTR="Project directory:    @FSDIR_PROJ@"
GROUPSSTR="Group directory:      @FSDIR_GROUPS@"
USERSSTR="User/Home directory:  @FSDIR_USERS@"
if [ -n "@FSDIR_SCRATCH@" ]; then
    SCRATCHSTR="Project scratch directory: @FSDIR_SCRATCH@"
else
    SCRATCHSTR=""
fi


29
for i in `/usr/sbin/repquota -v @FS_WITH_QUOTAS@ | awk '$2 ~ /\+/ {print $1}'`
30 31 32 33 34 35
do
(
# feel free to change this message!!!
cat << MESSAGE
From: Testbed Operations <@TBOPSEMAIL_NOSLASH@>
To: $i@@OURDOMAIN@
36
Bcc: @TBAUTOMAILEMAIL_NOSLASH@
37 38 39 40 41 42 43 44 45 46
Subject: over disk quota at @THISHOMEBASE@

Hello,

It looks like your disk usage has exceeded your disk quota. Please move or
remove some files to get below your quota. Disk space is limited, so if
you could clean up your directory it would be appreciated.

You can check your usage with the 'quota' command on @USERNODE@:

47
@USERNODE@> quota -v -l
48 49
`quota -v -l $i`

50 51
(Note: This will not work from nodes in an experiment.)

52 53
The directory trees (on @USERNODE@) where you most likely have files are:

54 55 56 57
$PROJSTR
$GROUPSSTR
$USERSSTR
$SCRATCHSTR
58

59 60 61 62
PLEASE NOTE: just login to @USERNODE@ directly to do the cleanup!
You will not be able to swapin an experiment to access these directories
while over quota.

63 64 65 66 67 68 69 70
Thanks,
@THISHOMEBASE@ Testbed Operations
@TBOPSEMAIL_NOSLASH@

MESSAGE
) | /usr/sbin/sendmail -t
done