~matsubara/maas/packaging.quantal-remove-adt-header

« back to all changes in this revision

Viewing changes to debian/maas-cluster-controller.postinst

  • Committer: Tarmac
  • Author(s): Jeroen Vermeulen
  • Date: 2012-12-12 12:48:37 UTC
  • mfrom: (149.1.1 q-pkg-bug-1086239)
  • Revision ID: tarmac-20121212124837-95rzvgiiawe78vad
[r=rvb][bug=1086239][author=jtv] Backport packaging r156: Duplicate CLUSTER_UUID into maas_cluster.conf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
        ln -sf /var/lib/maas/ephemeral/tgt.conf /etc/tgt/conf.d/maas.conf
27
27
}
28
28
 
 
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/"
 
36
}
 
37
 
 
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.
 
43
    local uuid
 
44
 
 
45
 
 
46
    if [ -n "$(extract_cluster_uuid /etc/maas/maas_cluster.conf)" ]; then
 
47
        # UUID is already set up.  Wonderful.
 
48
        return
 
49
    fi
 
50
 
 
51
    # Look for a UUID stored in the old location.
 
52
    uuid="$(extract_cluster_uuid /etc/maas/maas_local_celeryconfig_cluster.py)"
 
53
 
 
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.
 
57
        uuid="$(uuidgen)"
 
58
        sed -i "s|^CLUSTER_UUID = None$|CLUSTER_UUID = '$uuid'|" \
 
59
            /etc/maas/maas_local_celeryconfig_cluster.py
 
60
    fi
 
61
 
 
62
    # Either way, at this point we have a uuid, and it is configured in
 
63
    # the old config location.
 
64
    #
 
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
 
68
}
 
69
 
 
70
 
29
71
if [ "$1" = "configure" ] && [ -z "$2" ]; then
30
72
    # logging
31
73
    create_log_dir
35
77
    chown root:maas /etc/maas/maas_local_celeryconfig_cluster.py
36
78
    chmod 0640 /etc/maas/maas_local_celeryconfig_cluster.py
37
79
 
38
 
    # Generate cluster UUID.
39
 
    if grep -qs "^CLUSTER_UUID\ \= None$" /etc/maas/maas_local_celeryconfig_cluster.py; then
40
 
        uuid="$(uuidgen)"
41
 
        sed -i "s|^CLUSTER_UUID\ \= None$|CLUSTER_UUID = '"$uuid"'|" \
42
 
                       /etc/maas/maas_local_celeryconfig_cluster.py
43
 
    fi
44
 
 
45
80
    configure_maas_tgt
46
81
fi
47
82
 
63
98
    fi
64
99
fi
65
100
 
 
101
if [ "$1" = "configure" ]; then
 
102
    configure_cluster_uuid
 
103
fi
 
104
 
66
105
#DEBHELPER#
67
106
exit 0