holoiso/airootfs/usr/local/bin/holoinstall

224 lines
8.7 KiB
Bash
Executable File

#!/bin/zsh
# HoloISO Installer v2
# This defines all of the current variables.
CMD_PACMAN_INSTALL=(/usr/bin/pacman --noconfirm -S --needed --overwrite="*")
CMD_PACMAN_UPDATE=(/usr/bin/pacman -Sy)
CPU_VENDOR=$(cat /proc/cpuinfo | grep 'vendor' | uniq | cut -c 13-)
SYSTEM_LOCALE="${SYSTEM_LOCALE:-en_US.UTF-8 UTF-8}"
HOLO_INSTALL_DIR="${HOLO_INSTALL_DIR:-/mnt}"
# Internet connectivity check
wget -q --spider http://google.com
if [ $? -eq 0 ]; then
echo "Internet check passed"
else
echo -e "No Internet connection available, exiting\nUse wifi-menu util to connect WiFi"
exit
fi
# Update system time
if [ $(timedatectl status | grep -c "NTP service: active") -ne 1 ]; then
# If NTP is not active, enable it.
timedatectl set-ntp true
# Update the hardware clock.
hwclock --systohc
fi
if [[ "${CPU_VENDOR}" == "AuthenticAMD" ]]; then
UCODE_INSTALL_MSG="AMD CPU detected, installing AMD ucode..."
UCODE_INSTALL="amd-ucode"
else
UCODE_INSTALL_MSG="Intel CPU detected, installing Intel ucode..."
UCODE_INSTALL="intel-ucode"
fi
base_os_install() {
lsblk
read "?Enter your desired drive node here (for example, sda or nvme0n1): " DRIVEDEVICE
#read "?WARNING: This drive is going to be erased fully. Press enter to continue, or CTRL+Z to terminate"
DEVICE="/dev/${DRIVEDEVICE}"
INSTALLDEVICE="${DEVICE}"
echo ${DEVICE} | grep -q -P "^/dev/(nvme|loop|mmcblk)"
if [ $? -eq 0 ]; then
INSTALLDEVICE="${DEVICE}p"
fi
if [ ! -b $DEVICE ]; then
echo "$DEVICE not found! Installation Aborted!"
exit 1
fi
echo "\n\nWARNING: The following drive is going to be erased fully. ALL DATA ON DRIVE $DEVICE WILL BE LOST!\n"
lsblk $DEVICE
echo -n "\nErase $DEVICE and begin installation(y/N): "
read ANS
if [[ ! ($ANS = 'y' || $ANS = 'Y') ]]; then
echo "Installation Aborted!"
exit 1
fi
echo "\nCreating partitions..."
sfdisk --delete ${DEVICE}
wipefs -a ${DEVICE}
parted ${DEVICE} mklabel gpt
parted ${DEVICE} mkpart primary fat32 2M 256M
parted ${DEVICE} set 1 boot on
parted ${DEVICE} set 1 esp on
parted ${DEVICE} mkpart primary btrfs 256M 24G
parted ${DEVICE} mkpart primary ext4 24G 29G
parted ${DEVICE} mkpart primary ext4 29G 100%
root_partition="${INSTALLDEVICE}2"
mkfs -t vfat ${INSTALLDEVICE}1
fatlabel ${INSTALLDEVICE}1 HOLOEFI
mkfs -t btrfs -f ${root_partition}
mkfs -t ext4 ${INSTALLDEVICE}3
mkfs -t ext4 ${INSTALLDEVICE}4
home_partition="${INSTALLDEVICE}4"
btrfs filesystem label ${root_partition} holo-root
e2label "${INSTALLDEVICE}3" holo-recovery
e2label "${INSTALLDEVICE}4" holo-home
echo "\nPartitioning complete, mounting and pacstrapping..."
echo "${UCODE_INSTALL_MSG}"
mount -t btrfs -o subvol=/,compress-force=zstd:1,discard,noatime,nodiratime ${root_partition} ${HOLO_INSTALL_DIR}
pacstrap -i ${HOLO_INSTALL_DIR} base base-devel ${UCODE_INSTALL} core/linux core/linux-headers linux-neptune-dri linux-neptune-dri-headers linux-firmware
mount -t ext4 ${home_partition} ${HOLO_INSTALL_DIR}/home
echo "\nBase system installation done, generating fstab..."
genfstab -U -p /mnt >> /mnt/etc/fstab
cp /etc/pacman.conf /mnt/etc/pacman.conf
cp /etc/pacman.d/mirrorlist /mnt/etc/pacman.d/mirrorlist
read "?Enter hostname for this installation: " HOLOHOSTNAME
echo ${HOLOHOSTNAME} > ${HOLO_INSTALL_DIR}/etc/hostname
# Setup password for root
while true; do
echo -n "Enter \"root\" password for this installation(will not echo): "
read -s ROOTPASS
echo
echo -n "Enter \"root\" password for this installation(again): "
read -s ROOTPASS_CONF
echo
if [ $ROOTPASS = $ROOTPASS_CONF ]; then
break
fi
echo "Error: Password does not match."
done
# Create user
while true; do
read "?Enter username for this installation: " HOLOUSER
if [ $HOLOUSER = "root" ]; then
echo "User \"root\" already exists!"
else
break
fi
done
# Setup password for user
while true; do
echo -n "Enter \"$HOLOUSER\" password for this installation(will not echo): "
read -s HOLOPASS
echo
echo -n "Enter \"$HOLOUSER\" password for this installation(again): "
read -s HOLOPASS_CONF
echo
if [ $HOLOPASS = $HOLOPASS_CONF ]; then
break
fi
echo "Error: Password does not match."
done
echo "\nCreating user ${HOLOUSER}..."
echo -e "${ROOTPASS}\n${ROOTPASS}" | arch-chroot ${HOLO_INSTALL_DIR} passwd root
arch-chroot ${HOLO_INSTALL_DIR} useradd --create-home ${HOLOUSER}
echo -e "${HOLOPASS}\n${HOLOPASS}" | arch-chroot ${HOLO_INSTALL_DIR} passwd ${HOLOUSER}
echo "${HOLOUSER} ALL=(root) NOPASSWD:ALL" > ${HOLO_INSTALL_DIR}/etc/sudoers.d/${HOLOUSER}
chmod 0440 ${HOLO_INSTALL_DIR}/etc/sudoers.d/${HOLOUSER}
echo "127.0.1.1 ${HOLOHOSTNAME}" >> ${HOLO_INSTALL_DIR}/etc/hosts
echo "\nInstalling bootloader..."
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_UPDATE}
mkdir ${HOLO_INSTALL_DIR}/boot/efi
mount -t vfat ${INSTALLDEVICE}1 ${HOLO_INSTALL_DIR}/boot/efi
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_INSTALL} core/grub efibootmgr inetutils mkinitcpio neofetch networkmanager sddm-wayland
arch-chroot ${HOLO_INSTALL_DIR} systemctl enable NetworkManager systemd-timesyncd
arch-chroot ${HOLO_INSTALL_DIR} grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=holo --removable
cp /etc/holoinstall/10_linux ${HOLO_INSTALL_DIR}/etc/grub.d/10_linux
cp /etc/holoinstall/grubdefault ${HOLO_INSTALL_DIR}/etc/default/grub
arch-chroot ${HOLO_INSTALL_DIR} grub-mkconfig -o /boot/grub/grub.cfg
echo "\nSetting up locale..."
echo "${SYSTEM_LOCALE}" >> ${HOLO_INSTALL_DIR}/etc/locale.gen
arch-chroot ${HOLO_INSTALL_DIR} locale-gen
echo "LANG=$(echo ${SYSTEM_LOCALE} | cut -d' ' -f1)" > ${HOLO_INSTALL_DIR}/etc/locale.conf
}
full_install() {
echo "Installing full SteamOS 3..."
sleep 1
echo "Please choose your current GPU:"
echo "1) AMD only: Will install updated Gamescope with Mangohud and FSR support"
echo "2) Intel: Will install older Gamescope that's compatible with Intel GPUs but without Mangohud and FSR support"
read "?Enter your choice here: " HOLO_GPU_TYPE
if [[ "${HOLO_GPU_TYPE}" == "1" ]]; then
echo "Installing gamescope for AMD GPUs..."
GAMESCOPE_INSTALL="gamescope mesa lib32-mesa"
elif [[ "${HOLO_GPU_TYPE}" == "2" ]]; then
echo "Installing gamescope for Intel GPUs..."
GAMESCOPE_INSTALL="extra/mesa multilib/lib32-mesa holo/gamescope"
else
echo "Nothing choosed or Invalid choice. Installing gamescope for Intel GPUs..."
GAMESCOPE_INSTALL="extra/mesa multilib/lib32-mesa holo/gamescope"
fi
# The actual installation begins here:
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_UPDATE}
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_INSTALL} holoiso-main holoiso-updateclient wireplumber vulkan-radeon lib32-vulkan-radeon extra/vulkan-intel multilib/lib32-vulkan-intel
echo "\nConfiguring Steam Deck UI by default..."
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_INSTALL} ${GAMESCOPE_INSTALL}
mkdir ${HOLO_INSTALL_DIR}/etc/sddm.conf.d
echo "[General]\nDisplayServer=wayland\n\n[Autologin]\nUser=${HOLOUSER}\nSession=gamescope-wayland.desktop" >> ${HOLO_INSTALL_DIR}/etc/sddm.conf.d/autologin.conf
mkdir /mnt/home/${HOLOUSER}/Desktop
cp /etc/holoinstall/steamos-gamemode.desktop /mnt/home/${HOLOUSER}/Desktop/steamos-gamemode.desktop
arch-chroot ${HOLO_INSTALL_DIR} chmod +x /home/${HOLOUSER}/Desktop/steamos-gamemode.desktop
arch-chroot ${HOLO_INSTALL_DIR} ln -s /usr/share/applications/steam.desktop /home/${HOLOUSER}/Desktop/steam.desktop
arch-chroot ${HOLO_INSTALL_DIR} chown -R ${HOLOUSER}:${HOLOUSER} /home/${HOLOUSER}/Desktop
arch-chroot ${HOLO_INSTALL_DIR} systemctl enable cups bluetooth sddm holoiso-reboot-tracker
arch-chroot ${HOLO_INSTALL_DIR} usermod -a -G rfkill ${HOLOUSER}
arch-chroot ${HOLO_INSTALL_DIR} sudo -u ${HOLOUSER} steam
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_INSTALL} flatpak
arch-chroot ${HOLO_INSTALL_DIR} flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
}
# The installer itself. Good wuck.
echo "SteamOS 3 Installer"
echo "Start time: $(date)"
echo "Please choose installation type:"
echo "1) barebones: Barebones OS-only installation"
echo "2) deckperience: Full SteamOS 3 experience"
read "?Enter your choice here: " HOLO_INSTALL_TYPE
echo ""
if [[ "${HOLO_INSTALL_TYPE}" == "1" ]] || [[ "${HOLO_INSTALL_TYPE}" == "barebones" ]]; then
echo "Installing SteamOS, barebones configuration..."
base_os_install
echo "Installation finished! You may reboot now, or type arch-chroot /mnt to make further changes"
elif [[ "${HOLO_INSTALL_TYPE}" == "2" ]]; then
echo "Installing SteamOS, deckperience configuration..."
base_os_install
full_install
echo "Installation finished! You may reboot now, or type arch-chroot /mnt to make further changes"
else
echo "Invalid choice. Exiting installer..."
fi
echo "End time: $(date)"