~andreserl/maas/maas_packaging_restart

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Andres Rodriguez
  • Date: 2013-11-13 21:46:41 UTC
  • mfrom: (212.1.2 trusty)
  • Revision ID: tarmac-20131113214641-1dknmsovn87de4v0
[r=andreserl,matsubara][bug=][author=andreserl] debian/maas-region-controller.postinst: Allo default-maas-url debconf
option to be preseeded.

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
        fi
121
121
}
122
122
 
 
123
get_default_route_ip() {
 
124
        while read Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT; do
 
125
                [ "$Mask" = "00000000" ] && break
 
126
        done < /proc/net/route
 
127
        interface="$Iface"
 
128
        ipaddr=$(LC_ALL=C /sbin/ip -4 addr list dev "$interface" scope global)
 
129
        ipaddr=${ipaddr#* inet }
 
130
        ipaddr=${ipaddr%%/*}
 
131
        echo $ipaddr
 
132
}
 
133
 
123
134
configure_maas_squid_deb_proxy() {
124
135
        local ipaddr="$1"
125
136
 
158
169
        ##########  Configure DEFAULT_MAAS_URL  #################
159
170
        #########################################################
160
171
 
161
 
        # Obtain IP address of default route and change DEFAULT_MAAS_URL.
162
 
        while read Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT; do
163
 
                [ "$Mask" = "00000000" ] && break
164
 
        done < /proc/net/route
165
 
        interface="$Iface"
166
 
        ipaddr=$(LC_ALL=C /sbin/ip -4 addr list dev "$interface" scope global)
167
 
        ipaddr=${ipaddr#* inet }
168
 
        ipaddr=${ipaddr%%/*}
 
172
        # Obtain IP address of default route and change DEFAULT_MAAS_URL
 
173
        # if default-maas-url has not been preseeded.
 
174
        db_get maas/default-maas-url
 
175
        ipaddr="$RET"
 
176
        if [ -z "$RET" ]; then
 
177
                ipaddr=$(get_default_route_ip)
 
178
        fi
169
179
        # Set the IP address of the interface with default route
170
180
        if [ -n "$ipaddr" ]; then
171
181
                configure_maas_default_url "$ipaddr"