Skip to content

Instantly share code, notes, and snippets.

@dkmonaghan
Created May 26, 2020 22:13
Show Gist options
  • Save dkmonaghan/0237d0d3b21586b4572fe83419504f3a to your computer and use it in GitHub Desktop.
Save dkmonaghan/0237d0d3b21586b4572fe83419504f3a to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -f "/sys/class/net/ens192/address" ]; then
# Temporarily bring up the network
sed -i 's/eth0/ens192/g' /etc/network/interfaces
service networking restart
fi
# Apt-get update
apt-get update
# Remove hyperv-daemons
apt-get remove -y hyperv-daemons
# Install open-vm-tools
apt-get install -y open-vm-tools
if [ -f "/sys/class/net/ens192/address" ]; then
# Configure network interface
cat >> /etc/systemd/network/10-eth0.link <<EOL
[Match]
MACAddress=`cat /sys/class/net/ens192/address`
[Link]
Name=eth0
EOL
# Set interfaces file back to eth0
sed -i 's/ens192/eth0/g' /etc/network/interfaces
# Update initramfs
update-initramfs -u
fi
# Remove myself
apt-get remove -y vmwaremigrate
echo "Done! VM Configured. Rebooting in 3 seconds..."
sleep 3
# Reboot system
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment