~ubuntu-branches/ubuntu/quantal/maas/quantal-security

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

. /usr/share/debconf/confmodule
db_version 2.0

# creates question
set_question() {
	if ! db_fget "$1" seen; then
		db_register dbconfig-common/dbconfig-install "$1"
		db_subst "$1" ID "$1"
		db_fget "$1" seen
	fi
	if [ "$RET" = false ]; then
		db_set "$1" "$2"
		db_fset "$1" seen true
	fi
}

# source dbconfig-common shell library, and call the hook function
if [ -f /usr/share/dbconfig-common/dpkg/config.pgsql ]; then
	. /usr/share/dbconfig-common/dpkg/config.pgsql
fi

if ([ "$1" = "configure" ] && [ -z "$2" ]); then
	# Hide maas/dbconfig-install question by setting default.
	set_question maas-region-controller/dbconfig-install true
	set_question maas-region-controller/pgsql/app-pass ""

	dbc_dbname="maasdb"
	dbc_dbuser="maas"
	dbc_remove="true"

	dbc_go maas-region-controller $@

elif [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then
	db_get maas/default-maas-url || true
	if [ -n "$RET" ]; then
		db_set maas/default-maas-url "$RET"
	else
		ipaddr=$(awk '$1 == "DEFAULT_MAAS_URL" { split($0,array,"/")} END{print array[3] }' /etc/maas/maas_local_settings.py)
		db_set maas/default-maas-url "$ipaddr"
	fi
	db_input low maas/default-maas-url || true
	db_go
fi