-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenhosts.sh
78 lines (73 loc) · 2.22 KB
/
enhosts.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
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
#set -x
if [[ "$3" == "" ]]
then
echo "[gates]" > hosts
echo "[gates]" > $(dirname $0)/enhostdom/domsw
> $(dirname $0)/inspect0.list
SERIAL=`date +%F | awk -F "-" '{print$1$2$3"01"}'`
echo '$TTL' 1h > $(dirname $0)/enhostdom/dom
echo "@ IN SOA ns1 root (" >> $(dirname $0)/enhostdom/dom
echo "$SERIAL ; serial" >> $(dirname $0)/enhostdom/dom
echo "1h ; refresh (1 hour)" >> $(dirname $0)/enhostdom/dom
echo "15m ; retry (15 minutes)" >> $(dirname $0)/enhostdom/dom
echo "2w ; expire (2 weeks)" >> $(dirname $0)/enhostdom/dom
echo "20m ; minimum (20 minutes)" >> $(dirname $0)/enhostdom/dom
echo ")" >> $(dirname $0)/enhostdom/dom
echo -e "\n\e[33mWORK WITH JIRA,\e[0m \e[31mNOT HMS!\e[0m"
echo -e "Put the \e[33mFULL list\e[0m of hosts only!"
for ((ns=1; ns<=$1; ns++)); do
echo "@ IN NS ns"$ns >> $(dirname $0)/enhostdom/dom
done;
fi
if [[ "$1" == "elim" || "$1" == "ipset" ]]
then
if [[ "$2" != "" && "$2" != "sp" ]]
then
echo "[gates]" > hosts$2
ipc=0
while [[ "$ipc" != "" ]]; do
echo -ne "\e[33mEnter IP-address:\e[0m "
read ip
ipc=`echo $ip | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}"`
echo $ipc >> hosts$2
done
elif [[ "$2" == "" ]]
then
echo "[gates]" > hosts
ipc=0
while [[ "$ipc" != "" ]]; do
echo -ne "\e[33mEnter IP-address:\e[0m "
read ip
ipc=`echo $ip | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}"`
echo $ipc >> hosts
done;
fi
elif [[ "$2" == "sp" ]]
then
ns=1
for i in `cat $(dirname $0)/sp_res.log`; do
echo "ns$ns IN A $i" >> $(dirname $0)/enhostdom/dom
echo "ns$ns""_"$i >> $(dirname $0)/inspect0.list
echo $i >> hosts
((ns+=1))
done
else
echo -ne '###\r'
ns=1
let limit=$1+1
h=`cat hosts | wc -l`
while [ $h -lt $limit ]
do
echo -ne "\e[33mEnter IP-address:\e[0m "
read ip
ipc=`echo $ip | grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}"`
if [[ "$ipc" != "" ]]
then
echo "ns$h IN A $ipc" >> $(dirname $0)/enhostdom/dom
echo "ns$h""_"$ipc >> $(dirname $0)/inspect0.list
echo $ipc >> hosts
echo $ipc >> $(dirname $0)/enhostdom/domsw
h=`cat hosts | wc -l`
fi
done
fi