17
17
chmod -R 775 /var/log/maas/oops
21
# Set up iSCSI: add maas.conf to tgt conf.d.
22
local tgtcfg="/etc/tgt/targets.conf"
23
[ -d /etc/tgt/conf.d/ ] ||
24
echo "Warning! $tgtcfg did not exist" 1>&2;
25
mkdir -p /etc/tgt/conf.d/ /var/lib/maas/ephemeral/
26
ln -sf /var/lib/maas/ephemeral/tgt.conf /etc/tgt/conf.d/maas.conf
29
extract_cluster_uuid(){
30
# Extract ClUSTER_UUID setting from config file $1. This will work
31
# both the cluster celery config (which is python) and the cluster
32
# config (which is shell).
33
sed -n -e "s/^CLUSTER_UUID *= *[\"']\([^\"']*\).*/\1/p" "$1"
36
configure_cluster_uuid(){
37
# The cluster uuid goes into maas_cluster.conf, but we also still
38
# keep a copy in maas_local_celeryconfig_cluster.py (hopefully just
39
# temporarily). If an old uuid is configured, we replicate that to
40
# maas_cluster.conf; otherwise, we want to generate one.
44
if [ -n "$(extract_cluster_uuid /etc/maas/maas_cluster.conf)" ]; then
45
# UUID is already set up. Wonderful.
49
# Look for a UUID stored in the old location.
50
uuid="$(extract_cluster_uuid /etc/maas/maas_local_celeryconfig_cluster.py)"
52
if [ -z "$uuid" ]; then
53
# No UUID at all yet. Generate one, and insert it into its
54
# placeholder in the old config location.
56
sed -i "s|^CLUSTER_UUID = None$|CLUSTER_UUID = '$uuid'|" \
57
/etc/maas/maas_local_celeryconfig_cluster.py
60
# Either way, at this point we have a uuid, and it is configured in
61
# the old config location.
63
# Write it to maas_cluster.conf as well. There is no initial
64
# placeholder in this file, so just append the setting.
65
echo "CLUSTER_UUID=\"$uuid\"" >>/etc/maas/maas_cluster.conf
20
69
if [ "$1" = "configure" ] && [ -z "$2" ]; then
24
# The local celery config may contain a private cluster UUID. Only
25
# maas can read it; only root can write it.
26
chown root:maas /etc/maas/maas_local_celeryconfig_cluster.py
27
chmod 0640 /etc/maas/maas_local_celeryconfig_cluster.py
29
# Generate cluster UUID.
30
if grep -qs "^CLUSTER_UUID\ \= None$" /etc/maas/maas_local_celeryconfig_cluster.py; then
32
sed -i "s|^CLUSTER_UUID\ \= None$|CLUSTER_UUID = '"$uuid"'|" \
33
/etc/maas/maas_local_celeryconfig_cluster.py
37
75
if ([ "$1" = "configure" ] && [ -z "$2" ]) || [ "$1" = "reconfigure" ] || [ -n "$DEBCONF_RECONFIGURE" ]; then
43
# Get the MAAS_URL on configure/reconfigure and write it to the conf file.
81
# Get the MAAS_URL on configure/reconfigure and write it to the conf files.
44
82
db_get maas-cluster-controller/maas-url || true
45
83
if [ -n "$RET" ]; then
46
84
sed -i "s|MAAS_URL=.*|MAAS_URL="$RET"|" /etc/maas/maas_cluster.conf
85
# Extract the hostname part.
86
HOSTPART=$(echo $RET|awk '{ split($0,array,"/")} END{print array[3] }')
87
# And substitute it in-place in pserv.yaml on an indented, non-commented
89
sed -ri "s|^([[:space:]]+)(#+[[:space:]]*)?(generator:[[:space:]]+https?://)[^:/]+|\1\3$HOSTPART|" /etc/maas/pserv.yaml
93
if [ "$1" = "configure" ]; then
94
# These config files may contain a private cluster UUID. Only maas
95
# can read them; only root can write them
97
/etc/maas/maas_local_celeryconfig_cluster.py \
98
/etc/maas/maas_cluster.conf
100
/etc/maas/maas_local_celeryconfig_cluster.py \
101
/etc/maas/maas_cluster.conf
103
configure_cluster_uuid