|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +if [[ $EUID -ne 0 ]]; then |
| 4 | + echo -e "\033[0;31mravynOS Installer must be run with sudo.\033[0m" |
| 5 | + exit 1 |
| 6 | +fi |
| 7 | + |
| 8 | +# ANSI escape codes for styling |
| 9 | +RED='\033[0;31m' |
| 10 | +GREEN='\033[0;32m' |
| 11 | +YELLOW='\033[0;33m' |
| 12 | +CYAN='\033[0;36m' |
| 13 | +WHITE='\033[0;97m' |
| 14 | +RESET='\033[0m' |
| 15 | + |
| 16 | +# Beautiful welcome message |
| 17 | +echo -e "${CYAN}" |
| 18 | +echo -e "==========================================" |
| 19 | +echo -e " ${GREEN}Welcome to${CYAN} ravynOS ${GREEN}Setup for Developers${RESET}" |
| 20 | +echo -e "==========================================" |
| 21 | +echo -e "${YELLOW}Preparing your environment...${RESET}" |
| 22 | +echo -e "${CYAN}------------------------------------------${RESET}" |
| 23 | +echo -e "${RED}WARNING:${RESET} Before proceeding, make sure to run the command ${YELLOW}gpart destroy -F${RESET} (e.g., for devices like ${CYAN}ada0, da0, etc.${RESET})." |
| 24 | + |
| 25 | +# Prompt the user for the disk device name |
| 26 | +read -p "Enter the disk device name (e.g., ada0, da0, etc.): " device |
| 27 | + |
| 28 | +# Confirm the input |
| 29 | +echo "You selected the device: $device" |
| 30 | +read -p "Continue? (y/n): " confirm |
| 31 | +if [[ "$confirm" != "y" ]]; then |
| 32 | + echo "Installation aborted." |
| 33 | + exit 1 |
| 34 | +fi |
| 35 | + |
| 36 | +# Delete existing partitions and create a new GPT |
| 37 | +echo "Preparing the device..." |
| 38 | +gpart create -s gpt $device |
| 39 | + |
| 40 | +# Create an EFI partition |
| 41 | +echo "Creating EFI partition..." |
| 42 | +gpart add -t efi -l efi -s 256M $device |
| 43 | +newfs_msdos /dev/${device}p1 |
| 44 | + |
| 45 | +# Create a swap partition |
| 46 | +echo "Creating swap partition..." |
| 47 | +gpart add -t freebsd-swap -s 4G $device |
| 48 | + |
| 49 | +# Create a ZFS partition |
| 50 | +echo "Creating ZFS partition..." |
| 51 | +gpart add -t freebsd-zfs -l ravynOS $device |
| 52 | + |
| 53 | +# Initialize the ZFS pool |
| 54 | +echo "Initializing ZFS pool..." |
| 55 | +zpool create -f -R /mnt -O mountpoint=/ -O atime=off -O canmount=off -O compression=on ravynOS /dev/${device}p3 |
| 56 | + |
| 57 | +# Create ZFS datasets |
| 58 | +echo "Creating ZFS datasets..." |
| 59 | +zfs create -o canmount=off -o mountpoint=none ravynOS/ROOT |
| 60 | +zfs create -o mountpoint=/ ravynOS/ROOT/default |
| 61 | + |
| 62 | +# Prepare EFI boot files |
| 63 | +echo "Preparing EFI boot files..." |
| 64 | +zpool set bootfs=ravynOS/ROOT/default ravynOS |
| 65 | +mkdir /tmp/efi |
| 66 | +mount -t msdosfs /dev/${device}p1 /tmp/efi |
| 67 | +mkdir -p /tmp/efi/efi/boot |
| 68 | +cp /boot/loader.efi /tmp/efi/efi/boot/bootx64.efi |
| 69 | +cp /boot/loader.efi /tmp/efi/efi/boot/loader.efi |
| 70 | +umount /tmp/efi |
| 71 | + |
| 72 | +# Exclude unnecessary directories |
| 73 | +cat >> /tmp/excludes <<EOF |
| 74 | +/dev |
| 75 | +/proc |
| 76 | +/tmp |
| 77 | +EOF |
| 78 | + |
| 79 | +echo "Installing ravynOS... This process may take several minutes, please wait." |
| 80 | +echo "Relax and have a coffee while ravynOS is installing on your computer." |
| 81 | +cd /sysroot |
| 82 | +cpdup -uIof -X /tmp/excludes . /mnt |
| 83 | + |
| 84 | +# Enter the chroot environment |
| 85 | +chroot /mnt /bin/sh <<'EOF' |
| 86 | +
|
| 87 | +# Perform configuration |
| 88 | +/usr/sbin/bsdinstall config |
| 89 | +/usr/sbin/bsdinstall entropy |
| 90 | +
|
| 91 | +# Remove temporary user liveuser |
| 92 | +/usr/sbin/pw userdel -n liveuser |
| 93 | +/usr/sbin/pw groupdel -n liveuser |
| 94 | +rm -rf /Users/liveuser |
| 95 | +
|
| 96 | +# Create a new user 'dev' with password 'temp' |
| 97 | +echo "Creating user dev with password temp..." |
| 98 | +/usr/sbin/pw useradd -n dev -s /bin/sh -m -G wheel -h 0 <<'USER_PASS' |
| 99 | +temp |
| 100 | +USER_PASS |
| 101 | +
|
| 102 | +# Move rc.conf.local file |
| 103 | +mv /etc/rc.conf.local /etc/rc.conf |
| 104 | +
|
| 105 | +# Configure /etc/rc.conf using sysrc |
| 106 | +echo "Configuring ravynOS..." |
| 107 | +sysrc zfs_enable=YES |
| 108 | +sysrc zfsd_enable=YES |
| 109 | +
|
| 110 | +# Configure /boot/loader.conf |
| 111 | +echo "Configuring ravynOS bootloader..." |
| 112 | +cat <<'LOADER_CONF' >> /boot/loader.conf |
| 113 | +cryptodev_load="YES" |
| 114 | +zfs_load="YES" |
| 115 | +beastie_disable="YES" |
| 116 | +autoboot_delay="3" |
| 117 | +vfs.root.mountfrom.options="rw" |
| 118 | +vfs.root.mountfrom="zfs:ravynOS/ROOT/default" |
| 119 | +LOADER_CONF |
| 120 | +
|
| 121 | +# Set the timezone |
| 122 | +echo "Setting the timezone..." |
| 123 | +cp /usr/share/zoneinfo/UTC /etc/localtime |
| 124 | +EOF |
| 125 | + |
| 126 | +# Finish installation |
| 127 | +echo -e "${YELLOW}Attention!${RESET} User: ${CYAN}dev${RESET}. Password: ${CYAN}temp${RESET}. Please change the password after rebooting using ${CYAN}passwd dev${RESET}." |
| 128 | +echo -e "Installation completed." |
| 129 | + |
| 130 | +# Prompt the user to reboot |
| 131 | +read -p "Would you like to reboot now? (y/N): " reboot_choice |
| 132 | +if [ "$reboot_choice" = "y" ] || [ "$reboot_choice" = "Y" ]; then |
| 133 | + echo "Rebooting..." |
| 134 | + reboot |
| 135 | +else |
| 136 | + echo "Reboot canceled. Please reboot manually when ready." |
| 137 | +fi |
0 commit comments