-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen-file.sh
40 lines (36 loc) · 1.43 KB
/
gen-file.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
#!/bin/bash
if test "${server}" == ""; then
echo "Please set a value for 'server' in the environment or on the cli."
exit 1
fi
mkdir redir
if test "${list}" != ""; then
if test -f "${list}"; then
mkdir "redir/${list%.*}"
for domain in `cat ${list}`; do
sed -e "s@gen\.com@${domain}@g" \
-e "s@server\.example\.com@${server}@g" \
gen.zone > "redir/${list%.*}/${domain}.zone"
echo -e "zone \"${domain}\" IN {" >> "redir/${list%.*}/${list%.*}.conf"
echo -e "\ttype master;" >> "redir/${list%.*}/${list%.*}.conf"
echo -e "\tfile \"redir/${list%.*}/${domain}.zone\";" >> "redir/${list%.*}/${list%.*}.conf"
echo -e "};\n" >> "redir/${list%.*}/${list%.*}.conf"
done
else
echo "No file ${list}!"
exit 1
fi
else
for list in *.txt; do
mkdir "redir/${list%.*}"
for domain in `cat ${list}`; do
sed -e "s@gen\.com@${domain}@g" \
-e "s@server\.example\.com@${server}@g" \
gen.zone > "redir/${list%.*}/${domain}.zone"
echo -e "zone \"${domain}\" IN {" >> "redir/${list%.*}/${list%.*}.conf"
echo -e "\ttype master;" >> "redir/${list%.*}/${list%.*}.conf"
echo -e "\tfile \"redir/${list%.*}/${domain}.zone\";" >> "redir/${list%.*}/${list%.*}.conf"
echo -e "};\n" >> "redir/${list%.*}/${list%.*}.conf"
done
done
fi