ArchInstallInitial.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/bash
  2. SDA1=/dev/sda1 # change as needed
  3. SDA=/dev/sda # change as needed
  4. MNT=/mnt # change as needed.
  5. FSTAB=/etc/fstab
  6. PACMAN_MIRROR=/etc/pacman.d/mirrorlist
  7. HOSTNAME=/etc/hostname
  8. ZONE=/usr/share/zoneinfo/
  9. LOCAL_TIME=/etc/localtime
  10. LOCALE_GEN=/etc/locale.gen
  11. LOCALE_CONF=/etc/locale.conf
  12. MKINITCPIO_CONF=/etc/mkinitcpio.conf
  13. GRUB_CFG=/boot/grub/grub.cfg
  14. BASH=/bin/bash
  15. SUDOERS=/etc/sudoers
  16. CREATOR="CSCoder4ever"
  17. GIT_CLONED_DIR=arch-o-matic
  18. PART2=Chroot-Install.sh
  19. # This script is made to automate the installation of Arch onto my server.
  20. # it assumes the disk you want to use is /dev/sda1
  21. # To get this script going in an Arch live CD, do the following:
  22. # mkdir usb && mount /dev/sdb1 usb
  23. # this of course assumes the usb is /dev/sdb1
  24. # to verify, the command "df -h" will come in handy.
  25. echo "Welcome to $CREATOR's installation script! part 1 of 2"
  26. echo "The Following will remove ALL data from $SDA1"
  27. read -p "continue? y/n: " YesOrNo # asks if you'd like to format the drive
  28. if [ "$YesOrNo" = "y" ]; then # If yes, format here we come!
  29. #echo "Formatting $SDA1 to ext4"
  30. mkfs.ext4 $SDA1
  31. #echo "Format complete!"
  32. else #if no, program will exit.
  33. read -p "exit? y/n: " exitR
  34. if [ "$exitR" = "y" ]; then
  35. exit
  36. fi
  37. fi
  38. #sleep 1 && read -p "do you have wifi for the installation? y/n: " wifiResponse
  39. #if [[ "$wifiResponse" = "y" || "$wifiResponse" = "Y" ]]; then
  40. # wifi-menu
  41. #else
  42. # echo "assuming you're connected via ethernet"
  43. #fi
  44. sleep 1 && echo "Mounting $SDA1"
  45. mount $SDA1 $MNT
  46. sleep 1 && read -p "Which editor would you like to use? " USER_EDITOR
  47. sleep 1 && read -p "Want to edit $PACMAN_MIRROR? y/n: " pacResponse
  48. if [[ "$pacResponse" = "y" || "$pacResponse" = "Y" ]]; then
  49. $USER_EDITOR $PACMAN_MIRROR
  50. fi
  51. sleep 1 && echo "installing base system"
  52. pacstrap $MNT base base-devel grub-bios sudo
  53. # if something goes wrong with the pacstrap install, uncomment the code below
  54. #read -p "did everything go right? if so, press enter to continue... " debugging
  55. sleep 1 && echo "Generating fstab"
  56. genfstab -p $MNT >> /mnt$FSTAB
  57. sleep 1 && echo "edit $HOSTNAME"
  58. $USER_EDITOR /mnt$HOSTNAME
  59. # Select Zone, now with autocomplete
  60. echo "Choose your timezone." && sleep 4
  61. sleep 1 && ls $MNT$ZONE | less; cd $ZONE
  62. sleep 1 && echo "Select Zone: ( use TAB to complete if desired )"; read -e OUTER
  63. sleep 1 && ls $MNT$ZONE$OUTER | less; cd $OUTER
  64. sleep 1 && echo "Select Subzone: ( use TAB to complete if desired )"; read -e INNER
  65. sleep 1 && echo "creating a symlink for $ZONE$OUTER$INNER to $LOCAL_TIME"
  66. ln -s $ZONE$OUTER$INNER $MNT$LOCAL_TIME; cd
  67. sleep 1 && echo "uncomment a section in $LOCALE_GEN"
  68. $USER_EDITOR $MNT$LOCALE_GEN
  69. sleep 1 && read -p "Would you like to edit $MKINITCPIO_CONF? y/n: " mkResponse
  70. if [[ "$mkResponse" = "y" || "$mkResponse" = "Y" ]]; then
  71. $USER_EDITOR $MNT$MKINITCPIO_CONF
  72. fi
  73. echo "Edit /etc/pacman.conf" && sleep 5
  74. $USER_EDITOR $MNT/etc/pacman.conf
  75. # and enable multi-arch support, if desired.
  76. echo "uncomment the section that contains \"wheel\" to give $userName admin rights." && sleep 5
  77. $USER_EDITOR $MNT$SUDOERS
  78. sleep 1 && read -p "Want to install Packer? y/n: " packerInstallResponse
  79. if [[ "$packerInstallResponse" = "y" || "$packerInstallResponse" = "Y" ]]; then
  80. wget https://aur.archlinux.org/packages/pa/packer/PKGBUILD
  81. cp PKGBUILD $MNT
  82. fi
  83. sleep 1 && echo "( 1 ) = Desktop, ( 2 ) = Laptop, "
  84. echo "( 3 ) = Server ( Default = 1 )"
  85. echo
  86. read -p "Input Install type ( 1 | 2 | 3 ): " DLORS
  87. case $DLORS in
  88. 1) echo "cp Desktop Installation script" && cp desktop/$PART2 $MNT/part2.sh ;;
  89. 2) echo "cp Laptop Installation script" && cp laptop/$PART2 $MNT/part2.sh ;;
  90. 3) echo "cp Server Installation script" && cp server/$PART2 $MNT/part2.sh ;;
  91. *) echo "cp Desktop Installation script" && cp desktop/$PART2 $MNT/part2.sh ;;
  92. esac
  93. sleep 1 && echo "arch-chrooting into the new install"
  94. arch-chroot $MNT $BASH part2.sh