Added building Ubuntu 20.04 template
This commit is contained in:
@ -0,0 +1,85 @@
|
||||
#!/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"
|
||||
if [ -z "$(cat /etc/network/interfaces | grep "inet dhcp")" ]; then
|
||||
# No DHCP
|
||||
iface=$(cat /etc/network/interfaces | grep "iface" | sed '/loopback/d' | awk '{print $2}')
|
||||
ip_add=$(cat /etc/network/interfaces | grep "address" | awk '{print $2}')
|
||||
ip_netm=$(cat /etc/network/interfaces | grep "netmask" | awk '{print $2}')
|
||||
ip_gw=$(cat /etc/network/interfaces | grep "gateway" | awk '{print $2}')
|
||||
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
|
||||
|
||||
else
|
||||
# Yes DHCP
|
||||
iface=$(cat /etc/network/interfaces | grep "iface" | sed '/loopback/d' | awk '{print $2}')
|
||||
|
||||
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 dhcp
|
||||
" > /etc/network/interfaces
|
||||
|
||||
fi
|
||||
rm -f /etc/network/*.BeforeVMwareCustomization
|
||||
|
||||
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
|
Reference in New Issue
Block a user