2021-05-03 18:50:04 +00:00
|
|
|
#!/bin/bash
|
2020-05-14 17:36:23 +00:00
|
|
|
|
|
|
|
# This script runs before the installer executes, and sets up ssh during install as well
|
|
|
|
# as rewriting the autoyast file with any substitutions prior to it being evaluated for real
|
|
|
|
|
2021-05-03 18:50:04 +00:00
|
|
|
exec >> /tmp/confluent-pre.log
|
|
|
|
exec 2>> /tmp/confluent-pre.log
|
2021-12-07 12:21:04 +00:00
|
|
|
chmod 600 /tmp/confluent-pre.log
|
2022-08-25 20:45:00 +00:00
|
|
|
cat /tls/*.pem > /etc/confluent/ca.pem
|
2020-07-01 12:57:08 +00:00
|
|
|
nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}')
|
|
|
|
rootpw=$(grep rootpassword: /etc/confluent/confluent.deploycfg|sed -e 's/^rootpassword: //')
|
2020-05-14 17:36:23 +00:00
|
|
|
if [ "$rootpw" = "null" ]; then
|
|
|
|
rootpw="!"
|
|
|
|
fi
|
2020-07-01 12:57:08 +00:00
|
|
|
cryptboot=$(grep encryptboot: /etc/confluent/confluent.deploycfg|sed -e 's/^encryptboot: //')
|
2020-06-03 19:33:10 +00:00
|
|
|
if [ "$cryptboot" != "" ] && [ "$cryptboot" != "none" ] && [ "$cryptboot" != "null" ]; then
|
2020-06-03 20:18:24 +00:00
|
|
|
echo "****Encrypted boot requested, but not implemented for this OS, halting install" > /dev/console
|
|
|
|
[ -f '/tmp/autoconsdev' ] && (echo "****Encryptod boot requested, but not implemented for this OS,halting install" >> $(cat /tmp/autoconsdev))
|
|
|
|
while :; do sleep 86400; done
|
2020-06-03 19:33:10 +00:00
|
|
|
fi
|
2020-05-14 17:36:23 +00:00
|
|
|
|
|
|
|
mkdir ~/.ssh
|
2021-03-09 20:45:40 +00:00
|
|
|
cat /ssh/*pubkey > ~/.ssh/authorized_keys 2>/dev/null
|
|
|
|
|
2020-05-14 17:36:23 +00:00
|
|
|
ssh-keygen -A
|
|
|
|
for i in /etc/ssh/ssh_host*key.pub; do
|
|
|
|
certname=${i/.pub/-cert.pub}
|
2021-05-03 16:48:08 +00:00
|
|
|
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
|
2020-05-14 17:36:23 +00:00
|
|
|
echo HostKey ${i%.pub} >> /etc/ssh/sshd_config
|
|
|
|
echo HostCertificate $certname >> /etc/ssh/sshd_config
|
|
|
|
done
|
|
|
|
/usr/sbin/sshd
|
2021-05-03 16:48:08 +00:00
|
|
|
curl -f https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/functions > /tmp/functions
|
2020-06-01 20:01:26 +00:00
|
|
|
. /tmp/functions
|
2020-07-09 17:37:50 +00:00
|
|
|
ntpcfg=""
|
|
|
|
if grep ^ntpservers: /etc/confluent/confluent.deploycfg > /dev/null; then
|
|
|
|
echo '<ntp-client><ntp_servers config:type="list">' > /tmp/ntp.cfg
|
|
|
|
sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/confluent.deploycfg | sed 1d|sed '$d'| sed -e 's/^- /<ntp_server><address>/' -e 's!$!</address></ntp_server>!' >> /tmp/ntp.cfg
|
|
|
|
echo '</ntp_servers></ntp-client>' >> /tmp/ntp.cfg
|
2020-07-09 19:05:20 +00:00
|
|
|
ntpcfg=$(paste -sd '' /tmp/ntp.cfg)
|
2020-07-09 17:37:50 +00:00
|
|
|
fi
|
2022-08-24 20:07:38 +00:00
|
|
|
export confluent_mgr confluent_profile nodename
|
|
|
|
run_remote pre.custom
|
|
|
|
run_remote_parts pre.d
|
|
|
|
if [ ! -e /tmp/installdisk ]; then
|
|
|
|
mdadm --assemble --scan
|
|
|
|
run_remote_python getinstalldisk
|
|
|
|
if grep ^md /tmp/installdisk > /dev/null; then
|
|
|
|
for md in /dev/disk/*/*; do
|
|
|
|
rmd=$(readlink $md)
|
|
|
|
if echo $rmd|grep $(cat /tmp/installdisk)$ > /dev/null; then
|
|
|
|
echo ${md#/dev/} > /tmp/installdisk
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2022-03-17 16:19:42 +00:00
|
|
|
fi
|
2021-08-20 15:12:22 +00:00
|
|
|
sed -e s'!'%%INSTDISK%%'!'/dev/$(cat /tmp/installdisk)'!' -e s'!'%%NODENAME%%'!'$nodename'!' -e 's!<networking\(.*\)>!'"$ntpcfg"'<networking\1>!' -e "s?%%ROOTPASSWORD%%?${rootpw}?" /tmp/profile/autoinst.xml > /tmp/profile/modified.xml
|
2021-06-22 16:19:54 +00:00
|
|
|
if grep append /tmp/bootloader.xml > /dev/null; then
|
|
|
|
sed -i 's@</general>@</general>'"$(tr -d '\n' < /tmp/bootloader.xml)"'@' /tmp/profile/modified.xml
|
|
|
|
fi
|
|
|
|
sed -i 's#root</username>#root</username>'"$(tr -d '\n' < /tmp/rootkeys.xml)"'#' /tmp/profile/modified.xml
|
|
|
|
sed -i 's@/hwclock>@/hwclock>'"$(tr -d '\n' < /tmp/timezone)"'@' /tmp/profile/modified.xml
|
2021-06-24 12:27:55 +00:00
|
|
|
sed -i 's@<media_url/>@'"$(tr -d '\n' < /tmp/pkgurl)"'@' /tmp/profile/modified.xml
|