This file is indexed.

postinst is in maas-cluster-controller 1.5.4+bzr2294-0ubuntu1.2.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/sh

set -e

. /usr/share/debconf/confmodule
db_version 2.0

RELEASE=`lsb_release -rs` || RELEASE=""

create_log_dir() {
    # create log dir
    if [ ! -d /var/lib/maas ]; then
        mkdir -p /var/lib/maas
    fi
    if [ ! -d /var/log/maas/oops ]; then
        mkdir -p /var/log/maas/oops
    fi
    # Give appropriate permissions
    chown -R maas:maas /var/lib/maas/
    chown -R maas:maas /var/log/maas
    chmod -R 775 /var/log/maas/oops
}

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
    # both the cluster celery config (which is python) and the cluster
    # config (which is shell).
    sed -n -e "s/^CLUSTER_UUID *= *[\"']\([^\"']*\).*/\1/p" "$1"
}

configure_cluster_uuid(){
    # The cluster uuid goes into maas_cluster.conf, but we also still
    # keep a copy in maas_local_celeryconfig_cluster.py (hopefully just
    # temporarily).  If an old uuid is configured, we replicate that to
    # maas_cluster.conf; otherwise, we want to generate one.
    local uuid


    if [ -n "$(extract_cluster_uuid /etc/maas/maas_cluster.conf)" ]; then
        # UUID is already set up.  Wonderful.
        return
    fi

    # Look for a UUID stored in the old location.
    uuid="$(extract_cluster_uuid /etc/maas/maas_local_celeryconfig_cluster.py)"

    if [ -z "$uuid" ]; then
        # No UUID at all yet.  Generate one, and insert it into its
        # placeholder in the old config location.
        uuid="$(uuidgen)"
        sed -i "s|^CLUSTER_UUID = None$|CLUSTER_UUID = '$uuid'|" \
            /etc/maas/maas_local_celeryconfig_cluster.py
    fi

    # Either way, at this point we have a uuid, and it is configured in
    # the old config location.
    #
    # Write it to maas_cluster.conf as well.  There is no initial
    # placeholder in this file, so just append the setting.
    echo "CLUSTER_UUID=\"$uuid\"" >>/etc/maas/maas_cluster.conf
}

enable_apache_version_mod(){
    COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)
    if [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
        a2enmod version
    fi
}

configure_cluster_http(){
    case $RELEASE in
        12.04|12.10|13.04)
            if [ -e /etc/maas/maas-cluster-http.conf -a \
                ! -e /etc/apache2/conf.d/maas-cluster-http.conf ]; then
                ln -sf /etc/maas/maas-cluster-http.conf /etc/apache2/conf.d/maas-cluster-http.conf
            fi
            ;;
        *)
            # handle apache configs
            if [ -e /etc/maas/maas-cluster-http.conf -a \
                ! -e /etc/apache2/conf-enabled/maas-cluster-http.conf ]; then
                ln -sf /etc/maas/maas-cluster-http.conf /etc/apache2/conf-enabled/maas-cluster-http.conf
            fi
            ;;
    esac
}

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
}

restart_apache2(){
    if [ -x /usr/sbin/invoke-rc.d ]; then
        invoke-rc.d apache2 restart || true
    else
        /etc/init.d/apache2 restart || true
    fi
}

configure_pserv_generator(){
    # Get the MAAS_URL on configure/reconfigure and write it to the conf files.
    db_get maas-cluster-controller/maas-url || true
    if [ -n "$RET" ]; then
        sed -i "s|MAAS_URL=.*|MAAS_URL=\"$RET\"|" /etc/maas/maas_cluster.conf
        # Extract the hostname part.
        HOSTPART=$(echo $RET|awk '{ split($0,array,"/")} END{print array[3] }')
        # And substitute it in-place in pserv.yaml on an indented, non-commented
        # line.
        sed -ri "s|^([[:space:]]+)(#+[[:space:]]*)?(generator:[[:space:]]+https?://)[^:/]+|\1\3$HOSTPART|" /etc/maas/pserv.yaml
    fi
}



if [ "$1" = "configure" ] && [ -z "$2" ]; then
    create_log_dir
    configure_maas_tgt
fi

if [ "$1" = "configure" ]; then
    if dpkg --compare-versions "$2" lt 0.1+bzr1239+dfsg-0ubuntu1; then
        create_log_dir
    fi

    configure_maas_tgt
    configure_pserv_generator

    # These config files may contain a private cluster UUID.  Only maas
    # can read them; only root can write them
    chown root:maas \
        /etc/maas/maas_local_celeryconfig_cluster.py \
        /etc/maas/maas_cluster.conf
    chmod 0640 \
        /etc/maas/maas_local_celeryconfig_cluster.py \
        /etc/maas/maas_cluster.conf

    configure_cluster_uuid
    configure_cluster_authbind
    enable_apache_version_mod
    configure_cluster_http
    restart_apache2
    maas-provision upgrade-cluster
fi

db_stop


# Automatically added by dh_python2:
if which pycompile >/dev/null 2>&1; then
	pycompile -p maas-cluster-controller 
fi

# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/maas-pserv" ] || [ -e "/etc/init/maas-pserv.conf" ]; then
	if [ ! -e "/etc/init/maas-pserv.conf" ]; then
		update-rc.d maas-pserv defaults >/dev/null
	fi
	invoke-rc.d maas-pserv start || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
update-rc.d -f maas-pserv remove >/dev/null || exit $?
# End automatically added section
# Automatically added by dh_installinit
if [ -x "/etc/init.d/maas-cluster-celery" ] || [ -e "/etc/init/maas-cluster-celery.conf" ]; then
	if [ ! -e "/etc/init/maas-cluster-celery.conf" ]; then
		update-rc.d maas-cluster-celery defaults >/dev/null
	fi
	invoke-rc.d maas-cluster-celery start || exit $?
fi
# End automatically added section
# Automatically added by dh_installinit
update-rc.d -f maas-cluster-celery remove >/dev/null || exit $?
# End automatically added section