Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. function setup(){
  4. echo "Installation setup"
  5. echo "List of partition :"
  6. parted -l
  7. read -p "Select disk where install Archlinux : " -i "/dev/sd" -e DISK
  8. read -p "Type a username for basic user : " -e USERNAME
  9. read -p "Type a hostname for computers name : " -e HOSTNAME
  10.  
  11. while [[ -z ${ANSWER} ]]; do
  12. read -p "Install on virtualbox ? [Y or N] " response
  13. case $response in
  14. [yY])
  15. local ANSWER=true
  16. VIRTUALBOX=true
  17. ;;
  18. [nN])
  19. local ANSWER=true
  20. VIRTUALBOX=false
  21. ;;
  22. *)
  23. echo "not a valid response"
  24. ;;
  25. esac
  26. done
  27. unset ANSWER
  28. unset response
  29.  
  30. if [[ -e ${DISK} ]]; then #Test if the choosen disk exist
  31. while [ -z ${YN} ]
  32. do
  33. read -p "$(warning Are you okay with this? It will erase EVERYTHING in this disk and you will not be able to change the password. [y/N]) " response
  34. case $response in
  35. [yY][eE][sS][oO]|[yY])
  36. local YN=true
  37.  
  38. echo "Creating partition"
  39. create_partitions
  40. echo "Partition created OK"
  41.  
  42. echo "Make file system"
  43. mkfs_partitions
  44. echo "MKFS OK"
  45.  
  46. echo "Mounting FileSystem"
  47. mount_fs
  48. echo "FileSystem mounted sucessful"
  49.  
  50. info "Preparing boot"
  51. prepare_boot
  52. info "Boot prepared sucessful"
  53.  
  54. info "Installing base"
  55. install_base
  56. info "Base installed sucessful"
  57.  
  58. info "Generate fstab"
  59. generate_fstab
  60. info "fstab generated sucessful"
  61.  
  62. info 'Chrooting into installed system to continue setup...'
  63. prepare_chroot
  64. ;;
  65. [nN])
  66. local YN=true
  67. info "Okay... Good Bye !"
  68. exit 0
  69. ;;
  70. *)
  71. echo "Mmmmh... don't understand, only Y or N are authorized. And I'm sure you can do it. "
  72. ;;
  73. esac
  74. done
  75.  
  76. }
  77.  
  78. function print_param(){
  79. echo "Disk : ${DISK}"
  80. echo "Username : ${USERNAME}"
  81. echo "Hostname : ${HOSTNAME}"
  82. echo "Password : ${PASSWORD}"
  83. echo "VIRTUALBOX : ${VIRTUALBOX}"
  84. }
  85.  
  86.  
  87. # to call before mount_fs
  88. function mkfs_partitions(){
  89. mkfs.ext2 ${DISK}1
  90. mkfs.ext4 ${DISK}2
  91. mkfs.ext4 ${DISK}3
  92.  
  93.  
  94. }
  95.  
  96. function mount_fs(){
  97.  
  98. mount /dev/sda2 /mnt
  99. mkdir /mnt/boot
  100. mount /dev/sda1 /mnt/boot
  101. mkdir /mnt/home
  102. mount /dev/sda3 /mnt/home
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement