Skip to content

Instantly share code, notes, and snippets.

@officialmofabs
Forked from piotrek94692/floppy.sh
Created February 17, 2023 20:01
Show Gist options
  • Save officialmofabs/73e0b7bacfd26577d7ab9d4035431b8e to your computer and use it in GitHub Desktop.
Save officialmofabs/73e0b7bacfd26577d7ab9d4035431b8e to your computer and use it in GitHub Desktop.
floppyOS main installation script
#!/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 "PAGER=less -RF --mouse --use-color"
export "MANPAGER=less -RF --mouse --use-color"
export "LESS=-RF --mouse --use-color"
export "VISUAL=nano"
export "EDITOR=nano"
export "SUDO_EDITOR=nano"
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-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 "$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
gpudrivers=" libomxil-bellagio libxvmc opencl-clhpp vulkan-mesa-layers"
if [ "$gpu" == "amd" ]; then
gpudrivers="${gpudrivers} clinfo libva-mesa-driver libva-utils libvdpau-va-gl mesa-utils mesa-vdpau opencl-mesa vdpauinfo vulkan-radeon vulkan-tools xf86-video-amdgpu"
fi
if [ "$gpu" == "intel" ]; then
gpudrivers="${gpudrivers} clinfo libva-intel-driver libva-utils mesa-amber mesa-utils opencl-mesa vulkan-intel vulkan-tools xf86-video-intel"
fi
if [ "$gpu" == "nvidia" ]; then
gpudrivers="${gpudrivers} clinfo libva-utils libvdpau-va-gl mesa-utils nvidia-dkms opencl-nvidia vdpauinfo vulkan-tools"
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-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 is useful when running floppyOS as a guest in GNOME Boxes, libvirt, QEMU, etc.${cc}"
read -r qemuga < /dev/tty
case "${qemuga,,}" in
"y" | "ye" | "yes")
qemuga=" qemu-guest-agent"
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 disablerfk < /dev/tty
case "${disablerfk,,}" in
"n" | "no")
disablerfk=""
;;
*)
disablerfk=" rfkill.default_state=1 rfkill.master_switch_mode=0"
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
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="Admin"
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 "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 might be ignored.${cc}"
until reflector --save /etc/pacman.d/mirrorlist --protocol https --country "$country" --latest 20 --sort rate; do continue; done
echo -e "${gg}• Reflector updated the mirror list.${cc}"
echo -e "${yy}• Installing floppyOS...${cc}"
basepackages="${cpu}-ucode acpi adobe-source-sans-fonts adobe-source-serif-fonts alsa-firmware alsa-plugins alsa-utils antiword argyllcms aria2 aspell-en atomicparsley atool avisynthplus base base-devel bat bottom bridge-utils bzip3 cabextract catdoc catimg ccid cdrtools chafa colord-sane cpio devil dialog dmidecode dnsmasq dotnet-runtime duf exfatprogs fastjar fatresize faudio fdkaac gamemode git github-cli gnome-keyring gnome-themes-extra go grml-zsh-config gspell gst-plugin-libcamera gst-plugin-pipewire gst-plugins-bad gst-plugins-base gst-plugins-good gst-plugins-ugly gstreamer-vaapi gtk-engines gtk4 gtkspell gtkspell3 gvfs-afc gvfs-google gvfs-gphoto2 gvfs-mtp gvfs-nfs hdparm hunspell hunspell-en_gb hunspell-en_us hwdetect iptables-nft ispell iwd jq jshon ladspa lesspipe libao libappindicator-gtk2 libappindicator-gtk3 libcanberra libfido2 libmad libmysofa libopenraw libraw librsync libspectre libusb-compat libvirt libvirt-storage-gluster libvirt-storage-iscsi-direct libvisual libwmf linux-firmware linux-zen linux-zen-headers lrzip lzip lzop mcpp mkinitcpio mpdecimal nano-syntax-highlighting net-tools nuspell nvme-cli odt2txt ogmtools open-iscsi openbsd-netcat opusfile p7zip pacman-contrib 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 pv python-dnspython python-gobject python-html2text python-libevdev python-markdown python-mutagen python-prettytable python-pycryptodomex python-pyudev python-pywal python-setuptools python-websockets qemu-emulators-full qemu-full qemu-user-static-binfmt quota-tools radvd reflector rpmextract rsync schroedinger sdparm sof-firmware soundfont-fluid source-highlight sox terminus-font thefuck tk tree unace unrtf unzip webp-pixbuf-loader wget wireless-regdb wireplumber words xclip xdg-desktop-portal xdg-desktop-portal-gtk xdg-user-dirs-gtk xf86-video-fbdev xf86-video-vesa xorg-apps xorg-font-util xorg-fonts-100dpi xorg-fonts-75dpi xorg-server xorg-server-devel xorg-xinit xorg-xlsfonts xsel yt-dlp zenity zip zsh-completions${asciitools}${bluetooth}${gpudrivers}${psd}${qemuga}${sdswap}${vanillakernel} ${GIMMIE}"
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 bluetooth.service iwd.service libvirtd.service paccache.timer plocate-updatedb.timer reflector.timer systemd-boot-update.service systemd-networkd.service systemd-resolved.service systemd-swap.service systemd-timesyncd.service
if [ "$trim" == "true" ]; then
systemctl --root=/mnt enable fstrim.timer
fi
cd /
curl --compressed -H "Cache-Control: no-cache, no-store, must-revalidate" -H "Pragma: no-cache" -H "Expires: 0" -o /mnt/floppy-chroot.sh -L "${csurl}?$(date +%s)"
echo -e "${yy}• Entering chroot...${cc}"
trap 2 20
arch-chroot /mnt zsh -c "keymap='${keymap}'; basepackages='${basepackages}'; gpu='${gpu}'; psdbool='${psdbool}'; 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