Thu, 06 Dec 2012 15:08:01 +0100
Fixed spelling error, updated address
5 | 1 | #!/bin/bash |
2 | # | |
3 | ############################################################################# | |
14
59e07bba67cc
Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents:
5
diff
changeset
|
4 | # Copyright (C) 2005-2012 |
5 | 5 | # |
6 | # Michiel Broek <mbse@mbse.dds.nl> | |
7 | # the Netherlands | |
8 | # | |
14
59e07bba67cc
Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents:
5
diff
changeset
|
9 | # This file is part of SlackSecCheckScripts. |
5 | 10 | # |
11 | # This package is free software; you can redistribute it and/or modify it | |
12 | # under the terms of the GNU General Public License as published by the | |
13 | # Free Software Foundation; either version 2, or (at your option) any | |
14 | # later version. | |
15 | # | |
14
59e07bba67cc
Fixed spelling error, updated address
Michiel Broek <mbse@mbse.eu>
parents:
5
diff
changeset
|
16 | # SlackSecCheckScripts is distributed in the hope that it will be useful, but |
5 | 17 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | # General Public License for more details. | |
20 | # | |
21 | # You should have received a copy of the GNU General Public License | |
22 | # along with MBSE BBS; see the file COPYING. If not, write to the Free | |
23 | # Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
24 | ############################################################################# | |
25 | ||
26 | ||
27 | PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
28 | ||
29 | umask 077 | |
30 | TZ=UTC; export TZ | |
31 | MP=/etc/passwd | |
32 | LANG=C; export LANG | |
33 | ||
34 | SECUREDIR=`mktemp -d /tmp/_securedir.XXXXXX` || exit 1 | |
35 | ||
36 | trap "/bin/rm -rf $SECUREDIR ; exit 0" EXIT INT QUIT PIPE | |
37 | ||
38 | if ! cd "$SECUREDIR"; then | |
39 | echo "Can not cd to $SECUREDIR". | |
40 | exit 1 | |
41 | fi | |
42 | ||
43 | MPBYPATH=secure1.$$ | |
44 | OUTPUT=secure2.$$ | |
45 | ||
46 | ||
47 | # These are used several times. | |
48 | # | |
49 | awk -F: '{ print $1 " " $3 " " $6 }' $MP > $MPBYPATH | |
50 | ||
51 | ||
52 | while read name uid homedir; do | |
53 | if [ -d ${homedir}/ ] && [ "`expr $uid \>= 1000`" == "1" ]; then | |
54 | USAGE=`du -s --block-size=1048576 -h $homedir | cut -f 1` | |
55 | SPACE=`df -khTP $homedir | tail -n 1 | awk '{ print $3 }'` | |
56 | printf -- "%-16s %6s %6s $homedir\n" $name $USAGE $SPACE | |
57 | fi | |
58 | done < $MPBYPATH > $OUTPUT | |
59 | if [ -s $OUTPUT ] ; then | |
60 | printf -- "\n Diskspace used by users.\n\n" | |
61 | printf -- "Username used size homedirectory\n" | |
62 | printf -- "---------------- ------ ------ -------------\n" | |
63 | cat $OUTPUT | |
64 | fi | |
65 |