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