Update IP address set - cloud-init updates

This commit is contained in:
Doug Masiero 2024-12-16 17:27:16 -05:00
parent ec854a9c27
commit 124eaaf015

View File

@ -16,7 +16,7 @@ if [ -z "$IP" ] || [ -z "$HOSTNAME" ] || [ -z "$DHCP" ] || [ -z "$GATEWAY" ] ||
fi
# Create the new netplan configuration
sudo tee /etc/netplan/50-cloud-init.yaml << EOL
sudo tee /etc/cloud/cloud.cfg.d/90-installer-network.cfg << EOL
network:
version: 2
ethernets:
@ -26,7 +26,7 @@ EOL
# If DHCP is false, add static IP configuration
if [ "$DHCP" = "false" ]; then
sudo tee -a /etc/netplan/50-cloud-init.yaml << EOL
sudo tee -a /etc/cloud/cloud.cfg.d/90-installer-network.cfg << EOL
addresses:
- ${IP}
routes:
@ -47,5 +47,8 @@ sudo sed -i "s/127.0.1.1.*/127.0.1.1\t${HOSTNAME}/" /etc/hosts
echo "System configuration completed successfully"
# Apply network configuration in the background and exit before it takes effect
nohup bash -c "(sleep 2 && sudo netplan apply) &" > /dev/null 2>&1
# nohup bash -c "(sleep 2 && sudo netplan apply) &" > /dev/null 2>&1
# exit 0
nohup bash -c "(sleep 2 && sudo reboot) &" > /dev/null 2>&1
exit 0