This repository has been archived by the owner on Jun 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
lab_start.sh
executable file
·187 lines (131 loc) · 4.47 KB
/
lab_start.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/sh
echo ""
echo "####################################################"
echo "# Welcome to the DNSSEC Labs #"
echo "# It will take a few minutes to start everything #"
echo "####################################################"
echo ""
sleep 5
ROOT=`pwd`
/usr/sbin/portsnap fetch extract
WITHOUT_X11=yes
PACKAGES=${ROOT}/packages
for i in ports-mgmt/pkg dns/bind911 dns/ldns editors/nano editors/vim-lite security/sudo;
do
cd /usr/ports/${i} && make package-recursive WITHOUT="X11" BATCH=yes PACKAGES=${ROOT}/packages
done
cd ${ROOT}
for i in auth1 auth2 resolver users; do
cp ${PACKAGES}/All/* confs/${i}/pkg/
done;
## Now build the packages specific to the signer jail.
## We need a web server and PHP to manage the DS update process.
for i in www/nginx lang/php56 lang/php56-extensions;
do
cd /usr/ports/${i} && make package-recursive WITHOUT="X11" BATCH=yes PACKAGES=${ROOT}/packages
done;
cd ${ROOT}
cp ${PACKAGES}/All/* confs/signer/pkg/
echo ""
echo "#######################"
echo "# Installing tmux #"
echo "#######################"
echo ""
/usr/sbin/pkg install -y tmux
#### Install EZJail
echo ""
echo "#######################"
echo "# Installing EZjail #"
echo "#######################"
echo ""
/usr/sbin/pkg install -y ezjail
echo 'ezjail_enable="YES"' >> /etc/rc.conf
/usr/local/bin/ezjail-admin install
echo ""
echo "################################"
echo "# Finished installing EZjail #"
echo "################################"
echo ""
sleep 3
#### Setup PF for forwarding
echo ""
echo "####################"
echo "# Configuring PF #"
echo "####################"
echo ""
cp etc/pf.conf /etc/pf.conf
echo 'pf_enable="YES"' >> /etc/rc.conf
/etc/rc.d/pf start
echo ""
echo "#############################"
echo "# Finished configuring PF #"
echo "#############################"
echo ""
sleep 3
#### Copy the flavours where they belong
echo ""
echo "######################"
echo "# Copying flavours #"
echo "######################"
echo ""
cp -r ./confs/* /usr/jails/flavours/
#### Create and start auth1
echo ""
echo "####################"
echo "# Creating auth1 #"
echo "####################"
echo ""
/usr/local/bin/ezjail-admin create -f auth1 auth1 "lo0|10.0.1.53,lo0|10.0.3.53,lo0|10.0.5.53,lo0|2001:db8::1:53,lo0|2001:db8::3:53,lo0|2001:db8::5:53"
echo ""
echo "####################"
echo "# Starting Auth1 #"
echo "####################"
echo ""
/usr/local/bin/ezjail-admin start auth1
KEY=`/usr/bin/grep -l "key-signing" /usr/jails/auth1/usr/local/etc/namedb/domains/root/K*`
echo ""
echo "###############################"
echo "# Copying keys in user dirs #"
echo "###############################"
echo ""
echo "managed-keys { " > bind.keys && \
/usr/bin/tail -n+5 ${KEY} | \
/usr/bin/sed "s/20 IN DNSKEY/initial-key/" | \
/usr/bin/sed "s/3 8/3 8 \"/" >> bind.keys && \
echo "\";};" >> bind.keys
for i in users resolver auth2; do
cp bind.keys /usr/jails/flavours/${i}/usr/
cp etc/named.root /usr/jails/flavours/${i}/usr/
done
echo ""
echo "########################################"
echo "# Creating and starting the resolver #"
echo "########################################"
echo ""
/usr/local/bin/ezjail-admin create -f resolver resolver "lo0|10.0.0.201,lo0|2001:db8::201:53"
/usr/local/bin/ezjail-admin start resolver
echo ""
echo "#################################"
echo "# Creating and starting Auth2 #"
echo "#################################"
echo ""
/usr/local/bin/ezjail-admin create -f auth2 auth2 "lo0|10.0.2.53,lo0|10.0.4.53,lo0|10.0.6.53,lo0|2001:db8::2:53,lo0|2001:db8::4:53,lo0|2001:db8::6:53"
/usr/local/bin/ezjail-admin start auth2
echo ""
echo "######################################"
echo "# Creating and starting the signer #"
echo "######################################"
echo ""
#### Create and start the signer
/usr/local/bin/ezjail-admin create -f signer signer "lo0|10.0.0.101,lo0|2001:db8::101:53"
/usr/local/bin/ezjail-admin start signer
echo ""
echo "#################################################"
echo "# Lab has finished starting, now opening TMUX #"
echo "#################################################"
echo ""
/usr/local/bin/tmux new-window -t :1 -n "auth1" 'ezjail-admin console auth1'
/usr/local/bin/tmux new-window -t :2 -n "auth2" 'ezjail-admin console auth2'
/usr/local/bin/tmux new-window -t :3 -n "resolver" 'ezjail-admin console resolver'
/usr/local/bin/tmux new-window -t :4 -n "signer" 'ezjail-admin console signer'
/usr/local/bin/tmux new-window -t :5 -n "clients" 'sh clients_start.sh'