quotamail.in 2.81 KB
Newer Older
1
#!/bin/sh
2
#
3
# Copyright (c) 2003-2014 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23
#
24 25 26 27 28 29 30 31 32 33 34
# 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.
#
35 36 37
# 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.
38 39
#

40 41 42 43 44 45 46 47 48
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

49 50 51 52 53 54
MAINSITE=@TBMAINSITE@
if [ $MAINSITE -ne 0 ]; then
    QUOTAHELP="See https://wiki.emulab.net/wikidocs/wiki/kb81 for more info on quotas."
else
    QUOTAHELP=""
fi
55

56
for i in `/usr/sbin/repquota -v @FS_WITH_QUOTAS@ | awk '$2 ~ /\+/ {print $1}'`
57 58 59 60 61 62
do
(
# feel free to change this message!!!
cat << MESSAGE
From: Testbed Operations <@TBOPSEMAIL_NOSLASH@>
To: $i@@OURDOMAIN@
63
Bcc: @TBAUTOMAILEMAIL_NOSLASH@
64 65 66 67 68 69 70 71 72 73
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@:

74
@USERNODE@> quota -v -l
75 76
`quota -v -l $i`

77 78
(Note: This will not work from nodes in an experiment.)

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

81 82 83 84
$PROJSTR
$GROUPSSTR
$USERSSTR
$SCRATCHSTR
85

86 87 88 89
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.

90 91
$QUOTAHELP

92 93 94 95 96
Thanks,
@THISHOMEBASE@ Testbed Operations
@TBOPSEMAIL_NOSLASH@

MESSAGE
97
) | /usr/sbin/sendmail -i -t
98 99
done