Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- clear
- # When cloned, Debian switches to eth1 instead of eth0 for some reason
- if ! ping -c 1 google.com &>/dev/null; then
- cat >> /etc/network/interfaces <<-EOF
- auto eth1
- iface eth1 inet dhcp
- EOF
- ifup eth1 &>/dev/null
- fi
- echo "Updating Debian in the background..."
- apt-get update &>/dev/null && apt-get -y upgrade &>/dev/null &
- sleep 1
- pattern="^[a-z][-a-z0-9]*$"
- echo; echo "Changing hostname..."
- read -p "Hostname: " hostname
- while [[ ! $hostname =~ $pattern ]]; do
- echo "Invalid hostname."
- read -p "Hostname: " hostname
- done
- echo $hostname > /etc/hostname
- sed -i 's/127.0.1.1.*/127.0.1.1\t'"$hostname"'/' /etc/hosts
- echo "...done."
- echo; echo "Adding new user..."
- read -p "Username: " username
- while [[ ! $username =~ $pattern ]]; do
- echo "Invalid username."
- read -p "Username: " username
- done
- adduser --gecos "" --quiet $username
- adduser $username sudo
- sleep 2
- clear
- echo "The machine will be ready soon."
- if [[ -n $(jobs -r) ]]; then
- echo; echo -n "Waiting for updates to finish. This will take a while."
- sleep 2
- i=0
- while [[ -n $(jobs -r) ]]; do
- echo -n "."
- sleep 2
- done
- echo "done."
- fi
- echo; echo -n "Enabling Hyper-V Virtual Guest Services..."
- cat >> /etc/initramfs-tools/modules <<-EOF
- hv_vmbus
- hv_storvsc
- hv_blkvsc
- hv_netvsc
- EOF
- update-initramfs -u &>/dev/null &
- sleep 2
- while [[ -n $(jobs -r) ]]; do
- echo -n "."
- sleep 2
- done
- echo "done."
- echo; echo -n "Installing OpenSSH server..."
- apt-get -y install openssh-server &>/dev/null &
- sleep 2
- while [[ -n $(jobs -r) ]]; do
- echo -n "."
- sleep 2
- done
- echo "done."
- echo; echo "Setup complete. Rebooting..."
- mv /etc/inittab.orig /etc/inittab
- mv .profile-orig .profile
- shutdown -r now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement