#!/bin/bash echo "First start VM" echo "Resize root partition..." parted /dev/sda resizepart 2 100% pvresize /dev/sda2 lvextend -y -f -l +100%FREE /dev/vg01/root resize2fs /dev/vg01/root echo "Generete new machine-id" rm /etc/machine-id systemd-machine-id-setup echo "Recreate new SSHd keys" rm -f /etc/ssh/ssh_host_* dpkg-reconfigure openssh-server --force -f noninteractive echo "Make right /etc/network/interfaces" rm -rf /etc/netplan/* iface=`ip a | grep 'global' | awk {'print $7'}` ip_add=`ifconfig | grep -E "inet(.*)broadcast" | awk {'print $2'}` ip_netm=`ifconfig | grep -E "inet(.*)broadcast" | awk {'print $4'}` ip_gw=`ip r l | grep 'default' | awk {'print $3'}` echo " # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto $iface allow-hotplug $iface iface $iface inet static address $ip_add netmask $ip_netm gateway $ip_gw " > /etc/network/interfaces echo "Create hostname and hosts" ipaddr=$(ip a | grep "scope global" | awk '{print $2}' | sed -r 's/\/.+//') host_name=$(hostname -f) host_shot_name=$(hostname -s) echo $host_name > /etc/hostname echo "127.0.0.1 localhost" > /etc/hosts echo "$ipaddr $host_name $host_shot_name" >> /etc/hosts systemctl enable networking.service systemctl disable systemd-networkd-wait-online.service systemctl disable systemd-networkd.service systemctl disable multipathd.service systemctl disable ModemManager.service apt -y purge cloud-init unattended-upgrades systemd-resolved snapd netplan.io rm -rf /etc/netplan/ rm -rf /usr/share/netplan/ rm -rf ~/snap rm -rf /var/snap rm -rf /var/lib/snapd rm -f /etc/network/*.BeforeVMwareCustomization sed '/^#/d' -i /etc/resolv.conf sed '/^\/root\/first_start.sh &/d' -i /etc/rc.local rm /root/first_start.sh sleep 5 echo "Clean all logs" find /var/log -type f,l | xargs rm -f reboot