-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhostsecurmod.sh
More file actions
executable file
·60 lines (51 loc) · 1.61 KB
/
hostsecurmod.sh
File metadata and controls
executable file
·60 lines (51 loc) · 1.61 KB
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
#!/bin/bash
SAVEDIR=/mcorp/backup/
SAVE=hosts.`date +%Y%m%d%H%M`
TMP=/tmp/hosts.tmp
FILE=/etc/hosts
#cp ${FILE} ${FILE}.bak
cp ${FILE} ${TMP}
vi ${TMP}
echo "----------------------"
echo "| > element supprime |"
echo "| < element ajoute |"
echo "----------------------"
DIFF=`diff ${TMP} ${FILE}`
echo "${DIFF}"
echo -n "Voulez vous enregistrer ? [y,N]"
read RESPONSE
if [ "$RESPONSE" = "y" ]
then
cp ${FILE} ${SAVEDIR}${SAVE}
cp ${TMP} ${FILE}
RESULT=`ls ${SAVEDIR} | wc -l`
if [ "${RESULT}" -gt 100 ]
then
RESULT2=`ls ${SAVEDIR} | head -1`
rm -f ${SAVEDIR}${RESULT2}
echo "------------------------------------------------------------"
echo "| Le fichier de sauvegarde ${RESULT2} a ete efface |"
echo "------------------------------------------------------------"
fi
rm -f ${TMP}
echo "-----------------------------------"
echo "| le fichier a ete edite et sauve |"
echo "-----------------------------------"
echo -e "----------------------\n| > element supprime |\n| < element ajoute |\n----------------------\n ${DIFF}" | mail -s "Modification du fichier HOSTS" "exploit@lapin.net"
echo -n "Voulez vous synchroniser le hosts ? [y,N]"
read RESPONSE
if [ "$RESPONSE" = "y" ]
then
/lapin/scripts/distrib sync -g self /etc/hosts /
/root/guillaume/synchro_host_to_avamar
echo "----------------------------------"
echo "| Le fichier a ete synchronise |"
echo "----------------------------------"
fi
else
rm -f ${TMP}
echo "----------------------------------"
echo "| Le fichier n'a pas ete modifie |"
echo "----------------------------------"
exit
fi