blob: 58c560c7f037322fa4d8eea60f610818b4e371b5 [file] [log] [blame]
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +04001#!/bin/sh -e
2#
3# rc.local
4#
5# This script is executed at the end of each multiuser runlevel.
6# Make sure that the script will "exit 0" on success or any other
7# value on error.
8#
9# In order to enable or disable this script just change the execution
10# bits.
11#
12# By default this script does nothing.
13
Denis Egorenko88f1cf52019-05-24 11:04:01 +040014update_from_metadata_fields() {
15 local metadataIp="169.254.169.254"
16 local metadataFiels=$(curl -s --connect-timeout 5 169.254.169.254/openstack/latest/meta_data.json | jq -r .meta)
17 if [ -n "${metadataFiels}" ]; then
18 local dmz=$(echo ${metadataFiels} | jq -r .dmz)
19 if [ "${dmz}" == "true" ]
20 local dmzGateway=$(echo ${metadataFiels} | jq -r .dmz_gateway)
21 if [ -n "${dmzGateway}" ]; then
22 local curDefault=$(ip r | grep 'default via' | cut -f 3 -d ' ')
23 if [ "${curDefault}" != "${dmzGateway}" ]; then
24 ip r del default
25 ip r add default via ${dmzGateway}
26 fi
27 fi
28 fi
29 fi
30}
31
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040032if [ ! -f /tmp/bootstrap_interfaces ] && [ -d /srv/salt/reclass/nodes/_generated ]; then
33 sed -i "s/single_address:.*/single_address: $(hostname -I | cut -d ' ' -f 1)/g" /srv/salt/reclass/nodes/cfg01.*
34 touch /tmp/bootstrap_interfaces
35fi
36
Denis Egorenko88f1cf52019-05-24 11:04:01 +040037update_from_metadata_fields || echo "Can't update settings from metadata fields"
38
Ivan Berezovskiyc46e7c02018-10-29 18:22:09 +040039exit 0