-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkmtree.sh
executable file
·36 lines (33 loc) · 1 KB
/
mkmtree.sh
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
#!/bin/sh
echo "(i)nit mtree or (c)ompare mtree?"
read cmd
getSeed () {
echo "enter seed"
read seed
}
case $cmd in
"i")
getSeed
for i in bin sbin usr-bin usr-sbin usr-local-bin etc usr-local-etc; do
p=/`echo $i | sed s!-!/!g`
mtree -s $seed -p $p -c -K cksum,sha256 > /root/.${i}_chksum_mtree
openssl enc -bf -salt -in /root/.${i}_chksum_mtree -out /root/.${i}_chksum_mtree.enc -e
rm /root/.${i}_chksum_mtree
done
;;
"c")
getSeed
for i in bin sbin usr-bin usr-sbin usr-local-bin etc usr-local-etc; do
p=/`echo $i | sed s!-!/!g`
openssl enc -bf -in /root/.${i}_chksum_mtree.enc -out /root/.${i}_chksum_mtree -d
mtree -s $seed -p $p < /root/.${i}_chksum_mtree > /root/.${i}_chksum_mtree.output
# if output is not empty, file has been changed
if [ -s /root/.${i}_chksum_mtree.output ]; then
echo "something's been changed..."
else
rm /root/.${i}_chksum_mtree
fi
done
;;
*) echo "enter i or c"
esac