26
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
local config_file="$1"
34
grep "^CLUSTER_UUID *= *[\"'][^\"']*[\"']" $config_file |
35
sed -e "s/^CLUSTER_UUID *= *\"\([^\"']*\)\".*/\1/"
38
configure_cluster_uuid(){
39
# The cluster uuid goes into maas_cluster.conf, but we also still
40
# keep a copy in maas_local_celeryconfig_cluster.py (hopefully just
41
# temporarily). If an old uuid is configured, we replicate that to
42
# maas_cluster.conf; otherwise, we want to generate one.
46
if [ -n "$(extract_cluster_uuid /etc/maas/maas_cluster.conf)" ]; then
47
# UUID is already set up. Wonderful.
51
# Look for a UUID stored in the old location.
52
uuid="$(extract_cluster_uuid /etc/maas/maas_local_celeryconfig_cluster.py)"
54
if [ -z "$uuid" ]; then
55
# No UUID at all yet. Generate one, and insert it into its
56
# placeholder in the old config location.
58
sed -i "s|^CLUSTER_UUID = None$|CLUSTER_UUID = '$uuid'|" \
59
/etc/maas/maas_local_celeryconfig_cluster.py
62
# Either way, at this point we have a uuid, and it is configured in
63
# the old config location.
65
# Write it to maas_cluster.conf as well. There is no initial
66
# placeholder in this file, so just append the setting.
67
echo "CLUSTER_UUID=\"$uuid\"" >>/etc/maas/maas_cluster.conf
29
71
if [ "$1" = "configure" ] && [ -z "$2" ]; then
35
77
chown root:maas /etc/maas/maas_local_celeryconfig_cluster.py
36
78
chmod 0640 /etc/maas/maas_local_celeryconfig_cluster.py
38
# Generate cluster UUID.
39
if grep -qs "^CLUSTER_UUID\ \= None$" /etc/maas/maas_local_celeryconfig_cluster.py; then
41
sed -i "s|^CLUSTER_UUID\ \= None$|CLUSTER_UUID = '"$uuid"'|" \
42
/etc/maas/maas_local_celeryconfig_cluster.py