2020-04-09 20:13:33 +00:00
|
|
|
#!/bin/sh
|
2020-04-14 20:34:50 +00:00
|
|
|
[ -e /tmp/confluent.initq ] && return 0
|
|
|
|
echo -n "" > /tmp/confluent.initq
|
2020-04-09 20:13:33 +00:00
|
|
|
cd /sys/class/net
|
|
|
|
for currif in *; do
|
|
|
|
ip link set $currif up
|
|
|
|
done
|
|
|
|
cd -
|
|
|
|
while ! grep MANAGER /tmp/confluent.info >& /dev/null; do
|
2020-04-10 20:46:41 +00:00
|
|
|
/opt/confluent/bin/copernicus -t > /tmp/confluent.info
|
2020-04-09 20:13:33 +00:00
|
|
|
done
|
|
|
|
read ifidx <<EOF
|
2020-04-10 20:46:41 +00:00
|
|
|
$(grep ^MANAGER /tmp/confluent.info|grep fe80|sed -e s/.*%//)
|
2020-04-09 20:13:33 +00:00
|
|
|
EOF
|
2020-04-10 20:46:41 +00:00
|
|
|
read mgr << EOF
|
|
|
|
$(grep ^MANAGER /tmp/confluent.info|grep fe80|awk '{print $2}')
|
|
|
|
EOF
|
|
|
|
mgridx=${mgr#*%}
|
2020-04-09 20:13:33 +00:00
|
|
|
ifname=$(ip link |grep ^$ifidx:|awk '{print $2}')
|
|
|
|
ifname=${ifname%:}
|
|
|
|
echo $ifname > /tmp/net.ifaces
|
2020-04-14 20:34:50 +00:00
|
|
|
nodename=$(grep ^NODENAME /tmp/confluent.info|awk '{print $2}')
|
2020-04-10 20:46:41 +00:00
|
|
|
#TODO: blkid --label <whatever> to find mounted api
|
|
|
|
|
|
|
|
if [ -z "$apikey" ]; then
|
|
|
|
apikey=$(/opt/confluent/bin/clortho $nodename $mgr)
|
|
|
|
fi
|
2020-04-16 15:54:40 +00:00
|
|
|
oum=$(umask)
|
|
|
|
umask 0077
|
|
|
|
echo $apikey > /etc/confluent.apikey
|
|
|
|
umask $oum
|
2020-04-14 20:34:50 +00:00
|
|
|
mgr="[$mgr]"
|
2020-04-10 20:46:41 +00:00
|
|
|
curl -f -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $apikey" https://$mgr/confluent-api/self/deploycfg > /tmp/confluent.deploycfg
|
|
|
|
|
|
|
|
mgr=$(grep ^ipv4_server: /tmp/confluent.deploycfg)
|
|
|
|
mgr=${mgr#ipv4_server: }
|
|
|
|
profilename=$(grep ^profile: /tmp/confluent.deploycfg)
|
|
|
|
profilename=${profilename#profile: }
|
|
|
|
proto=$(grep ^protocol: /tmp/confluent.deploycfg)
|
|
|
|
proto=${proto#protocol: }
|
|
|
|
echo inst.repo=$proto://$mgr/confluent-public/os/$profilename/distribution >> /etc/cmdline.d/01-confluent.conf
|
|
|
|
echo inst.ks=$proto://$mgr/confluent-public/os/$profilename/kickstart >> /etc/cmdline.d/01-confluent.conf
|
2020-04-14 20:34:50 +00:00
|
|
|
kickstart=$proto://$mgr/confluent-public/os/$profilename/kickstart
|
|
|
|
root=anaconda-net:$proto://$mgr/confluent-public/os/$profilename/distribution
|
|
|
|
export kickstart
|
|
|
|
export root
|
2020-04-10 20:46:41 +00:00
|
|
|
autoconfigmethod=$(grep ipv4_method /tmp/confluent.deploycfg)
|
2020-04-22 20:12:33 +00:00
|
|
|
autoconfigmethod=${autoconfigmethod#ipv4_method: }
|
2020-04-10 20:46:41 +00:00
|
|
|
if [ "$autoconfigmethod" = "dhcp" ]; then
|
|
|
|
echo ip=$ifname:dhcp
|
|
|
|
else
|
|
|
|
v4addr=$(grep ^ipv4_address: /tmp/confluent.deploycfg)
|
|
|
|
v4addr=${v4addr#ipv4_address: }
|
|
|
|
v4gw=$(grep ^ipv4_gateway: /tmp/confluent.deploycfg)
|
|
|
|
v4gw=${v4gw#ipv4_gateway: }
|
|
|
|
if [ "$v4gw" = "null" ]; then
|
|
|
|
v4gw=""
|
|
|
|
fi
|
|
|
|
v4nm=$(grep ipv4_netmask: /tmp/confluent.deploycfg)
|
|
|
|
v4nm=${v4nm#ipv4_netmask: }
|
2020-04-20 17:05:10 +00:00
|
|
|
echo ip=$v4addr::$v4gw:$v4nm:$nodename:$ifname:none >> /etc/cmdline.d/01-confluent.conf
|
2020-04-10 20:46:41 +00:00
|
|
|
fi
|
2020-04-20 18:27:14 +00:00
|
|
|
nameserversec=0
|
|
|
|
while read -r entry; do
|
|
|
|
if [ $nameserversec = 1 ]; then
|
|
|
|
if [[ $entry == "-"* ]]; then
|
|
|
|
echo nameserver=${entry#- } >> /etc/cmdline.d/01-confluent.conf
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
nameserversec=0
|
|
|
|
if [ ${entry%:*} = "nameservers" ]; then
|
|
|
|
nameserversec=1
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
done < /tmp/confluent.deploycfg
|
2020-04-10 20:46:41 +00:00
|
|
|
|