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
|
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-05-03 16:48:08 +00:00
|
|
|
confluent_mgr=$(grep ^deploy_server /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
|
|
|
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|sed -e 's/^rootpassword: //')
|
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-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
|
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
|