2020-05-14 19:47:08 +00:00
|
|
|
#!/bin/sh
|
2020-06-01 14:52:01 +00:00
|
|
|
|
|
|
|
# This runs prior to the installer beginning. This is used to rewrite the
|
2020-07-01 13:52:17 +00:00
|
|
|
# scripted install file, merging data from confluent and identifying
|
2020-06-01 14:52:01 +00:00
|
|
|
# the most appropriate install source.
|
|
|
|
|
|
|
|
# If you want to use a more custom partition plan, the easiest
|
|
|
|
# method is to edit the kicktstart file and comment out or
|
|
|
|
# delete %include /tmp/partitioning
|
2021-04-30 13:39:00 +00:00
|
|
|
if [ -f "/run/install/cmdline.d/01-autocons.conf" ]; then
|
|
|
|
consoledev=$(cat /run/install/cmdline.d/01-autocons.conf | sed -e 's!console=!/dev/!' -e 's/,.*//')
|
2021-04-30 20:27:16 +00:00
|
|
|
TMUX= tmux a <> $consoledev >&0 2>&1 &
|
2021-04-30 13:39:00 +00:00
|
|
|
fi
|
2021-10-06 20:59:47 +00:00
|
|
|
function confluentpython() {
|
|
|
|
if [ -x /usr/libexec/platform-python ]; then
|
|
|
|
/usr/libexec/platform-python $*
|
|
|
|
elif [ -x /usr/bin/python3 ]; then
|
|
|
|
/usr/bin/python3 $*
|
|
|
|
elif [ -x /usr/bin/python ]; then
|
|
|
|
/usr/bin/python $*
|
|
|
|
elif [ -x /usr/bin/python2 ]; then
|
|
|
|
/usr/bin/python2 $*
|
|
|
|
fi
|
|
|
|
}
|
2021-04-30 13:39:00 +00:00
|
|
|
exec >> /tmp/confluent-pre.log
|
2021-05-03 12:57:59 +00:00
|
|
|
exec 2>> /tmp/confluent-pre.log
|
2021-12-07 12:21:04 +00:00
|
|
|
chmod 600 /tmp/confluent-pre.log
|
2021-04-30 13:39:00 +00:00
|
|
|
tail -f /tmp/confluent-pre.log > /dev/tty &
|
2021-04-30 17:38:31 +00:00
|
|
|
logshowpid=$!
|
2021-10-06 20:59:47 +00:00
|
|
|
confluentpython /etc/confluent/apiclient >& /dev/null
|
2021-05-03 19:18:33 +00:00
|
|
|
nicname=$(ip link|grep ^$(cat /tmp/confluent.ifidx): | awk '{print $2}' | awk -F: '{print $1}')
|
|
|
|
nmcli c u $nicname
|
|
|
|
while ip -6 addr | grep tentative > /dev/null; do
|
|
|
|
sleep 0.5
|
|
|
|
done
|
2020-07-01 12:57:08 +00:00
|
|
|
nodename=$(grep ^NODENAME /etc/confluent/confluent.info|awk '{print $2}')
|
|
|
|
locale=$(grep ^locale: /etc/confluent/confluent.deploycfg)
|
2020-05-18 16:52:31 +00:00
|
|
|
locale=${locale#locale: }
|
2020-07-01 12:57:08 +00:00
|
|
|
keymap=$(grep ^keymap: /etc/confluent/confluent.deploycfg)
|
2020-05-18 18:55:35 +00:00
|
|
|
keymap=${keymap#keymap: }
|
2020-05-18 16:52:31 +00:00
|
|
|
echo lang $locale > /tmp/langinfo
|
2020-05-18 18:55:35 +00:00
|
|
|
echo keyboard --vckeymap=$keymap >> /tmp/langinfo
|
2020-07-01 12:57:08 +00:00
|
|
|
tz=$(grep ^timezone: /etc/confluent/confluent.deploycfg)
|
2020-05-18 16:52:31 +00:00
|
|
|
tz=${tz#timezone: }
|
2022-06-17 13:06:33 +00:00
|
|
|
MVER=$(grep VERSION_ID /etc/os-release|cut -d = -f 2 |cut -d . -f 1|cut -d '"' -f 2)
|
2020-07-09 16:11:32 +00:00
|
|
|
ntpsrvs=""
|
2022-06-17 13:06:33 +00:00
|
|
|
if [ "$MVER" -ge 9 ]; then
|
|
|
|
if grep ^ntpservers: /etc/confluent/confluent.deploycfg > /dev/null; then
|
|
|
|
for ntpsrv in $(sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/confluent.deploycfg|sed 1d|sed '$d' | sed -e 's/^- //'); do
|
|
|
|
echo timesource --ntp-server $ntpsrv >> /tmp/timezone
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if grep ^ntpservers: /etc/confluent/confluent.deploycfg > /dev/null; then
|
|
|
|
ntpsrvs="--ntpservers="$(sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/confluent.deploycfg|sed 1d|sed '$d' | sed -e 's/^- //' | paste -sd,)
|
|
|
|
fi
|
2020-07-09 16:11:32 +00:00
|
|
|
fi
|
2022-06-17 13:06:33 +00:00
|
|
|
echo timezone $ntpsrvs $tz --utc >> /tmp/timezone
|
2020-07-01 12:57:08 +00:00
|
|
|
rootpw=$(grep ^rootpassword /etc/confluent/confluent.deploycfg | awk '{print $2}')
|
2020-05-14 19:47:08 +00:00
|
|
|
if [ "$rootpw" = null ]; then
|
|
|
|
echo "rootpw --lock" > /tmp/rootpw
|
|
|
|
else
|
|
|
|
echo "rootpw --iscrypted $rootpw" > /tmp/rootpw
|
|
|
|
fi
|
2021-05-03 16:48:08 +00:00
|
|
|
curl -sf https://$confluent_mgr/confluent-public/os/$confluent_profile/profile.yaml > /tmp/instprofile.yaml
|
2020-12-01 17:55:41 +00:00
|
|
|
blargs=$(grep ^installedargs: /tmp/instprofile.yaml | sed -e 's/#.*//' -e 's/^installedargs: //')
|
2020-12-01 15:53:26 +00:00
|
|
|
if [ ! -z "$blargs" ]; then
|
|
|
|
blargs=' --append="'$blargs'"'
|
|
|
|
fi
|
2020-07-01 12:57:08 +00:00
|
|
|
grubpw=$(grep ^grubpassword /etc/confluent/confluent.deploycfg | awk '{print $2}')
|
2020-06-02 20:05:44 +00:00
|
|
|
if [ "$grubpw" = "null" ]; then
|
|
|
|
touch /tmp/grubpw
|
|
|
|
else
|
2020-12-01 15:53:26 +00:00
|
|
|
blargs=" --iscrypted --password=$grubpw $blargs"
|
|
|
|
fi
|
|
|
|
if [ ! -z "$blargs" ]; then
|
|
|
|
echo "bootloader $blargs" > /tmp/grubpw
|
2020-06-02 20:05:44 +00:00
|
|
|
fi
|
2021-04-30 20:27:16 +00:00
|
|
|
ssh-keygen -A
|
2022-12-14 21:15:30 +00:00
|
|
|
rm /etc/ssh/ssh_host_dsa_key*
|
2020-05-14 19:47:08 +00:00
|
|
|
for pubkey in /etc/ssh/ssh_host*key.pub; do
|
|
|
|
certfile=${pubkey/.pub/-cert.pub}
|
2021-05-03 16:48:08 +00:00
|
|
|
curl -sf -X POST -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $(cat /etc/confluent/confluent.apikey)" -d @$pubkey https://$confluent_mgr/confluent-api/self/sshcert > $certfile
|
2020-05-14 19:47:08 +00:00
|
|
|
echo HostCertificate $certfile >> /etc/ssh/sshd_config.anaconda
|
|
|
|
done
|
|
|
|
/usr/sbin/sshd -f /etc/ssh/sshd_config.anaconda
|
2020-07-01 12:57:08 +00:00
|
|
|
cryptboot=$(grep ^encryptboot: /etc/confluent/confluent.deploycfg | awk '{print $2}')
|
2020-06-02 20:05:44 +00:00
|
|
|
LUKSPARTY=''
|
2021-05-03 19:54:39 +00:00
|
|
|
touch /tmp/cryptpkglist
|
2023-09-19 17:01:10 +00:00
|
|
|
touch /tmp/pkglist
|
2020-10-07 19:27:06 +00:00
|
|
|
touch /tmp/addonpackages
|
2020-07-01 17:33:59 +00:00
|
|
|
if [ "$cryptboot" == "tpm2" ]; then
|
2020-07-01 12:57:08 +00:00
|
|
|
LUKSPARTY="--encrypted --passphrase=$(cat /etc/confluent/confluent.apikey)"
|
2020-06-02 20:05:44 +00:00
|
|
|
echo $cryptboot >> /tmp/cryptboot
|
2021-05-03 19:18:33 +00:00
|
|
|
echo clevis-dracut >> /tmp/cryptpkglist
|
2020-06-02 20:05:44 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2021-05-03 19:54:39 +00:00
|
|
|
export confluent_mgr confluent_profile nodename
|
2021-05-03 16:48:08 +00:00
|
|
|
curl -sf https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/functions > /tmp/functions
|
2020-06-01 13:08:41 +00:00
|
|
|
. /tmp/functions
|
2022-03-18 16:09:43 +00:00
|
|
|
confluentpython /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/kickstart.custom -o /tmp/kickstart.custom
|
2021-04-22 16:08:25 +00:00
|
|
|
run_remote pre.custom
|
2021-05-03 16:48:08 +00:00
|
|
|
run_remote_parts pre.d
|
2021-10-25 14:05:15 +00:00
|
|
|
confluentpython /etc/confluent/apiclient /confluent-public/os/$confluent_profile/kickstart -o /tmp/kickstart.base
|
2023-09-19 17:01:10 +00:00
|
|
|
if grep '^%include /tmp/pkglist' /tmp/kickstart.* > /dev/null; then
|
|
|
|
confluentpython /etc/confluent/apiclient /confluent-public/os/$confluent_profile/packagelist -o /tmp/pkglist
|
|
|
|
fi
|
2021-10-25 14:05:15 +00:00
|
|
|
grep '^%include /tmp/partitioning' /tmp/kickstart.* > /dev/null || touch /tmp/installdisk
|
2021-04-23 13:08:50 +00:00
|
|
|
if [ ! -e /tmp/installdisk ]; then
|
2021-04-22 16:12:58 +00:00
|
|
|
run_remote_python getinstalldisk
|
|
|
|
fi
|
2023-09-19 17:01:10 +00:00
|
|
|
confluentpython /etc/confluent/apiclient /confluent-public/os/$confluent_profile/partitioning -o /tmp/partitioning.template
|
2021-10-25 14:05:15 +00:00
|
|
|
grep '^%include /tmp/partitioning' /tmp/kickstart.* > /dev/null || rm /tmp/installdisk
|
2021-04-22 16:12:58 +00:00
|
|
|
if [ -e /tmp/installdisk -a ! -e /tmp/partitioning ]; then
|
2023-09-19 17:01:10 +00:00
|
|
|
INSTALLDISK=$(cat /tmp/installdisk)
|
|
|
|
sed -e s/%%INSTALLDISK%%/$INSTALLDISK/ -e s/%%LUKSHOOK%%/$LUKSPARTY/ /tmp/partitioning.template > /tmp/partitioning
|
2021-10-25 14:05:15 +00:00
|
|
|
dd if=/dev/zero of=/dev/$(cat /tmp/installdisk) bs=1M count=1 >& /dev/null
|
|
|
|
vgchange -a n >& /dev/null
|
2020-05-14 19:47:08 +00:00
|
|
|
fi
|
2021-04-30 20:27:16 +00:00
|
|
|
kill $logshowpid
|