~allenap/maas/ipmi-power-confusion--bug-1560830

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
#!/bin/bash
# Copyright 2012-2016 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# Exit immediately if a command exits with a non-zero status.
set -o errexit
# Treat unset variables as an error when substituting.
set -o nounset

# Move to the project root.
cd "$(dirname "$0")/../.."

# Start logging, if requested. Not using multilog here right now
# because there are race issues when restarting.
[ -z "${logdir:-}" ] || exec &>> "${logdir}/current"

# DNS settings, for driving BIND.
export MAAS_DNS_CONFIG_DIR="${MAAS_ROOT}/etc/bind/maas"
export MAAS_DNS_RNDC_PORT=5247
export MAAS_DNS_DEFAULT_CONTROLS=0

# Ensure that we've got a configuration directory.
mkdir -p "${MAAS_DNS_CONFIG_DIR}"

homedir="$MAAS_DNS_CONFIG_DIR"
port="$((MAAS_DNS_RNDC_PORT - 1))"
rndc_port="$MAAS_DNS_RNDC_PORT"

# Create DNS config.
bin/py -m provisioningserver.testing.bindfixture -- \
    --create-config-only --overwrite-config \
    --homedir "${homedir}" --port "${port}" \
    --rndc-port "${rndc_port}"

# Create MAAS' DNS config: do not overwrite an existing config file
# as the writing of the full configuration might have happened already.
bin/maas-region set_up_dns --no-clobber

# Edit the fixture's named.conf to include MAAS' DNS config.
bin/maas-region get_named_conf \
    --edit --config_path "${homedir}/named.conf"

# Run named.
exec $(command -v authbind && echo --deep) \
    bin/py -m provisioningserver.testing.bindfixture -- \
    --homedir "${homedir}" --port "${port}" \
    --rndc-port "${rndc_port}"