-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathinstall.sh
executable file
·44 lines (30 loc) · 1.26 KB
/
install.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
#!/bin/bash
set -e
target=/opt/dnsmasq-rest-api/
echo "Installing dnsmasq-rest-api to $target."
[ -d $target ] || git clone git://github.com/bpaquet/dnsmasq-rest-api.git $target
echo "Configuring dnsmasq."
ln -sf $target/config/dnsmasq/dnsmasq-rest-api.conf /etc/dnsmasq.d/dnsmasq-rest-api.conf
/etc/init.d/dnsmasq restart
echo "Allow dnsmasq-rest-api to send signal to dnsmasq"
cp $target/config/sudo/dnsmasq /etc/sudoers.d/dnsmasq
chmod 0440 /etc/sudoers.d/dnsmasq
echo "Configuring apache2"
a2enmod rewrite
ln -sf $target/config/apache2/dnsmasq-rest-api.conf /etc/apache2/conf.d/dnsmasq-rest-api.conf
/etc/init.d/apache2 restart
chown -R www-data $target/zones
cp $target/www/config.example.php $target/www/config.php
echo "Dnsmasq-rest-api installed."
echo "Running tests."
echo "* Listing zones"
curl -s http://localhost/dnsmasq-rest-api/zones | grep "\\[" | grep "\\]"
echo "* Adding records"
curl -s -X POST http://localhost/dnsmasq-rest-api/zones/myTest/127.0.0.2/localhost.test | grep OK
echo "* Reload dnsmasq"
curl -s -X POST http://localhost/dnsmasq-rest-api/reload | grep OK
echo "* Testing dns"
nslookup localhost.test 127.0.0.1 | grep 127.0.0.2
echo "* Removing test zone"
curl -s -X DELETE http://localhost/dnsmasq-rest-api/zones/myTest | grep OK
echo "Tests ok."