概要 †
アップデートなどによって作られる不要ファイルを削除するスクリプトです。
コード †
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
| -
!
-
|
|
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
!
-
-
-
-
-
|
|
!
!
|
|
-
-
-
-
-
|
|
!
!
|
|
-
-
|
!
|
-
!
|
|
MAIL_ADDRESS="[email protected]"
MAIL_TITLE="[$(hostname)] 不要ファイル削除報告"
CHECK_PATH1=(
/etc/cron.d/
/etc/cron.daily/
/etc/cron.hourly/
/etc/cron.monthly/
/etc/cron.weekly/
)
DENNY_LIST1=(
chkrootkit
rkhunter
tripwire
avira_updater
logrotate
)
CHECK_PATH2=(
/etc/logrotate.d/
)
DENNY_LIST2=(
apt
aptitude
avira
cron-apt
dpkg
exim4-base
exim4-paniclog
munin
munin-node
nginx
rkhunter
ntpdate
)
MAIL=/usr/bin/mail
OUTFILE=`/bin/mktemp` || exit 1
for path in ${CHECK_PATH1[*]}
do
for file in ${DENNY_LIST1[*]}
do
if test -f $path$file; then
/bin/rm $path$file
echo $path$file >> $OUTFILE
fi
done
done
for path in ${CHECK_PATH2[*]}
do
for file in ${DENNY_LIST2[*]}
do
if test -f $path$file; then
/bin/rm $path$file
echo $path$file >> $OUTFILE
fi
done
done
if [ -s "$OUTFILE" ]; then
/bin/cat $OUTFILE | tr -d '\r' | $MAIL -s "$MAIL_TITLE" "$MAIL_ADDRESS"
fi
/bin/rm -f $OUTFILE
|
検証時の環境 †