This file is indexed.

postinst is in maas-dhcp 0.1+bzr482+dfsg-0ubuntu1.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

 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
#!/bin/sh -e

. /usr/share/debconf/confmodule
db_version 2.0

if ([ "$1" = "configure" ] && [ -z "$2" ]) || [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then
        db_input high maas-dhcp/dnsmasq-dhcp-range || true
        db_go
        db_input high maas-dhcp/dnsmasq-default-gateway || true
        db_go
        db_input high maas-dhcp/dnsmasq-domain-name || true
        db_go

	# Setup dnsmasq
	sed -i -e "s/^manage_dns:.*$/manage_dns: 1/" \
	       -e "s/^manage_dhcp:.*$/manage_dhcp: 1/" /etc/cobbler/settings
	sed -i -e "s/^module = manage_bind/module = manage_dnsmasq/" \
	       -e "s/^module = manage_isc/module = manage_dnsmasq/" /etc/cobbler/modules.conf

	# Set the DHCP range
	db_get maas-dhcp/dnsmasq-dhcp-range || true
	range="$RET"
	if [ -n "$range" ]; then
		sed -i -e "s/^dhcp-range=.*$/dhcp-range=$range/" /etc/cobbler/dnsmasq.template
	fi

	# Setup Default Gateway
	db_get maas-dhcp/dnsmasq-default-gateway || true
	ipaddr="$RET"
	if [ -n "$ipaddr" ]; then
		# If template has $next_server as default gateway, set it to $ipaddr
		if grep -qs "^dhcp-option=.*$" /etc/cobbler/dnsmasq.template; then
			sed -i -e "s/^dhcp-option=.*$/dhcp-option=3,$ipaddr/" /etc/cobbler/dnsmasq.template
		fi
	fi

	# Setup Domain Name
	db_get maas-dhcp/dnsmasq-domain-name || true
	domain="$RET"
	if [ -n "$domain" ]; then
		# if the domain hasn't been set, set it to $domain
		if grep -qs "^#domain=.*$" /etc/cobbler/dnsmasq.template; then
			sed -i -e "s/^#domain=.*/domain=$domain/" /etc/cobbler/dnsmasq.template
		# if the domain has been set, change it to $domain
		elif grep -qs "^domain=.*$" /etc/cobbler/dnsmasq.template; then
			sed -i -e "s/^domain=.*$/domain=$domain/" /etc/cobbler/dnsmasq.template
		fi
	elif [ -z "$domain" ]; then
		# if the domain has been set to empty, then disable it
		if grep -qs "^domain=.*$" /etc/cobbler/dnsmasq.template; then
			sed -i -e "s/^domain=.*$/#domain=/" /etc/cobbler/dnsmasq.template
		fi
	fi
	if [ -x /usr/sbin/invoke-rc.d ]; then
                invoke-rc.d cobbler restart || true
	fi

fi


exit 0