2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-09 22:46:45 +00:00
Files
confluent/confluent_osdeploy/suse16/profiles/server/scripts/pre.sh
T
Markus Hilger edf98e3177 Lock root on SUSE 16 when no password is set
The deploycfg carries the literal 'null', which went into the profile as
a password hash, so the installed root account reported a usable
password instead of a locked one. 15 substitutes '!' for this; the sed
delimiter has to move off '!' to carry it.
2026-09-07 06:14:54 +02:00

79 lines
3.5 KiB
Bash

#!/bin/bash
# This script runs before the installer executes, and sets up ssh during install as well
# as rewriting the autoinstall file with any substitutions prior to it being evaluated for real
exec >> /tmp/confluent-pre.log
exec 2>> /tmp/confluent-pre.log
chmod 600 /tmp/confluent-pre.log
cryptboot=$(grep encryptboot: /etc/confluent/confluent.deploycfg|sed -e 's/^encryptboot: //')
if [ "$cryptboot" != "" ] && [ "$cryptboot" != "none" ] && [ "$cryptboot" != "null" ]; then
echo "****Encrypted boot requested, but not implemented for this OS, halting install"
while :; do sleep 86400; done
fi
cp /etc/confluent/tls/*.pem /etc/pki/trust/anchors/
update-ca-certificates
echo "Initializing SSH"
for pubkey in /etc/ssh/ssh_host_*key.pub; do
privfile=${pubkey%.pub}
certfile=${pubkey/.pub/-cert.pub}
python3 /opt/confluent/bin/apiclient /confluent-api/self/sshcert $pubkey > $certfile
if [ -s $certfile ]; then
echo HostCertificate $certfile >> /etc/ssh/sshd_config.d/20_hostkeys.conf
fi
done
systemctl restart sshd
python3 /opt/confluent/bin/apiclient /confluent-public/os/$profile/autoinstall.json > /tmp/autoinstall.json
deployserver=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg|awk '{print $2}')
if [ -z "$deployserver" ] || [ "$deployserver" = "none" ] || [ "$deployserver" = "null" ]; then
deployserver=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg|awk '{print $2}')
fi
if [[ "$deployserver" == *":"* ]]; then
deployserver="[$deployserver]"
fi
source /etc/confluent/functions
hostname $(grep ^NODENAME: /etc/confluent/confluent.info|awk '{print $2}')
run_remote_parts pre.d
sed -i s!%%DEPLOYER%%!$deployserver!g /tmp/autoinstall.json
sed -i s!%%PROFILE%%!$(grep ^profile: /etc/confluent/confluent.deploycfg|awk '{print $2}')!g /tmp/autoinstall.json
rootpw=$(grep ^rootpassword: /etc/confluent/confluent.deploycfg|awk '{print $2}')
if [ "$rootpw" = "null" ]; then
# lock the account, as 15 does. ! is a marker, not a hash anything matches
rootpw='!'
fi
sed -i 's@%%ROOTPASSWORD%%@'"$rootpw"'@g' /tmp/autoinstall.json
sed -i s!%%NODENAME%%!$(hostname)!g /tmp/autoinstall.json
python3 /opt/confluent/bin/apiclient /confluent-public/os/$profile/profile.yaml > /tmp/instprofile.yaml
blargs=$(grep ^installedargs: /tmp/instprofile.yaml | sed -e 's/#.*//' -e 's/^installedargs: //')
sed -i 's!%%INSTALLEDARGS%%!'"$blargs"'!g' /tmp/autoinstall.json
python3 /opt/confluent/bin/apiclient /confluent-public/os/$profile/scripts/getinstalldisk > /tmp/getinstalldisk
locale=$(grep ^locale: /etc/confluent/confluent.deploycfg)
locale=${locale#locale: }
keymap=$(grep ^keymap: /etc/confluent/confluent.deploycfg)
keymap=${keymap#keymap: }
tz=$(grep ^timezone: /etc/confluent/confluent.deploycfg)
tz=${tz#timezone: }
# agama checks against the tzdata list, which carries UTC but no Etc/ zones
if [ "$tz" = "Etc/UTC" ]; then
tz=UTC
fi
sed -i 's!%%TIMEZONE%%!'$tz'!g' /tmp/autoinstall.json
sed -i 's!%%LOCALE%%!'$locale'!g' /tmp/autoinstall.json
sed -i 's!%%KEYMAP%%!'$keymap'!g' /tmp/autoinstall.json
osid=$(grep ^ID= /etc/os-release | sed -e 's/ID=//g' -e 's/"//g')
if [ "$osid" = "sles" ]; then
sed -i 's!%%PRODUCT%%!'SLES'!g' /tmp/autoinstall.json
else
sed -i 's!%%PRODUCT%%!openSUSE_Leap!g' /tmp/autoinstall.json
fi
if [ ! -e /tmp/installdisk ]; then
python3 /tmp/getinstalldisk
fi
installdisk=$(cat /tmp/installdisk)
if [ -z "$installdisk" ]; then
echo "Unable to determine target disk for installation"
sleep inf
fi
echo "Installing to $installdisk"
sed -i 's!%%INSTALLDISK%%!'/dev/$installdisk'!g' /tmp/autoinstall.json