Advertisement
Guest User

Untitled

a guest
May 24th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. clear
  4.  
  5. # When cloned, Debian switches to eth1 instead of eth0 for some reason
  6. if ! ping -c 1 google.com &>/dev/null; then
  7. cat >> /etc/network/interfaces <<-EOF
  8. auto eth1
  9. iface eth1 inet dhcp
  10. EOF
  11. ifup eth1 &>/dev/null
  12. fi
  13.  
  14. echo "Updating Debian in the background..."
  15. apt-get update &>/dev/null && apt-get -y upgrade &>/dev/null &
  16. sleep 1
  17.  
  18. pattern="^[a-z][-a-z0-9]*$"
  19.  
  20. echo; echo "Changing hostname..."
  21. read -p "Hostname: " hostname
  22. while [[ ! $hostname =~ $pattern ]]; do
  23. echo "Invalid hostname."
  24. read -p "Hostname: " hostname
  25. done
  26. echo $hostname > /etc/hostname
  27. sed -i 's/127.0.1.1.*/127.0.1.1\t'"$hostname"'/' /etc/hosts
  28. echo "...done."
  29.  
  30. echo; echo "Adding new user..."
  31. read -p "Username: " username
  32. while [[ ! $username =~ $pattern ]]; do
  33. echo "Invalid username."
  34. read -p "Username: " username
  35. done
  36. adduser --gecos "" --quiet $username
  37. adduser $username sudo
  38. sleep 2
  39.  
  40. clear
  41. echo "The machine will be ready soon."
  42.  
  43. if [[ -n $(jobs -r) ]]; then
  44. echo; echo -n "Waiting for updates to finish. This will take a while."
  45. sleep 2
  46. i=0
  47. while [[ -n $(jobs -r) ]]; do
  48. echo -n "."
  49. sleep 2
  50. done
  51. echo "done."
  52. fi
  53.  
  54. echo; echo -n "Enabling Hyper-V Virtual Guest Services..."
  55. cat >> /etc/initramfs-tools/modules <<-EOF
  56. hv_vmbus
  57. hv_storvsc
  58. hv_blkvsc
  59. hv_netvsc
  60. EOF
  61. update-initramfs -u &>/dev/null &
  62. sleep 2
  63. while [[ -n $(jobs -r) ]]; do
  64. echo -n "."
  65. sleep 2
  66. done
  67. echo "done."
  68.  
  69. echo; echo -n "Installing OpenSSH server..."
  70. apt-get -y install openssh-server &>/dev/null &
  71. sleep 2
  72. while [[ -n $(jobs -r) ]]; do
  73. echo -n "."
  74. sleep 2
  75. done
  76. echo "done."
  77.  
  78. echo; echo "Setup complete. Rebooting..."
  79. mv /etc/inittab.orig /etc/inittab
  80. mv .profile-orig .profile
  81. shutdown -r now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement