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 | #!/bin/sh
set -e
. /usr/share/debconf/confmodule
db_version 2.0
RELEASE=`lsb_release -rs` || RELEASE=""
create_var_dir() {
# create var dir
if [ ! -d /var/lib/maas ]; then
mkdir -p /var/lib/maas
fi
chown -R maas:maas /var/lib/maas/
}
create_log_dir() {
# Give appropriate permissions
if [ ! -f /var/log/maas/rackd.log ]; then
touch /var/log/maas/rackd.log
fi
chown maas:maas /var/log/maas/rackd.log
}
configure_maas_tgt() {
# Ensure that iSCSI targets get re-defined on reboot.
# Creates a softlink in /etc/tgt/conf.d/ that points to the current
# boot images' tgt configuration.
mkdir -p /etc/tgt/conf.d
ln -sf /var/lib/maas/boot-resources/current/maas.tgt /etc/tgt/conf.d/maas.conf
}
extract_cluster_uuid(){
# Extract ClUSTER_UUID setting from config file $1. This will work
# on the old the cluster config file (which is shell).
awk '{ split($1,array,"\"")} END{print array[2] }' "$1"
}
extract_maas_url(){
# Extract the MAAS_URL setting from the config file $1.
grep -Eo "https?://[^ ]+" "$1" | cut -d"\"" -f1
}
configure_cluster_uuid(){
# This will configure a UUID if one has not previously been set.
maas-provision config --init
}
configure_cluster_authbind() {
MAAS_UID="`id -u maas`"
if [ ! -f "/etc/authbind/byuid/$MAAS_UID" ]; then
if [ ! -d "/etc/authbind/byuid" ]; then
mkdir -p /etc/authbind/byuid
chmod 755 /etc/authbind
chmod 755 /etc/authbind/byuid
fi
fi
echo '0.0.0.0/0:68,69' >/etc/authbind/byuid/$MAAS_UID
echo '::/0,68-69' >>/etc/authbind/byuid/$MAAS_UID
chown maas:maas /etc/authbind/byuid/$MAAS_UID
chmod 700 /etc/authbind/byuid/$MAAS_UID
}
configure_maas_url(){
# Get the MAAS URL on configure/reconfigure and write it to the conf files.
db_get maas-rack-controller/maas-url || true
if [ -n "$RET" ]; then
maas-provision config --region-url "$RET"
fi
}
configure_shared_secret() {
db_get maas-rack-controller/shared-secret || true
if [ -n "$RET" ]; then
echo "$RET" | maas-provision install-shared-secret
chown maas:maas /var/lib/maas/secret
chmod 0640 /var/lib/maas/secret
fi
}
rack_controller_upgrade() {
# If we are upgrading from an older version, then we need to obtain
# the cluster UUID from the old configuration file and set it with
# the new configuration tool.
# If upgrading from 1.5, 1.7, 1.8
set -x
if [ -f /etc/maas/maas_cluster.conf ]; then
uuid=$(extract_cluster_uuid /etc/maas/maas_cluster.conf)
maas-provision config --uuid "$uuid"
maas_url=$(extract_maas_url /etc/maas/maas_cluster.conf)
maas-provision config --region-url "$maas_url"
db_set maas-rack-controller/maas-url "$maas_url"
mv /etc/maas/maas_cluster.conf /etc/maas/maas_cluster.conf.maas-old
mv /etc/maas/pserv.yaml /etc/maas/pserv.yaml.maas-old
fi
# if upgrading from 1.9
if [ -f /etc/maas/clusterd.conf ]; then
mv /etc/maas/clusterd.conf /etc/maas/rackd.conf
fi
}
# Unconditionally ensure that there is at least an empty configuration
# file. This does *not* overwrite any existing configuration.
maas-provision config
if [ "$1" = "configure" ] && [ -z "$2" ]; then
create_log_dir
create_var_dir
configure_maas_tgt
configure_maas_url
configure_cluster_uuid
configure_cluster_authbind
maas-provision upgrade-cluster
rack_controller_upgrade
elif [ -n "$DEBCONF_RECONFIGURE" ]; then
configure_maas_url
# Only ask for a shared secret when the region is not installed
# on the same system.
if [ ! -f /usr/sbin/maas-region-admin ]; then
db_input high maas-rack-controller/shared-secret
db_go
fi
configure_shared_secret
elif [ "$1" = "configure" ] && dpkg --compare-versions "$2" gt 0.1+bzr266+dfsg-0ubuntu1; then
configure_cluster_authbind
maas-provision upgrade-cluster
fi
db_stop
#DEBHELPER#
|