#!/bin/sh failinstall() { dialog --title "Error" --msgbox "EvolutionOS was not able to install" 0 0 clear exit 1 } create_menu() { menu="" for option in "$@"; do if [[ "$(cat /sys/block/${option}/ro)" = "1" ]]; then writability="Unwritable" else writability="Writable" fi menu="${menu} ${option} ${writability}" done echo "$menu" } if [[ $(id -u) -eq 0 ]]; then : else dialog --title "Run as root" --msgbox "Please run the installer as root!" 0 0 failinstall fi if [ $(uname -m) = "i686" ]; then grub="grub-i386-efi" arch=i386 else grub="grub-x86_64-efi" arch=x86_64 fi if [[ -x /sys/firmware/efi ]]; then uefi=true else uefi=false fi insmod /root/vfat-modules/fat.ko.zst insmod /root/vfat-modules/vfat.ko.zst dialog --title "Welcome" --msgbox "Welcome to the EvolutionOS installer! \n\nThis installer is meant to be straightforward, no need for technical skill. \n\nPress enter to select buttons, tab to move between text boxes, and left / right to move between buttons." 0 0 choice=$(dialog --menu "Select an installation drive:" 20 60 10 $(create_menu $(parted -l | grep -oE '^Disk /dev/[a-zA-Z0-9]+' | cut -d' ' -f2- | cut -c 6-)) 2>&1 >/dev/tty) if [[ ${choice} =~ "nvme" ]]; then part1="p1" part2="p2" elif [[ ${choice} =~ "mmcblk" ]]; then part1="p1" part2="p2" else part1="1" part2="2" fi if [[ "$(cat /sys/block/${choice}/ro)" = "1" ]]; then dialog --title "Scan disk" --msgbox "You are not able to install evolutionOS on a non-writable disk" 0 0 failinstall else dialog --title "Scan disk" --msgbox "EvolutionOS will now scan your disk drive to check if it can install evolutionOS" 0 0 fi dialog --yesno "Would you like to use the recommended disk partitioning?" 0 0 if [[ $? = 0 ]]; then if [[ $uefi = true ]]; then parted --script /dev/${choice} mklabel gpt mkpart primary fat32 1MiB 200MiB mkpart primary ext4 200MiB 100% else parted --script /dev/${choice} mklabel msdos mkpart primary ext4 1MiB 100% fi if [[ $? = 1 ]]; then dialog --msgbox "Partitioning failed!" 0 0 failinstall fi filesystem=$(dialog --menu "Select a filesystem:" 0 0 0 "ext4" "Fast basic filesystem (recommended)" "btrfs" "Great for data recovery and servers" 2>&1 >/dev/tty) if [[ $uefi = true ]]; then if [[ "$filesystem" = "ext4" ]]; then mkfs.ext4 /dev/${choice}${part2} | dialog --title "Creating file system..." --programbox 24 80 else mkfs.btrfs -f /dev/${choice}${part2} | dialog --title "Creating file system..." --programbox 24 80 fi if [[ $? = 1 ]]; then dialog --msgbox "Formatting failed!" 0 0 failinstall fi mkfs.fat -v -F 32 /dev/${choice}${part1} | dialog --title "Creating boot partition..." --programbox 24 80 if [[ $? = 1 ]]; then dialog --msgbox "Formatting failed!" 0 0 failinstall fi mount /dev/${choice}${part2} /mnt if [[ $? = 1 ]]; then dialog --msgbox "Mounting failed!" 0 0 failinstall fi mkdir -p /mnt/boot/efi sh -c "mount /dev/${choice}${part1} /mnt/boot/efi" if [[ $? = 1 ]]; then dialog --msgbox "Mounting ESP failed!" 0 0 failinstall fi else mkfs.$filesystem /dev/${choice}${part1} | dialog --title "Creating file system..." --programbox 24 80 if [[ $? = 1 ]]; then dialog --msgbox "Formatting failed!" 0 0 failinstall fi mount /dev/${choice}${part1} /mnt if [[ $? = 1 ]]; then dialog --msgbox "Mounting failed!" 0 0 failinstall fi fi else while true; do clear printf "Ok, welcome to the Linux Shell. Mount root at /" if [[ $uefi = true ]]; then printf " and ESP at /boot/efi." else printf "." fi echo " Type exit when you are done" ash dialog --yesno "Have you finished?" 0 0 if [[ $? = 0 ]]; then break else continue fi done fi installtype=$(dialog --title "Install type" --menu "Choose your installation type" 0 0 0 "local" "Extract from disk (may be out of date)" "network" "Download from internet (requires internet to be set up)" 2>&1 >/dev/tty) while true; do if [[ "$installtype" = "local" ]]; then cp -r /bin /home /lib32 /media /opt /root /sbin /var /boot /etc /lib /lib64 /run /usr /mnt if [[ $? = 1 ]]; then dialog --msgbox "Copying failed!" 0 0 failinstall fi mkdir /mnt/dev /mnt/tmp /mnt/proc /mnt/sys rm -rf /mnt/etc/dinit.d/rcboot.sh rm -rf /mnt/root/vfat-modules mv /mnt/etc/dinit.d/rcboot-real.sh /mnt/etc/dinit.d/rcboot.sh xbps-remove -OoR dialog parted e2fsprogs btrfs-progs xtools-minimal ncurses -r /mnt -y if [[ $uefi = false ]]; then xbps-remove -OoR dosfstools grub-x86_64-efi -r /mnt -y fi rm -rf /mnt/usr/bin/evolution-installer break else ping -c 1 example.org >/dev/null 2>&1 if [[ $? = 1 ]]; then netselect=$(dialog --title "Network" --menu "The network isn't connected. What would you like to do?" 0 0 0 "local" "Go back to extraction from disk" "network" "Manually set up network in the terminal" 2>&1 >/dev/tty) while true; do clear echo "Welcome to the Linux Shell. Type exit when you are done" ash dialog --yesno "Have you finished?" 0 0 if [[ $? = 0 ]]; then break else continue fi done else mkdir -p /mnt/var/db/xbps/keys/ cp /var/db/xbps/keys/* /mnt/var/db/xbps/keys/ if [[ $uefi = true ]]; then xbps-install -S -y -r /mnt base-system "${grub}" -R https://evolutionos.hectabit.org/pkg -R https://repo-default.voidlinux.org/current | dialog --title "Bootstrapping rootfs..." --programbox 24 80 else xbps-install -S -y -r /mnt base-system grub -R https://evolutionos.hectabit.org/pkg -R https://repo-default.voidlinux.org/current | dialog --title "Bootstrapping rootfs..." --programbox 24 80 fi break fi fi done xbps-reconfigure -r /mnt -f glibc-locales rootpasswd=$(dialog --title "Password" --clear --insecure --passwordbox "Enter admin (root) password" 0 0 2>&1 >/dev/tty) username=$(dialog --title "Username" --clear --inputbox "Enter your username" 0 0 2>&1 >/dev/tty) userpasswd=$(dialog --title "Password" --clear --insecure --passwordbox "Enter user password" 0 0 2>&1 >/dev/tty) hostname=$(dialog --title "Hostname" --clear --inputbox "Enter hostname for computer" 0 0 2>&1 >/dev/tty) echo -e "$rootpasswd\n$rootpasswd" | xchroot /mnt passwd xchroot /mnt useradd -m "${username}" echo -e "$userpasswd\n$userpasswd" | xchroot /mnt passwd "${username}" echo $hostname > /mnt/etc/hostname if [[ $uefi = true ]]; then xchroot /mnt grub-install --no-nvram --efi-directory=/boot/efi /dev/${choice} mkdir -p /mnt/boot/efi/EFI/boot/ mv /mnt/boot/efi/EFI/void*/grubx64.efi /mnt/boot/efi/EFI/boot/bootx64.efi rm -rf /mnt/boot/efi/EFI/void* else xchroot /mnt grub-install /dev/${choice} fi xchroot /mnt grub-mkconfig -o /boot/grub/grub.cfg xbps-reconfigure -f glibc-locales -r /mnt if [[ $? = 1 ]]; then dialog --msgbox "Package configuration failed!" 0 0 failinstall fi xbps-reconfigure -f -a -r /mnt if [[ $? = 1 ]]; then dialog --msgbox "Package configuration failed!" 0 0 failinstall fi dialog --yesno "EvolutionOS has been installed! Would you like to reboot?" 0 0 if [[ $? = 1 ]]; then clear exit 0 else reboot fi