Last active
April 30, 2023 11:07
-
-
Save piotrek94692/160a6fc6b3d434915dc6cb9b65c03d46 to your computer and use it in GitHub Desktop.
floppyOS main installation script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cd / | |
# floppyOS main installation script | |
# status: in later development | |
# I hate ubuntu | |
### variables ### | |
csurl="https://gist.githubusercontent.com/piotrek94692/22f9e56d2dc4aff0321d784a6c7aa9c6/raw" | |
rr="\033[0;31m" | |
gg="\033[0;32m" | |
bb="\033[0;34m" | |
yy="\033[0;33m" | |
cc="\033[0m" | |
################# | |
if [ ! -d /sys/firmware/efi/efivars ]; then | |
echo -e "${rr}• /sys/firmware/efi/efivars not found, the system didn't boot in UEFI mode. Legacy boot modes aren't supported.${cc}" | |
exit | |
fi | |
unset HISTFILE | |
setfont eurlatgr | |
rm -f /usr/share/libalpm/hooks/90-mkinitcpio-install.hook | |
export "MANPAGER=less -RF --mouse --use-color" | |
export "PAGER=less -RF --mouse --use-color" | |
export "LESS=-RF --mouse --use-color" | |
export "GREP_OPTIONS=--color=auto" | |
export "SUDO_EDITOR=nano" | |
export "VISUAL=nano" | |
export "EDITOR=nano" | |
export "CLICOLOR=1" | |
export "SYSTEMD_COLORS=true" | |
localectl set-locale en_GB.UTF-8 | |
GIMMIE=${GIMMIE//fl-gnome/gnome-control-center gnome-disk-utility gnome-menus gnome-remote-desktop gnome-shell-extension-appindicator gnome-shell-extension-gtile gnome-shell-extensions gnome-terminal xdg-desktop-portal-gnome} | |
echo -e "${gg}• floppyOS installer has initialized successfully.${cc}" | |
timedatectl set-ntp true | |
echo -e "${gg}• Enabled NTP / network time synchronization.${cc}" | |
echo -e "${yy}• Welcome to the floppyOS installer!" | |
echo -e "Make sure to read the script before continuing." | |
echo -e "You should always read any shell scripts before executing them, especially when you are running them as root." | |
echo -e "Improper use of installation scripts can damage your data, please disconnect any external data storage devices before continuing." | |
echo -e "Also make sure you have set up a working network connection before launching the script." | |
echo -e "Your network configuration will be copied over onto the installation." | |
echo -e "Ethernet should work out of the box, for Wi-Fi please use the iwctl command." | |
echo -e "If Wi-Fi doesn't work, try running 'rfkill unblock all'" | |
echo -e "And then also try running 'ip link set <interface> up'" | |
echo -e "To find your interface's name, please run 'ip -c a'" | |
echo -e "It's probably named 'wlan0' by default." | |
echo -e "DHCP should work out of the box too, thanks to systemd-networkd and systemd-resolved." | |
echo -e "You shouldn't use any additional networking tools if not necessary." | |
echo -e "Use 'ping archlinux.org' to test the network connection." | |
echo -e "If you want to revert your networking setup and start from scratch following these instructions, please reboot the system." | |
echo -e "You can press Ctrl+C to exit the installer, though you shouldn't do this during installation." | |
echo -e "• Tip: Use the 'poweroff' command to power off the system, and the 'reboot' command to reboot the system.${cc}" | |
echo -e "${bb}• Do you want to disable the (annoying) PC speaker, also known as the beeper/buzzer?${cc}" | |
read -r pcspeaker < /dev/tty | |
case "${pcspeaker,,}" in | |
"n" | "no") ;; | |
*) | |
rmmod pcspkr | |
pcsbl=" module_blacklist=pcspkr" | |
echo -e "${gg}• Tried to unload the PC speaker kernel module, if you see any errors, it doesn't matter.${cc}" | |
;; | |
esac | |
echo -e "${bb}• Which keymap do you want to use by default?" | |
echo -e "Examples: us | uk | pl | fr-latin1" | |
echo -e "(United States, United Kingdom, Poland and France, respectively.)${cc}" | |
read -r keymap < /dev/tty | |
keymap="${keymap,,}" | |
loadkeys "$keymap" | |
localectl set-keymap "$keymap" | |
echo -e "${gg}• Installer's keymap set.${cc}" | |
echo -e "${bb}• What's your time zone?" | |
echo -e "Examples: Europe/Warsaw | Europe/Paris${cc}" | |
read -r timezone < /dev/tty | |
timedatectl set-timezone "$timezone" | |
echo -e "${gg}• Installer's time zone set.${cc}" | |
fdisk -L -l | |
echo -e "${bb}• Which disk do you want to install floppyOS on?" | |
echo -e "The installer will open cgdisk, which should be used to partition the disk." | |
echo -e "If you have partitioned the disk already, you can exit cgdisk and continue the installation." | |
echo -e "${yy}• Warning: Swap partitions aren't supported!" | |
echo -e "A swap file can be optionally enabled later.${cc}" | |
read -r disk < /dev/tty | |
cgdisk "$disk" | |
clear | |
fdisk -L -l | |
echo -e "${bb}• What's the EFI partition's name?" | |
echo -e "Example: /dev/sda1${cc}" | |
read -r efip < /dev/tty | |
echo -e "${bb}• What's the root partition's name?" | |
echo -e "Example: /dev/sda2${cc}" | |
read -r rootp < /dev/tty | |
mkfs.fat -F 32 "$efip" | |
mkfs.ext4 "$rootp" | |
mount --mkdir "$rootp" /mnt | |
mount --mkdir "$efip" /mnt/boot | |
echo -e "${gg}• The partitions have been formatted and the file systems have been mounted.${cc}" | |
while [ "$cpu" != "amd" ] && [ "$cpu" != "intel" ]; do | |
echo -e "${bb}• AMD or Intel? (CPU)" | |
echo -e "Other CPUs aren't supported.${cc}" | |
read -r cpu < /dev/tty | |
cpu="${cpu,,}" | |
done | |
while [ "$gpu" != "amd" ] && [ "$gpu" != "intel" ] && [ "$gpu" != "nvidia" ]; do | |
echo -e "${bb}• AMD, Intel or NVIDIA? (GPU)" | |
echo -e "Intel Gen 8 or later isn't supported. ${rr}<- LEGACY DRIVER ONLY!${bb}" | |
echo -e "When it comes to NVIDIA, only the Maxwell and newer series are supported. ${rr}<- LEGACY DRIVERS UNSUPPORTED!${bb}" | |
echo -e "And when it comes to AMD, only the GCN family is supported. ${rr}<- LEGACY DRIVER UNSUPPORTED!${bb}" | |
echo -e "Other GPUs aren't supported.${cc}" | |
read -r gpu < /dev/tty | |
gpu="${gpu,,}" | |
done | |
if [ "$gpu" == "amd" ]; then | |
gpudrivers=" libva-mesa-driver opencl-mesa rocm-opencl-runtime vulkan-radeon" | |
fi | |
if [ "$gpu" == "intel" ]; then | |
gpudrivers=" libva-intel-driver mesa-amber opencl-mesa vulkan-intel" | |
fi | |
if [ "$gpu" == "nvidia" ]; then | |
gpudrivers=" libva-mesa-driver nvidia-dkms opencl-nvidia" | |
fi | |
echo -e "${bb}• Do you want to enable the swap file using systemd-swap?${cc}" | |
read -r sdswap < /dev/tty | |
case "${sdswap,,}" in | |
"n" | "no") | |
sdswap="" | |
;; | |
*) | |
sdswap=" systemd-swap" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
esac | |
echo -e "${bb}• Do you want to enable the web browser profile synchronization daemon?${cc}" | |
read -r psdbool < /dev/tty | |
case "${psdbool,,}" in | |
"n" | "no") | |
psdbool="false" | |
;; | |
*) | |
psd=" profile-sync-daemon" | |
psdbool="true" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
esac | |
echo -e "${bb}• Do you want to disable fallback initramfs?${cc}" | |
read -r fbinitramfs < /dev/tty | |
case "${fbinitramfs,,}" in | |
"n" | "no") | |
fbinitramfs="true" | |
;; | |
*) | |
fbinitramfs="false" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
esac | |
echo -e "${bb}• Do you want to install the vanilla Linux kernel alongside the Linux Zen kernel?" | |
echo -e "While the Zen kernel provides greater performance, the vanilla kernel is better for power saving on laptops.${cc}" | |
read -r vanillakernelbool < /dev/tty | |
case "${vanillakernelbool,,}" in | |
"y" | "ye" | "yes") | |
vanillakernel=" linux linux-headers" | |
vanillakernelbool="true" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
*) | |
vanillakernelbool="false" | |
;; | |
esac | |
rfkill unblock all | |
echo -e "${bb}• Do you want to enable Bluetooth?" | |
echo -e "Your computer needs to have a Bluetooth adapter or you need to have an external one.${cc}" | |
read -r bluetoothbool < /dev/tty | |
case "${bluetoothbool,,}" in | |
"y" | "ye" | "yes") | |
bluetooth=" bluez bluez-plugins bluez-utils" | |
bluetoothbool="true" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
*) | |
rfkill block bluetooth | |
rmmod btusb | |
btbl=" module_blacklist=btusb" | |
bluetoothbool="false" | |
;; | |
esac | |
echo -e "${bb}• Do you want to install QEMU Guest Agent?" | |
echo -e "This will also install Spice Agent." | |
echo -e "This is useful when running floppyOS as a guest in GNOME Boxes, KVM, libvirt, QEMU, etc.${cc}" | |
read -r qemuga < /dev/tty | |
case "${qemuga,,}" in | |
"y" | "ye" | "yes") | |
qemuga=" qemu-guest-agent spice-vdagent" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
*) | |
qemuga="" | |
;; | |
esac | |
echo -e "${bb}• Do you want to install Java 8?" | |
echo -e "It's needed for example to run older versions of Minecraft. Java 19 will be installed anyways.${cc}" | |
read -r java8 < /dev/tty | |
case "${java8,,}" in | |
"y" | "ye" | "yes") | |
java8=" zulu-8-bin" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
*) | |
java8="" | |
;; | |
esac | |
echo -e "${bb}• Do you want to install 32-bit libraries?" | |
echo -e "This is often necessary for gaming, but not only for that.${cc}" | |
read -r lib32 < /dev/tty | |
case "${lib32,,}" in | |
"n" | "no") | |
lib32="false" | |
;; | |
*) | |
lib32="true" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
esac | |
echo -e "${bb}• Do you want to enable periodic TRIM?" | |
echo -e "This will increase SSD performance.${cc}" | |
read -r trim < /dev/tty | |
case "${trim,,}" in | |
"n" | "no") | |
trim=false | |
;; | |
*) | |
trim=true | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
esac | |
echo -e "${bb}• Do you want to force disable rfkill (airplane mode)?" | |
echo -e "It's better to disable rfkill as it may cause issues, unless you need this feature." | |
echo -e "You still will be able to control it manually using the rfkill command.${cc}" | |
read -r rfkbool < /dev/tty | |
case "${rfkbool,,}" in | |
"n" | "no") | |
disablerfk="" | |
rfkbool="true" | |
;; | |
*) | |
disablerfk=" rfkill.default_state=1 rfkill.master_switch_mode=0" | |
rfkbool="false" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
esac | |
echo -e "${bb}• Do you want to install some CLI tools that will allow you to display nice ASCII arts?${cc}" | |
read -r asciitools < /dev/tty | |
case "${asciitools,,}" in | |
"n" | "no") | |
asciitools="" | |
;; | |
*) | |
asciitools=" cmatrix cowfortune figlet nyancat ponysay" | |
echo -e "${gg}Yes? OK!${cc}" | |
;; | |
esac | |
pacman -Sy | |
echo -e "${bb}• Do you want to install additional spell checking dictionaries?" | |
echo -e "Please enter your selections separated with spaces or leave it empty to don't install any." | |
echo -e "de -> German" | |
echo -e "el -> Greek" | |
echo -e "fr -> French" | |
echo -e "hu -> Hungarian" | |
echo -e "it -> Italian" | |
echo -e "nl -> Dutch" | |
echo -e "pl -> Polish${cc}" | |
read -r scd < /dev/tty | |
for l in "${scd,,}"; do | |
pacman -Si aspell-${l} && pacman -Si hunspell-${l} && scdpackages="${scdpackages} aspell-${l} hunspell-${l}" | |
done | |
echo -e "${bb}• Please enter the hostname that will be set on the installation. It shouldn't contain any spaces." | |
echo -e "Leave it empty to set the default hostname: 'floppyOS'${cc}" | |
read -r hostname < /dev/tty | |
if [ "$hostname" == "" ]; then | |
hostname="floppyOS" | |
fi | |
hostnamectl hostname $hostname | |
echo -e "${bb}• Please enter the administrator's username. It should be lowercase and shouldn't contain any spaces.${cc}" | |
read -r username < /dev/tty | |
username="${username,,}" | |
if [ "$username" == "" ]; then | |
username="admin" | |
fi | |
echo -e "${bb}• Please enter the administrator's display name.${cc}" | |
read -r userdisplayname < /dev/tty | |
if [ "$userdisplayname" == "" ]; then | |
userdisplayname="Administrator" | |
fi | |
echo -e "${bb}• For how long the systemd-boot menu should show on boot?" | |
echo -e "Please enter the time in seconds, you can also enter 'y' for the default time (30s) or 'n' or '0' to disable the menu." | |
echo -e "Alternatively enter 'menu-force' to show the menu without the timeout." | |
echo -e "If you enabled fallback initramfs or decided to install the vanilla Linux kernel, then you likely don't want to disable it." | |
echo -e "You can always hold any key during boot to show the menu.${cc}" | |
read -r sdboottimeout < /dev/tty | |
if [ "${sdboottimeout,,}" == "n" ] || [ "${sdboottimeout,,}" == "" ]; then | |
sdboottimeout="0" | |
fi | |
if [ "${sdboottimeout,,}" == "" ] && [ "${fbinitramfs}" == "true" ]; then | |
sdboottimeout="30" | |
fi | |
if [ "${sdboottimeout,,}" == "" ] && [ "${vanillakernelbool}" == "true" ]; then | |
sdboottimeout="30" | |
fi | |
if [ "${sdboottimeout,,}" == "y" ]; then | |
sdboottimeout="30" | |
fi | |
echo -e "${bb}• Please enter the country code that will be used to update the mirror list using Reflector." | |
echo -e "Examples: US, GB, PL, FR${cc}" | |
read -r country < /dev/tty | |
trap '' 2 20 | |
country="${country^^}" | |
echo -e "${yy}• Reflector is updating the mirror list, errors can likely be ignored.${cc}" | |
reflector --save /etc/pacman.d/mirrorlist --protocol https --country "$country" --latest 20 --sort rate | |
echo -e "${gg}• Reflector updated the mirror list.${cc}" | |
echo -e "${yy}• Installing the base installation and packages...${cc}" | |
basepackages="${cpu}-ucode acpi adobe-source-sans-fonts adobe-source-serif-fonts alsa-firmware alsa-plugins alsa-utils antiword arch-install-scripts archlinux-contrib argyllcms aria2 aribb24 aribb25 aspell-en atomicparsley atool avisynthplus base base-devel bat bottom bridge-utils bzip3 cabextract catdoc catimg ccid cdrtools clinfo colord-sane cpio devil dialog dleyna dmidecode dnsmasq dotnet-runtime dpkg duf exfatprogs ext4magic fastjar fatresize faudio fdkaac ffmpegthumbnailer fig2dev flatpak flite fuseiso gamemode git github-cli glfw-x11 gnome-keyring gnome-themes-extra gnome-video-effects gnu-free-fonts go gpsd grilo-plugins grml-zsh-config gspell gst-plugin-libcamera gst-plugin-pipewire gst-plugins-base gst-plugins-ugly gstreamer-vaapi gtk-engines gtk4 gtkspell gtkspell3 gvfs-afc gvfs-google gvfs-gphoto2 gvfs-mtp gvfs-nfs harfbuzz-utils hdparm hunspell hunspell-en_gb hunspell-en_us hwdetect innoextract iptables-nft ispell iwd jq jshon ladspa lesspipe libao libappindicator-gtk2 libappindicator-gtk3 libcanberra libcurl-gnutls libdvdcss libfido2 libgepub libgoom2 libmad libomxil-bellagio libopenraw libraw librsync libspectre libtiger libusb-compat libva-utils libvdpau-va-gl libvirt libvirt-storage-gluster libvirt-storage-iscsi-direct libvisual libwmf libxcrypt-compat linux-firmware linux-zen linux-zen-headers live-media lrzip lua52-socket luajit lzip lzop mcpp mesa-utils mesa-vdpau mkinitcpio mpdecimal nano-syntax-highlighting net-tools nuspell nvme-cli odt2txt ogmtools open-iscsi openbsd-netcat opencl-clhpp opusfile p7zip pacman-contrib papirus-icon-theme perl-archive-zip perl-authen-sasl perl-cgi perl-datetime-format-iso8601 perl-file-find-rule perl-file-homedir perl-file-mimeinfo perl-locale-gettext perl-lwp-protocol-https perl-mediawiki-api perl-net-dbus perl-term-readkey perl-test-pod perl-tk perl-x11-protocol pipewire-alsa pipewire-jack pipewire-pulse pipewire-roc pipewire-v4l2 plocate power-profiles-daemon profile-cleaner protobuf pstoedit pv python-cairo python-dnspython python-gobject python-html2text python-libevdev python-markdown python-mutagen python-prettytable python-pycryptodomex python-pyserial python-pyudev python-pywal python-requests python-setuptools python-websockets qemu-emulators-full qemu-full qemu-user-static-binfmt qemu-virtiofsd quota-tools radvd reflector rpmextract rsync rygel schroedinger scour sdl_image sdparm sndio sof-firmware soundfont-fluid source-highlight sox terminus-font thefuck tk tracker3-miners tree ttf-dejavu ttf-dejavu-nerd ttf-mononoki-nerd ttf-nerd-fonts-symbols-2048-em ttf-sourcecodepro-nerd ttf-terminus-nerd tumbler unace unrtf unzip v4l2loopback-dkms vcdimager vdpauinfo vkd3d vulkan-mesa-layers vulkan-tools webp-pixbuf-loader wget wireless-regdb wireplumber words x11-ssh-askpass xclip xdg-desktop-portal-gtk xdg-user-dirs-gtk xdg-utils xorg-apps xorg-drivers xorg-font-util xorg-fonts-100dpi xorg-fonts-75dpi xorg-server xorg-server-devel xorg-xinit xsel yt-dlp zenity zip zsh-completions${asciitools}${bluetooth}${gpudrivers}${psd}${qemuga}${scdpackages}${sdswap}${vanillakernel} ${GIMMIE}" | |
sed -i "/#Color/s/^#//g" /etc/pacman.conf | |
sed -i "/#ParallelDownloads/s/^#//g" /etc/pacman.conf | |
sed -i "s/^CheckSpace/#CheckSpace/g" /etc/pacman.conf | |
until pacman --noconfirm -Sy archlinux-keyring; pacstrap -K /mnt ${basepackages}; do continue; done | |
genfstab -L /mnt >> /mnt/etc/fstab | |
ln -sf /run/systemd/resolve/stub-resolv.conf /mnt/etc/resolv.conf | |
systemctl --root=/mnt enable gpsd.service iwd.service libvirtd.service paccache.timer plocate-updatedb.timer power-profiles-daemon.service reflector.timer systemd-boot-update.service systemd-networkd.service systemd-resolved.service systemd-swap.service systemd-timesyncd.service | |
if [ "$bluetoothbool" == "true" ]; then | |
systemctl --root=/mnt enable bluetooth.service | |
fi | |
if [ "$trim" == true ]; then | |
systemctl --root=/mnt enable fstrim.timer | |
fi | |
cd / | |
until curl --compressed -H "Cache-Control: no-cache, no-store, must-revalidate" -H "Expires: 0" -H "Pragma: no-cache" -o /mnt/floppy-chroot.sh -L "${csurl}?$(date +%s)"; do continue; done | |
echo -e "${yy}• Entering chroot...${cc}" | |
trap 2 20 | |
arch-chroot /mnt zsh -c "keymap='${keymap}'; basepackages='${basepackages}'; gpu='${gpu}'; psdbool='${psdbool}'; rfkbool='${rfkbool}'; timezone='${timezone}'; hostname='${hostname}'; country='${country}'; fbinitramfs='${fbinitramfs}'; bluetoothbool='${bluetoothbool}'; userdisplayname='${userdisplayname}'; username='${username}'; java8='${java8}'; lib32='${lib32}'; sdboottimeout='${sdboottimeout}'; cpu='${cpu}'; rootp='${rootp}'; btbl='${btbl}'; pcsbl='${pcsbl}'; disablerfk='${disablerfk}'; vanillakernelbool='${vanillakernelbool}'; rr='${rr}'; gg='${gg}'; bb='${bb}'; yy='${yy}'; cc='${cc}'; . /floppy-chroot.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment