2021-05-03 18:50:04 +00:00
|
|
|
#!/bin/bash
|
2020-05-14 18:49:53 +00:00
|
|
|
|
|
|
|
# This script runs at the end of the final boot, updating status
|
2021-05-03 18:50:04 +00:00
|
|
|
exec >> /var/log/confluent/confluent-firstboot.log
|
|
|
|
exec 2>> /var/log/confluent/confluent-firstboot.log
|
2021-12-07 12:21:04 +00:00
|
|
|
chmod 600 /var/log/confluent/confluent-firstboot.log
|
2020-05-14 18:49:53 +00:00
|
|
|
|
2020-05-14 17:36:23 +00:00
|
|
|
nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}')
|
2021-10-12 20:58:42 +00:00
|
|
|
v6cfg=$(grep ^ipv6_method: /etc/confluent/confluent.deploycfg)
|
|
|
|
v6cfg=${v6cfg#ipv6_method: }
|
|
|
|
if [ "$v6cfg" = "static" ]; then
|
|
|
|
confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg)
|
|
|
|
confluent_mgr=${confluent_mgr#deploy_server_v6: }
|
|
|
|
confluent_mgr="[$confluent_mgr]"
|
|
|
|
else
|
|
|
|
confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg)
|
|
|
|
confluent_mgr=${confluent_mgr#deploy_server: }
|
|
|
|
fi
|
2021-11-09 12:10:38 +00:00
|
|
|
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|sed -e 's/^profile: //')
|
2020-05-14 17:36:23 +00:00
|
|
|
proto=$(grep ^protocol: /etc/confluent/confluent.deploycfg |awk '{print $2}')
|
2021-05-03 16:48:08 +00:00
|
|
|
confluent_apikey=$(cat /etc/confluent/confluent.apikey)
|
2020-06-01 20:01:26 +00:00
|
|
|
. /etc/confluent/functions
|
2021-08-09 19:19:36 +00:00
|
|
|
while ! ping -c 1 $confluent_mgr >& /dev/null; do
|
|
|
|
sleep 1
|
|
|
|
done
|
2020-06-01 20:01:26 +00:00
|
|
|
|
2021-05-03 20:47:24 +00:00
|
|
|
for i in /etc/ssh/ssh_host*key.pub; do
|
|
|
|
certname=${i/.pub/-cert.pub}
|
|
|
|
curl -f -X POST -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $(cat /etc/confluent/confluent.apikey)" -d @$i https://$confluent_mgr/confluent-api/self/sshcert > $certname
|
|
|
|
done
|
|
|
|
systemctl restart sshd
|
2021-11-08 21:34:26 +00:00
|
|
|
run_remote_python confignet
|
2020-10-16 15:34:43 +00:00
|
|
|
run_remote firstboot.custom
|
2021-03-18 18:37:54 +00:00
|
|
|
|
|
|
|
# Firstboot scripts may be placed into firstboot.d, e.g. firstboot.d/01-firstaction.sh, firstboot.d/02-secondaction.sh
|
2021-05-03 16:48:08 +00:00
|
|
|
run_remote_parts firstboot.d
|
2021-03-18 18:37:54 +00:00
|
|
|
|
|
|
|
# Induce execution of remote configuration, e.g. ansible plays in ansible/firstboot.d/
|
2021-05-03 16:48:08 +00:00
|
|
|
run_remote_config firstboot.d
|
2021-03-18 18:37:54 +00:00
|
|
|
|
2021-05-03 16:48:08 +00:00
|
|
|
curl --capath /etc/confluent/tls -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" -f -X POST -d "status: complete" https://$confluent_mgr/confluent-api/self/updatestatus
|