~samiam/MaraDNS

MaraDNS/build/install.sh -rwxr-xr-x 6.2 KiB View raw
ccb94b01Sam Trenholme Dockerfile now installs MaraDNS in Docker image. 22 days ago
                                                                                
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/sh

# Shell script which installs the MaraDNS files in the appropriate directories

# Set the directory with the build-related scripts 
if [ -z "$BUILDDIR" ] ; then
	BUILDDIR="build"
fi

# Set the directory which is the top-level MaraDNS directory
if [ -z "$TOPLEVEL" ] ; then
	TOPLEVEL=$( pwd )
fi

cd $TOPLEVEL

# We call install.locations to set BIN, SBIN, MAN1, MAN8, and DOCS
# It is in a separate file to insure that install.sh and uninstall.sh
# have the same values
. $BUILDDIR/install.locations

# Make sure that the various install directories actually exist
if [ ! -d "$BIN" ] ; then
	echo The directory $BIN does not exist.  Please edit the file
	echo install.locations by hand.
	exit 2
fi
if [ ! -d "$SBIN" ] ; then
	echo The directory $SBIN does not exist.  Please edit the file
	echo install.locations by hand.
	exit 3
fi
if [ ! -d "$MAN1" ] ; then
	echo The directory $MAN1 does not exist.  Please edit the file
	echo install.locations by hand.
	exit 4
fi
if [ ! -d "$MAN5" ] ; then
	echo The directory $MAN5 does not exist.  Please edit the file
	echo install.locations by hand.
	exit 7
fi
if [ ! -d "$MAN8" ] ; then
	echo The directory $MAN8 does not exist.  Please edit the file
	echo install.locations by hand.
	exit 5
fi

# Make sure we have a place to put documents
# Thanks to Paul Howard for the following six lines
if [ ! -d "$( dirname $DOCS )" ] ; then
	if ! mkdir "$( dirname $DOCS )" ; then
		echo unable to make the $( dirname $DOCS ) directory. 
		exit 6
	fi
fi
if [ ! -d "$DOCS" ] ; then
	if ! mkdir "$DOCS" ; then
		echo unable to make the $DOCS directory. 
		exit 6
	fi
fi

echo Installing MaraDNS, placing programs in $BIN and $SBIN,
echo man pages in $MAN1, $MAN5, 
echo and $MAN8, and documents in $DOCS

# Place the binaries in $BIN and $SBIN

# Install the maradns binary
cd $TOPLEVEL/server
echo Installing maradns
if [ -x maradns ] ; then
	# We remove the file first to avoid the "text file busy" problem
	if [ -f $SBIN/maradns ] ; then
		rm $SBIN/maradns
	fi
	cp maradns $SBIN
	echo maradns installed
elif [ -x maradns.authonly ] ; then
	# We remove the file first to avoid the "text file busy" problem
	if [ -f $SBIN/maradns.authonly ] ; then
		rm $SBIN/maradns.authonly
	fi
	cp maradns.authonly $SBIN
	echo maradns installed as maradns.authonly
else
	echo unable to find maradns binary to install
	echo please make sure program sucessfully compiled
	exit 1
fi

# Install the Deadwood binary
cd $TOPLEVEL/deadwood-*/src/
echo Installing Deadwood
if [ -x Deadwood ] ; then
	if [ -f $SBIN/Deadwood ] ; then
		rm $SBIN/Deadwood
	fi
	cp Deadwood $SBIN
	echo Deadwood installed
fi

# Install the getzone and fetchzone binaries
cd $TOPLEVEL/tcp
echo Installing getzone and fetchzone
cp getzone fetchzone $BIN
echo getzone and fetchzone installed

# Install the zoneserver binary
echo installing zoneserver
# We remove the file first to avoid the "text file busy" problem
if [ -f $SBIN/zoneserver ] ; then
	rm $SBIN/zoneserver
fi
cp zoneserver $SBIN
echo zoneserver installed

# Install the askmara binary
echo installing askmara
cd $TOPLEVEL/tools
if [ -f $BIN/askmara ] ; then
	rm $BIN/askmara
fi
cp askmara $BIN
echo askmara installed

# Install the duende tool
# We remove the file first to avoid the "text file busy" problem
echo installing duende
if [ -f $BIN/duende ] ; then
	rm $BIN/duende
fi
cp duende $BIN
echo duende installed

# Place the man pages in $MAN1, $MAN5, and $MAN8
if [ -d $TOPLEVEL/doc/$LANGUAGE/man ] ; then
	cd $TOPLEVEL/doc/$LANGUAGE/man
else
	cd $TOPLEVEL/doc/en/man
fi
cp askmara.1 getzone.1 fetchzone.1 $MAN1
cp maradns.8 zoneserver.8 duende.8 $MAN8
cp csv1.5 csv2.5 csv2_txt.5 mararc.5 $MAN5

# Place all the documents in $DOCS
cd ..
mkdir $DOCS > /dev/null 2>&1
cp -r * $DOCS
cd $TOPLEVEL
cp maradns.gpg.key $DOCS

# Add Deadwood man page
cp deadwood-*/doc/Deadwood.1 $MAN1
# Add default dwood3rc file for Deadwood
if [ ! -f $RPM_BUILD_ROOT/etc/dwood3rc ] ; then
	cat deadwood-*/doc/dwood3rc | \
		sed 's/127.0.0.1\"/127.0.0.2\"/' | \
		sed 's/\/etc\/deadwood/\/etc\/maradns/' \
		> $RPM_BUILD_ROOT/etc/dwood3rc
else
	echo /etc/dwood3rc already there, not replacing
fi

# If the system in question does not already have configuration files,
# place example configuration files in /etc
if [ -d doc/$LANGUAGE/examples ] ; then
	cd doc/$LANGUAGE/examples
else
	cd doc/en/examples
fi

# $RPM_BUILD_ROOT was added at the request of one of my users
if [ ! -f $RPM_BUILD_ROOT/etc/mararc ] ; then
	cp example_mararc $RPM_BUILD_ROOT/etc/mararc
else 
	echo /etc/mararc already there, not replacing
fi
if [ ! -d $RPM_BUILD_ROOT/etc/maradns ] ; then
	mkdir $RPM_BUILD_ROOT/etc/maradns
	chmod 755 $RPM_BUILD_ROOT/etc/maradns
fi
if [ ! -d $RPM_BUILD_ROOT/etc/maradns/logger ] ; then
	# The duende tool *needs* an /etc/maradns/logger directory
	# Note that duende uses an absolute path
	mkdir $RPM_BUILD_ROOT/etc/maradns/logger
fi
if [ ! -f $RPM_BUILD_ROOT/etc/maradns/db.example.net ] ; then
	cp example_csv2 $RPM_BUILD_ROOT/etc/maradns/db.example.net
fi

# Finally, set up the startup files, as needed
# Go back to the top-level MaraDNS directory
cd $TOPLEVEL
# And copy over the init files if this system looks to be a sysVish init
# system
if [ -d $RPM_BUILD_ROOT/etc/rc.d/init.d ] ; then
	echo Adding MaraDNS startup scripts
	if [ ! -f $RPM_BUILD_ROOT/etc/rc.d/init.d/maradns ] ; then
	      cp $BUILDDIR/mara.startup $RPM_BUILD_ROOT/etc/rc.d/init.d/maradns
	      cp $BUILDDIR/zoneserver.startup \
	          $RPM_BUILD_ROOT/etc/rc.d/init.d/maradns.zoneserver
	      cp $BUILDDIR/deadwood.startup \
	          $RPM_BUILD_ROOT/etc/rc.d/init.d/maradns.deadwood
	      chmod 755 $RPM_BUILD_ROOT/etc/rc.d/init.d/maradns.deadwood
	fi
	if cd $RPM_BUILD_ROOT/etc/rc.d/rc3.d/ ; then
		echo Starting up MaraDNS at runlevel 3
		rm S60maradns 2> /dev/null
		rm K60maradns.zoneserver 2> /dev/null
		rm S60maradns.deadwood 2> /dev/null
		ln -s ../init.d/maradns S60maradns
		ln -s ../init.d/maradns.zoneserver K60maradns.zoneserver
		ln -s ../init.d/maradns.deadwood S60maradns.deadwood
	fi
	if cd $RPM_BUILD_ROOT/etc/rc.d/rc5.d/ ; then
		echo starting up MaraDNS at runlevel 5
		rm S60maradns 2> /dev/null
		rm K60maradns.zoneserver 2> /dev/null
		rm S60maradns.deadwood 2> /dev/null
		ln -s ../init.d/maradns S60maradns
		ln -s ../init.d/maradns.zoneserver K60maradns.zoneserver
		ln -s ../init.d/maradns.deadwood S60maradns.deadwood
	fi
fi