2022-08-04 20:27:58 +00:00
|
|
|
reverse_uuid() {
|
|
|
|
echo $1 | head -c 8 | tail -c 2
|
|
|
|
echo $1 | head -c 6 | tail -c 2
|
|
|
|
echo $1 | head -c 4 | tail -c 2
|
|
|
|
echo $1 | head -c 2 | tail -c 2
|
|
|
|
echo $1 | head -c 13 | tail -c 2
|
|
|
|
echo $1 | head -c 11 | tail -c 2
|
|
|
|
echo $1 | head -c 18 | tail -c 2
|
|
|
|
echo $1 | head -c 16 | tail -c 2
|
|
|
|
echo $1 | tail -c 18 | sed -e s/-//
|
|
|
|
}
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt() {
|
|
|
|
debconf-set $1 $2
|
|
|
|
echo d-i $1 $3 $2 >> /preseed.cfg
|
|
|
|
}
|
2022-08-04 20:27:58 +00:00
|
|
|
|
|
|
|
dhuuid=$(reverse_uuid $(cat /sys/devices/virtual/dmi/id/product_uuid))
|
|
|
|
dhcpid=$(mktemp)
|
|
|
|
mkdir -p /etc/confluent
|
|
|
|
cp /tls/* /etc/ssl/certs/
|
2022-08-04 20:51:33 +00:00
|
|
|
for nic in $(ip link | grep mtu|grep -v LOOPBACK|cut -d: -f 2|sed -e 's/ //'); do
|
2022-08-04 20:27:58 +00:00
|
|
|
ip link set $nic up
|
|
|
|
done
|
2022-08-04 20:51:33 +00:00
|
|
|
for nic in $(ip link | grep mtu|grep -v LOOPBACK|grep LOWER_UP|cut -d: -f 2|sed -e 's/ //'); do
|
2022-08-04 20:27:58 +00:00
|
|
|
if udhcpc -i $nic -p $dhcpid -t 2 -T 2 -n -x 93:0007 -x 97:00$dhuuid -q; then
|
|
|
|
/opt/confluent/bin/copernicus > /etc/confluent/confluent.info
|
|
|
|
if grep ^MANAGER:.*\\. /etc/confluent/confluent.info ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
ip -4 flush dev $nic
|
|
|
|
done
|
2022-08-04 20:51:33 +00:00
|
|
|
mgr=$(grep ^MANAGER:.*\\. /etc/confluent/confluent.info|head -n 1|cut -d: -f 2|sed -e 's/ //')
|
|
|
|
nodename=$(grep ^NODENAME: /etc/confluent/confluent.info|head -n 1|cut -d: -f 2|sed -e 's/ //')
|
2022-08-04 20:27:58 +00:00
|
|
|
/opt/confluent/bin/clortho $nodename $mgr > /etc/confluent/confluent.apikey
|
|
|
|
apikey=$(cat /etc/confluent/confluent.apikey)
|
|
|
|
cd /etc/confluent
|
|
|
|
wget --header="CONFLUENT_NODENAME: $nodename" --header="CONFLUENT_APIKEY: $apikey" https://$mgr/confluent-api/self/deploycfg
|
2022-08-05 18:05:27 +00:00
|
|
|
cd -
|
|
|
|
predir=$(mktemp -d)
|
|
|
|
cd $predir
|
|
|
|
profile=$(grep ^profile: /etc/confluent/deploycfg|cut -d ' ' -f 2)
|
|
|
|
wget https://$mgr/confluent-public/os/$profile/scripts/pre.sh
|
|
|
|
chmod u+x pre.sh
|
|
|
|
wget https://$mgr/confluent-public/os/$profile/preseed.cfg
|
|
|
|
mv preseed.cfg /
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt auto-install/enable true boolean
|
2022-08-08 18:23:01 +00:00
|
|
|
setdebopt partman/early_command $predir/pre.sh string
|
2022-08-05 18:05:27 +00:00
|
|
|
cd -
|
2022-08-04 20:27:58 +00:00
|
|
|
ip -4 a flush dev $nic
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt netcfg/choose_interface $nic select
|
|
|
|
setdebopt netcfg/get_hostname $nodename string
|
2022-08-04 20:51:33 +00:00
|
|
|
v4cfgmeth=$(grep ipv4_method: /etc/confluent/deploycfg |cut -d: -f 2|sed -e 's/ //')
|
2022-08-04 20:27:58 +00:00
|
|
|
if [ "$v4cfgmeth" = "static" ]; then
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt netcfg/disable_dhcp true boolean
|
2022-08-04 20:51:33 +00:00
|
|
|
v4addr=$(grep ^ipv4_address: /etc/confluent/deploycfg|cut -d: -f 2|sed -e 's/ //')
|
|
|
|
v4gw=$(grep ^ipv4_gateway: /etc/confluent/deploycfg|cut -d: -f 2| sed -e 's/ //')
|
2022-08-04 20:27:58 +00:00
|
|
|
if [ "$v4gw" = "null" ]; then
|
|
|
|
v4gw=""
|
|
|
|
fi
|
2022-08-04 20:51:33 +00:00
|
|
|
v4nm=$(grep ^ipv4_netmask: /etc/confluent/deploycfg|cut -d: -f 2|sed -e 's/ //')
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt netcfg/get_netmask $v4nm string
|
|
|
|
setdebopt netcfg/get_ipaddress $v4addr string
|
|
|
|
setdebopt netcfg/confirm_static true boolean
|
2022-08-04 20:27:58 +00:00
|
|
|
if [ ! -z "$v4gw" ]; then
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt netcfg/get_gateway $v4gw string
|
2022-08-04 20:27:58 +00:00
|
|
|
fi
|
2022-08-04 20:51:33 +00:00
|
|
|
namesrvs=$(sed -n '/^nameservers:/,/^[^-]/p' /etc/confluent/deploycfg|grep ^- | cut -d ' ' -f 2|sed -e 's/ //')
|
2022-08-04 20:27:58 +00:00
|
|
|
for namesrv in "$namesrvs"; do
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt netcfg/get_nameservers $namesrv string
|
2022-08-04 20:27:58 +00:00
|
|
|
done
|
2023-03-30 20:36:40 +00:00
|
|
|
elif [ "$v4cfgmeth" = "dhcp" ]; then
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt netcfg/disable_dhcp false boolean
|
|
|
|
setdebopt netcfg/confirm_static false boolean
|
2022-08-04 20:27:58 +00:00
|
|
|
fi
|
2022-08-05 18:05:27 +00:00
|
|
|
rootpass=$(grep ^rootpassword: /etc/confluent/deploycfg|cut -d ' ' -f 2|sed -e 's/ //')
|
|
|
|
if [ "$rootpass" = null ] || [ -z "$rootpass" ]; then
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt passwd/root-login false boolean
|
2022-08-05 18:05:27 +00:00
|
|
|
else
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt passwd/root-login true boolean
|
|
|
|
setdebopt passwd/root-password-crypted $rootpass string
|
2022-08-05 18:05:27 +00:00
|
|
|
fi
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt time/zone $(grep ^timezone: /etc/confluent/deploycfg|cut -d ' ' -f 2|sed -e 's/ //') string
|
2022-08-05 18:05:27 +00:00
|
|
|
ntpsrvs=$(sed -n '/^ntpservers:/,/^[^-]/p' /etc/confluent/deploycfg|grep ^- | cut -d ' ' -f 2|sed -e 's/ //')
|
|
|
|
for ntpsrv in "$ntpsrvs"; do
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt clock-setup/ntp true boolean
|
|
|
|
setdebopt clock-setup/ntep-server $ntpsrv string
|
2022-08-05 18:05:27 +00:00
|
|
|
done
|
2022-08-05 20:05:26 +00:00
|
|
|
#setdebopt console-setup/layoutcode $(grep ^keymap: /etc/confluent/deploycfg|cut -d ' ' -f 2) string
|
|
|
|
setdebopt debian-installer/locale $(grep ^locale: /etc/confluent/deploycfg|cut -d ' ' -f 2) select
|
2022-08-05 18:05:27 +00:00
|
|
|
domainname=$(grep ^dnsdomain: /etc/confluent/deploycfg|cut -d ' ' -f 2)
|
|
|
|
if [ ! -z "$domainname" ] && [ "$domainname" != "null" ]; then
|
2022-08-05 20:05:26 +00:00
|
|
|
setdebopt netcfg/get_domain $domainname string
|
2022-08-05 18:05:27 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2022-08-04 20:27:58 +00:00
|
|
|
|