2020-05-15 20:03:25 +00:00
|
|
|
#!/bin/sh
|
2023-04-12 15:22:27 +00:00
|
|
|
HOME=$(getent passwd $(whoami)|cut -d: -f 6)
|
|
|
|
export HOME
|
2020-06-01 16:25:30 +00:00
|
|
|
|
|
|
|
# This script is executed on the first boot after install has
|
|
|
|
# completed. It is best to edit the middle of the file as
|
|
|
|
# noted below so custom commands are executed before
|
|
|
|
# the script notifies confluent that install is fully complete.
|
|
|
|
|
2020-05-15 20:03:25 +00:00
|
|
|
nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}')
|
2021-05-03 16:48:08 +00:00
|
|
|
confluent_apikey=$(cat /etc/confluent/confluent.apikey)
|
2021-12-09 13:31:07 +00:00
|
|
|
v4cfg=$(grep ^ipv4_method: /etc/confluent/confluent.deploycfg)
|
|
|
|
v4cfg=${v4cfg#ipv4_method: }
|
|
|
|
if [ "$v4cfg" = "static" ] || [ "$v4cfg" = "dhcp" ]; then
|
|
|
|
confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg)
|
|
|
|
confluent_mgr=${confluent_mgr#deploy_server: }
|
|
|
|
confluent_pingtarget=$confluent_mgr
|
2022-10-25 12:21:42 +00:00
|
|
|
fi
|
|
|
|
if [ -z "$confluent_mgr" ]; then
|
2021-10-12 21:23:18 +00:00
|
|
|
confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg)
|
|
|
|
confluent_mgr=${confluent_mgr#deploy_server_v6: }
|
2022-12-09 16:19:06 +00:00
|
|
|
if [ -z "$confluent_mgr" ]; then
|
|
|
|
confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg)
|
|
|
|
confluent_mgr=${confluent_mgr#deploy_server: }
|
|
|
|
confluent_pingtarget=$confluent_mgr
|
|
|
|
else
|
|
|
|
confluent_pingtarget=$confluent_mgr
|
|
|
|
confluent_mgr="[$confluent_mgr]"
|
|
|
|
fi
|
2021-10-12 21:23:18 +00:00
|
|
|
fi
|
2021-05-03 16:48:08 +00:00
|
|
|
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg|awk '{print $2}')
|
|
|
|
export nodename confluent_mgr confluent_profile
|
2020-06-01 16:25:30 +00:00
|
|
|
. /etc/confluent/functions
|
2022-10-28 13:30:12 +00:00
|
|
|
(
|
2021-04-30 18:08:42 +00:00
|
|
|
exec >> /var/log/confluent/confluent-firstboot.log
|
2021-05-03 12:57:59 +00:00
|
|
|
exec 2>> /var/log/confluent/confluent-firstboot.log
|
2021-12-07 12:21:04 +00:00
|
|
|
chmod 600 /var/log/confluent/confluent-firstboot.log
|
2023-02-28 17:12:36 +00:00
|
|
|
if [ ! -f /etc/confluent/firstboot.ran ]; then
|
|
|
|
cat /etc/confluent/tls/*.pem >> /etc/pki/tls/certs/ca-bundle.crt
|
|
|
|
confluentpython /root/confignet
|
|
|
|
rm /root/confignet
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-10-12 21:23:18 +00:00
|
|
|
while ! ping -c 1 $confluent_pingtarget >& /dev/null; do
|
2021-08-09 19:19:36 +00:00
|
|
|
sleep 1
|
|
|
|
done
|
2020-06-01 16:25:30 +00:00
|
|
|
|
2023-02-28 17:12:36 +00:00
|
|
|
|
2021-04-29 13:20:24 +00:00
|
|
|
if [ ! -f /etc/confluent/firstboot.ran ]; then
|
|
|
|
touch /etc/confluent/firstboot.ran
|
2020-06-01 16:25:30 +00:00
|
|
|
|
2021-04-29 13:20:24 +00:00
|
|
|
run_remote firstboot.custom
|
|
|
|
# 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
|
2020-06-01 16:25:30 +00:00
|
|
|
|
2021-04-29 13:20:24 +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-04-29 13:20:24 +00:00
|
|
|
fi
|
2021-03-18 18:12:19 +00:00
|
|
|
|
2021-05-03 16:48:08 +00:00
|
|
|
curl -X POST -d 'status: complete' -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
|
2020-05-15 20:03:25 +00:00
|
|
|
systemctl disable firstboot
|
|
|
|
rm /etc/systemd/system/firstboot.service
|
2021-04-29 13:20:24 +00:00
|
|
|
rm /etc/confluent/firstboot.ran
|
2022-10-28 13:30:12 +00:00
|
|
|
) &
|
|
|
|
tail --pid $! -n 0 -F /var/log/confluent/confluent-firstboot.log > /dev/console
|