holoiso/airootfs/usr/local/bin/holoinstall

167 lines
6.3 KiB
Plaintext
Raw Normal View History

2022-04-21 17:47:47 +02:00
#!/bin/zsh
2022-05-05 09:19:36 +02:00
# HoloISO Installer v2
# This defines all of the current variables.
CMD_PACMAN_INSTALL=(/usr/bin/pacman --noconfirm -S --needed --overwrite="*")
2022-04-21 17:47:47 +02:00
CMD_PACMAN_UPDATE=(/usr/bin/pacman -Sy)
2022-05-05 09:19:36 +02:00
CPU_VENDOR=$(cat /proc/cpuinfo | grep 'vendor' | uniq | cut -c 13-)
2022-04-21 17:47:47 +02:00
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
2022-05-05 09:19:36 +02:00
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
select_disk() {
local ALLDISKS=(`lsblk -o NAME,TYPE -lnp | grep disk | awk '{ print $1 }'`)
i=1
for disk in $ALLDISKS; do
echo "${i}. ${disk}"
i=$((i+1))
done
read "?Enter your desired disk number here (or, if not available, enter the disk's name manually): " DISKNO
2022-05-05 09:19:36 +02:00
read "?WARNING: This drive is going to be erased fully. Press enter to continue, or CTRL+Z to terminate"
# if $DISKNO is numeric
if [[ "$DISKNO" == <-> ]]; then
DISKNO=$((DISKNO-1))
DEVICE="${ALLDISKS:${DISKNO}}"
else
if [[ "$DISKNO" =~ "^/dev/" ]]; then
DEVICE="$DISKNO"
else
DEVICE="/dev/$DISKNO"
fi
2022-05-05 11:58:09 +02:00
fi
}
base_os_install() {
select_disk
if [ -z "${DEVICE}" ]; then
echo "Exiting..."
exit 0
fi
if ! [ -b "${DEVICE}" ]; then
echo "${DEVICE} is not a block device. Exiting..."
exit 1
fi
INSTALL_DEVICE="${DEVICE}"
if echo ${DEVICE} | grep -q -P "^/dev/(nvme|loop|mmcblk)"; then
INSTALL_DEVICE="${DEVICE}p"
fi
echo "\nPartitioning drive..."
2022-05-05 09:19:36 +02:00
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 100%
root_partition="${INSTALL_DEVICE}2"
mkfs -t vfat ${INSTALL_DEVICE}1
fatlabel ${INSTALL_DEVICE}1 HOLOEFI
2022-05-05 09:19:36 +02:00
mkfs -t btrfs -f ${root_partition}
btrfs filesystem label ${root_partition} holo-root
2022-05-06 00:02:45 +02:00
echo "\nPartitioning complete, mounting and pacstrapping..."
2022-05-05 09:19:36 +02:00
echo "${UCODE_INSTALL_MSG}"
mount -t btrfs -o subvol=/,compress-force=zstd:1,discard,noatime,nodiratime ${root_partition} ${HOLO_INSTALL_DIR}
2022-05-09 12:13:14 +02:00
pacstrap -i ${HOLO_INSTALL_DIR} base base-devel ${UCODE_INSTALL} core/linux core/linux-headers linux-neptune-dri linux-neptune-headers linux-firmware
2022-05-06 00:02:45 +02:00
echo "\nBase system installation done, generating fstab..."
2022-05-05 09:19:36 +02:00
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
2022-05-06 00:02:45 +02:00
2022-05-05 09:19:36 +02:00
read "?Enter your hostname for this installation: " HOLOHOSTNAME
echo ${HOLOHOSTNAME} > ${HOLO_INSTALL_DIR}/etc/hostname
read "?Enter your username for this installation: " HOLOUSER
read "?Enter your user password for this installation: " HOLOPASS
2022-05-06 00:07:53 +02:00
read "?Enter your root password for this installation: " ROOTPASS
2022-05-06 14:49:46 +02:00
read "?Enable passwordless sudo for $HOLOUSER (y/n): " PASSWDLESS
2022-05-06 00:02:45 +02:00
echo "\nCreating user ${HOLOUSER}..."
2022-05-06 00:07:53 +02:00
echo -e "${ROOTPASS}\n${ROOTPASS}" | arch-chroot ${HOLO_INSTALL_DIR} passwd root
2022-05-05 09:19:36 +02:00
arch-chroot ${HOLO_INSTALL_DIR} useradd --create-home ${HOLOUSER}
echo -e "${HOLOPASS}\n${HOLOPASS}" | arch-chroot ${HOLO_INSTALL_DIR} passwd ${HOLOUSER}
2022-05-06 14:49:46 +02:00
if [[ ${PASSWDLESS} == "y" ]];then
echo "${HOLOUSER} ALL=(root) NOPASSWD:ALL" > ${HOLO_INSTALL_DIR}/etc/sudoers.d/${HOLOUSER}
else
echo "${HOLOUSER} ALL=(root) ALL" > ${HOLO_INSTALL_DIR}/etc/sudoers.d/${HOLOUSER}
fi
2022-05-05 09:19:36 +02:00
chmod 0440 ${HOLO_INSTALL_DIR}/etc/sudoers.d/${HOLOUSER}
echo "127.0.1.1 ${HOLOHOSTNAME}" >> ${HOLO_INSTALL_DIR}/etc/hosts
2022-05-06 00:02:45 +02:00
echo "\nInstalling bootloader..."
2022-05-05 09:19:36 +02:00
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_UPDATE}
mkdir ${HOLO_INSTALL_DIR}/boot/efi
mount -t vfat ${INSTALL_DEVICE}1 ${HOLO_INSTALL_DIR}/boot/efi
2022-05-05 23:16:20 +02:00
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_INSTALL} core/grub efibootmgr inetutils mkinitcpio neofetch networkmanager sddm
2022-05-05 09:19:36 +02:00
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
arch-chroot ${HOLO_INSTALL_DIR} grub-mkconfig -o /boot/grub/grub.cfg
arch-chroot ${HOLO_INSTALL_DIR} sed -i 's/Arch Linux/SteamOS/g' /boot/grub/grub.cfg
2022-05-06 00:02:45 +02:00
echo "\nSetting up locale..."
2022-05-05 09:19:36 +02:00
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() {
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_UPDATE}
2022-05-09 12:13:14 +02:00
arch-chroot ${HOLO_INSTALL_DIR} ${CMD_PACMAN_INSTALL} holoiso-main holoiso-updateclient wireplumber vulkan-radeon lib32-vulkan-radeon
2022-05-06 00:02:45 +02:00
echo "\nConfiguring Steam Deck UI by default..."
2022-05-05 09:19:36 +02:00
mkdir ${HOLO_INSTALL_DIR}/etc/sddm.conf.d
2022-05-06 00:02:45 +02:00
echo "[Autologin]\nUser=${HOLOUSER}\nSession=gamescope-wayland.desktop" >> ${HOLO_INSTALL_DIR}/etc/sddm.conf.d/autologin.conf
2022-05-05 09:19:36 +02:00
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} systemctl enable cups bluetooth sddm
arch-chroot ${HOLO_INSTALL_DIR} usermod -a -G rfkill ${HOLOUSER}
2022-05-05 09:19:36 +02:00
}
2022-05-05 09:19:36 +02:00
# The installer itself. Good wuck.
2022-05-05 11:58:09 +02:00
echo "SteamOS 3 Installer, version SteamOS_Holo_RC1-20220505_0837_amdgpu-x86_64"
2022-05-05 09:19:36 +02:00
echo "Start time: $(date)"
echo "Please choose installation type:"
echo "1) barebones: Barebones OS-only installation"
echo "2) deckperience: Full SteamOS 3 experience"
2022-05-05 09:19:36 +02:00
read "?Enter your choice here: " HOLO_INSTALL_TYPE
echo ""
if [[ "${HOLO_INSTALL_TYPE}" == "1" ]] || [[ "${HOLO_INSTALL_TYPE}" == "barebones" ]]; then
2022-05-05 09:19:36 +02:00
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
2022-05-05 09:19:36 +02:00
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"
2022-05-06 00:02:45 +02:00
else
echo "Invalid choice. Exiting installer..."
2022-05-05 09:19:36 +02:00
fi
2022-05-09 12:13:14 +02:00
echo "End time: $(date)"