diff options
author | Kyle K <kylek389@gmail.com> | 2020-02-01 15:05:34 -0600 |
---|---|---|
committer | Kyle K <kylek389@gmail.com> | 2020-02-01 15:05:34 -0600 |
commit | 7dc9e3b3e7b521286225a2271833bf7cbcc8ae9c (patch) | |
tree | b9ce520649801a4599f913b9de03133555347600 /install.sh | |
parent | 8d286f3cc70bf498a5731bbe016e3cd2d2f169ff (diff) | |
download | gentoox-7dc9e3b3e7b521286225a2271833bf7cbcc8ae9c.tar.gz gentoox-7dc9e3b3e7b521286225a2271833bf7cbcc8ae9c.tar.bz2 gentoox-7dc9e3b3e7b521286225a2271833bf7cbcc8ae9c.zip |
continue working on install script
Diffstat (limited to 'install.sh')
-rwxr-xr-x | install.sh | 96 |
1 files changed, 76 insertions, 20 deletions
@@ -4,26 +4,25 @@ if [ $(id -u) != "0" ]; then exit 1 fi -# post install -# -# adjust nproc in make.conf +set -e +echo -e 'Welcome to the GentooX setup, the installation script mainly consists of: +\t- providing this script with a target partition where system will be installed +\t- extracting precompiled squashfs system image into the specified parition +\t- setting up GRUB, BIOS or UEFI mode will be used depending how system was booted +\tGentooX uses openSUSE-style BTRFS root partition & subvolumes for snapshotting with snapper +\tGentooX requires minimum of 16GB of space, and use of BTRFS is hardcoded -# setup /etc/fstab +mounting target partition to /mnt/install +unsquash -f -i -d /mnt/install/ /mnt/cdrom/image.squashfs +/usr/local/sbin/genfstab -U >> /mnt/install/etc/fstab +/usr/local/sbin/arch-chroot /mnt/install/ +grub-install --target=x86_64-efi for UEFI mode or grub-install --target=i386-pc (BIOS only)' -#plymouth-set-default-theme fade-in -# adjust /etc/default/grub -# splash quiet - -#rc-update add zfs-import boot -#rc-update add zfs-mount boot - - -sensors-detect --auto -rc-update add lm_sensors default - -# grub-install -# grub-mkconfig -o /boot/grub/grub.cfg +declare -A PART_SCHEME +PART_SCHEME[a]="Automatic" +PART_SCHEME[m]="Manual" +if [[ -d /sys/firmware/efi/ ]]; then UEFI_MODE=y; fi setup_btrfs () { @@ -86,8 +85,65 @@ setup_btrfs () { mount /dev/$DEVICE /mnt/install/tmp -o subvol=@/tmp mount /dev/$DEVICE /mnt/install/usr/local -o subvol=@/usr/local mount /dev/$DEVICE /mnt/install/var -o subvol=@/var - - umount -l /mnt/install/boot/efi /mnt/install/var /mnt/install/usr/local /mnt/install/tmp /mnt/install/srv /mnt/install/root /mnt/install/opt /mnt/install/home \ - /mnt/install/boot/grub/x86_64-efi /mnt/install/boot/grub/i386-pc /mnt/install/.snapshots /mnt/install } + +while :; do + echo + read -erp "Automatic partitioning (a) or manual partitioning (will launch gparted)? [a/m] " -n 1 partitioning_mode + if [[ $partitioning_mode = "a" ]]; then + read -erp "Enter drive to be formatted for GentooX installation: " -i "/dev/sda" drive + elif [[ $partitioning_mode = "m" ]]; then + if [[ ! -z $UEFI_MODE ]]; then echo "EFI boot detected, please also create EF00 ESP EFI partition..."; fi + gparted &> /dev/null & + read -erp "Enter formatted partition for GentooX installation: " -i "/dev/sda1" partition + else + echo "Invalid option" + continue + fi + + read -erp "Partitioning: ${PART_SCHEME[$partitioning_mode]} + Partition: $partition + Is this correct? [y/n] " -n 1 yn + if [[ $yn == "y" ]]; then + break + fi +done + + +if [[ $partitioning_mode = "a" ]]; then + if [[ ! -z $UEFI_MODE ]]; then + echo -e "o\nn\np\n1\n+256M\n\np\n2\n\n\nw" | gdisk /dev/$drive + mkfs.vfat -F32 "${drive}1" + UEFI_PART="${drive}1" + setup_btrfs "${drive}2" + else + echo -e "o\nn\np\n1\n\n\nw" | fdisk /dev/$drive + setup_btrfs "${drive}1" + fi +else + # user done the partitioning + read -erp "Enter formatted EF00 ESP partition for EFI: " -i "/dev/sda1" efi_partition + setup_btrfs $partition +fi + +echo "extracting precompiled image.squashfs GentooX image to the target partition..." +unsquash -f -d /mnt/install/ /mnt/cdrom/image.squashfs +/usr/local/sbin/genfstab -U >> /mnt/install/etc/fstab + +mount -t proc none /mnt/install/proc +mount --rbind /dev /mnt/install/dev +mount --rbind /sys /mnt/install/sys + +cat <<HEREDOC | chroot . +source /etc/profile && export PS1="(chroot) \$PS1" +sensors-detect --auto +rc-update add lm_sensors default +NCORES=\$(getconf _NPROCESSORS_ONLN) +sed -i -r "s/^MAKEOPTS=\"([^\"]*)\"$/MAKEOPTS=\"-j\$NCORES\"/g" /etc/portage/make.conf +sed -i -r "s/^NTHREADS=\"([^\"]*)\"$/NTHREADS=\"\$NCORES\"/g" /etc/portage/make.conf +#rc-update add zfs-import boot +#rc-update add zfs-mount boot +HEREDOC + +umount -l /mnt/install/boot/efi /mnt/install/var /mnt/install/usr/local /mnt/install/tmp /mnt/install/srv /mnt/install/root /mnt/install/opt /mnt/install/home /mnt/install/boot/grub/x86_64-efi /mnt/install/boot/grub/i386-pc /mnt/install/.snapshots /mnt/install |