2020-06-18 16:36:00 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# 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-18 16:36:00 +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
|
|
|
|
|
2020-08-05 16:14:29 +00:00
|
|
|
mgraw=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info| sed -e 's/^EXTMGRINFO: //' | awk -F'|' '{print $1 " " $2 " " $3}' |grep 1$ | awk 'NR < 2')
|
|
|
|
if [ -z "$mgraw" ]; then
|
|
|
|
mgraw=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info| sed -e 's/^EXTMGRINFO: //' | awk -F'|' '{print $1 " " $2 " " $3}' | awk 'NR < 2')
|
|
|
|
fi
|
|
|
|
mgraw=$(echo $mgraw | awk '{print $1}')
|
|
|
|
if echo $mgraw | grep '%' > /dev/null; then
|
|
|
|
echo $mgraw | awk -F% '{print $2}' > /tmp/confluent.ifidx
|
|
|
|
fi
|
|
|
|
|
|
|
|
iface=$(grep -H $(cat /tmp/confluent.ifidx) /sys/class/net/*/ifindex | awk -F/ '{print $5}')
|
|
|
|
nmcli c u $iface
|
|
|
|
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-06-18 16:36:00 +00:00
|
|
|
locale=${locale#locale: }
|
2020-07-01 12:57:08 +00:00
|
|
|
keymap=$(grep ^keymap: /etc/confluent/confluent.deploycfg)
|
2020-06-18 16:36:00 +00:00
|
|
|
keymap=${keymap#keymap: }
|
|
|
|
echo lang $locale > /tmp/langinfo
|
|
|
|
echo keyboard --vckeymap=$keymap >> /tmp/langinfo
|
2020-07-01 12:57:08 +00:00
|
|
|
tz=$(grep ^timezone: /etc/confluent/confluent.deploycfg)
|
2020-06-18 16:36:00 +00:00
|
|
|
tz=${tz#timezone: }
|
2020-07-09 20:02:53 +00:00
|
|
|
ntpsrvs=""
|
|
|
|
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
|
|
|
|
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-06-18 16:36:00 +00:00
|
|
|
if [ "$rootpw" = null ]; then
|
|
|
|
echo "rootpw --lock" > /tmp/rootpw
|
|
|
|
else
|
|
|
|
echo "rootpw --iscrypted $rootpw" > /tmp/rootpw
|
|
|
|
fi
|
2020-12-01 15:53:26 +00:00
|
|
|
curl -f https://$mgr/confluent-public/os/$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-18 16:36:00 +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-18 16:36:00 +00:00
|
|
|
fi
|
2020-06-18 18:28:44 +00:00
|
|
|
ssh-keygen -A
|
2020-07-23 18:41:59 +00:00
|
|
|
for pubkey in /etc/ssh/ssh_host_*_key.pub; do
|
2020-06-18 16:36:00 +00:00
|
|
|
certfile=${pubkey/.pub/-cert.pub}
|
2020-07-01 12:57:08 +00:00
|
|
|
curl -f -X POST -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $(cat /etc/confluent/confluent.apikey)" -d @$pubkey https://$mgr/confluent-api/self/sshcert > $certfile
|
2020-06-18 16:36:00 +00:00
|
|
|
echo HostCertificate $certfile >> /etc/ssh/sshd_config.anaconda
|
|
|
|
done
|
2020-08-05 16:14:29 +00:00
|
|
|
cp /etc/ssh/sshd_config.anaconda /etc/ssh/sshd_config
|
2020-06-18 16:36:00 +00:00
|
|
|
/usr/sbin/sshd -f /etc/ssh/sshd_config.anaconda
|
2020-08-05 16:14:29 +00:00
|
|
|
systemctl start sshd
|
2020-06-18 16:36: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/,.*//')
|
2020-06-19 14:24:51 +00:00
|
|
|
TMUX= tmux a <> $consoledev >&0 2>&1 &
|
2020-06-18 16:36:00 +00:00
|
|
|
fi
|
2020-07-01 12:57:08 +00:00
|
|
|
cryptboot=$(grep ^encryptboot: /etc/confluent/confluent.deploycfg | awk '{print $2}')
|
2020-06-18 16:36:00 +00:00
|
|
|
LUKSPARTY=''
|
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-18 16:36:00 +00:00
|
|
|
echo $cryptboot >> /tmp/cryptboot
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
export mgr profile nodename
|
|
|
|
curl -f https://$mgr/confluent-public/os/$profile/scripts/functions > /tmp/functions
|
|
|
|
. /tmp/functions
|
|
|
|
run_remote_python getinstalldisk
|
|
|
|
if [ -e /tmp/installdisk ]; then
|
|
|
|
echo clearpart --all --initlabel >> /tmp/partitioning
|
|
|
|
echo ignoredisk --only-use $(cat /tmp/installdisk) >> /tmp/partitioning
|
2020-06-18 19:26:35 +00:00
|
|
|
echo autopart --type=thinp --nohome $LUKSPARTY >> /tmp/partitioning
|
2020-06-18 16:36:00 +00:00
|
|
|
fi
|
2020-06-19 12:28:25 +00:00
|
|
|
cd $(mktemp -d)
|
2020-08-05 13:45:22 +00:00
|
|
|
if [ -x /usr/bin/python ]; then
|
2020-08-05 16:35:16 +00:00
|
|
|
python=/usr/bin/python
|
2020-08-05 13:45:22 +00:00
|
|
|
elif [ -x /usr/libexec/platform-python ]; then
|
|
|
|
python=/usr/libexec/platform-python
|
|
|
|
fi
|
|
|
|
$python /etc/confluent/apiclient /confluent-public/os/$profile/image.rpm -o image.rpm
|
2020-06-19 12:28:25 +00:00
|
|
|
rpm2cpio image.rpm | cpio -dumi
|
2020-06-19 13:13:19 +00:00
|
|
|
ln -s $(find $(pwd) -name *img) /tmp/install.img
|
|
|
|
cd -
|
2020-08-05 13:45:22 +00:00
|
|
|
$python /etc/confluent/apiclient /confluent-public/os/$profile/kickstart.custom -o /tmp/kickstart.custom
|
2020-07-24 19:45:19 +00:00
|
|
|
run_remote pre.custom
|