shellcheck / shellcheck (push) Successful in 11s
install.sh now stops early, with a clear message, if this isn't 64-bit Arch, it's run as root, there's no internet, or sudo doesn't work. system/preflight.sh then asks before going on with too little disk space or / not on btrfs, and offers to switch another login screen to GDM and PulseAudio to PipeWire. Keeping another login screen puts GDM in services-off, so install and update stop failing to enable it; a migration does the same on existing machines. It says nothing when all is well, as refresh runs install.sh again. Intel GPUs also get intel-media-driver for hardware video decoding, with a migration for existing machines. The mise migration links ~/.local/bin/mise to /usr/bin/mise instead of deleting it, so shells opened before the update don't print an error at every prompt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
110 lines
3.8 KiB
Bash
110 lines
3.8 KiB
Bash
#!/bin/bash
|
|
#
|
|
# Purpose : Check the machine before install.sh sets it up, and offer to fix
|
|
# what can be fixed: too little disk space, / not on btrfs, a login
|
|
# screen other than GNOME's GDM, PulseAudio instead of PipeWire.
|
|
# Exits 1 to stop the install. refresh runs install.sh again, so it
|
|
# says nothing on a machine where all is well.
|
|
|
|
COREDESKTOP="$HOME/.local/share/coredesktop"
|
|
source "$COREDESKTOP/utils.sh"
|
|
|
|
SERVICES_OFF="$HOME/.config/coredesktop/services-off"
|
|
|
|
# install.sh is usually piped into bash, so ask on the terminal
|
|
TTY="${COREDESKTOP_TTY:-/dev/tty}"
|
|
|
|
# ask <question> <default y|n> <answer without a terminal y|n>
|
|
ask() {
|
|
local answer
|
|
if ! { : < "$TTY"; } 2> /dev/null; then
|
|
[ "$3" = y ]
|
|
return
|
|
fi
|
|
if [ "$2" = y ]; then
|
|
read -rp "$1 [Y/n] " answer < "$TTY"
|
|
[[ "$answer" != [nN]* ]]
|
|
else
|
|
read -rp "$1 [y/N] " answer < "$TTY"
|
|
[[ "$answer" == [yY]* ]]
|
|
fi
|
|
}
|
|
|
|
# Set up before: install.sh records migrations as its last step
|
|
already_installed() {
|
|
[ -d "$HOME/.local/state/coredesktop/migrations" ]
|
|
}
|
|
|
|
check_disk() {
|
|
local need=60 free
|
|
already_installed && need=10
|
|
free="$(df -k --output=avail / | tail -n 1 | tr -d ' ')"
|
|
[[ "$free" =~ ^[0-9]+$ ]] || return 0
|
|
free=$(( free / 1024 / 1024 ))
|
|
(( free < need )) || return 0
|
|
echo "Only $free GB is free on /, and this needs about $need GB."
|
|
ask "Continue anyway?" n n
|
|
}
|
|
|
|
# Can't be fixed without reinstalling Arch, so only asked about the first time
|
|
check_btrfs() {
|
|
local fstype
|
|
already_installed && return 0
|
|
fstype="$(findmnt -no FSTYPE /)"
|
|
[ "$fstype" = btrfs ] && return 0
|
|
echo "/ is on $fstype, not btrfs, so update can't take a snapshot first, and a bad"
|
|
echo "update can't be rolled back (see Snapshots in the README). Only reinstalling Arch"
|
|
echo "with btrfs, archinstall's default, changes that."
|
|
ask "Continue without snapshots?" y y
|
|
}
|
|
|
|
# CoreDesktop turns on GDM, which fails while another login screen is on
|
|
check_display_manager() {
|
|
local dm
|
|
dm="$(readlink /etc/systemd/system/display-manager.service 2> /dev/null)"
|
|
dm="$(basename "${dm:-none}")"
|
|
[ "$dm" = none ] || [ "$dm" = gdm.service ] && return 0
|
|
grep -qsx "system gdm.service" "$SERVICES_OFF" && return 0
|
|
|
|
echo "This machine's login screen is ${dm%.service}, not GNOME's (GDM)."
|
|
if ask "Switch to GNOME's login screen? It takes over when you restart." y n; then
|
|
# enable_services turns GDM on later in the install
|
|
sudo systemctl disable "$dm" || return 1
|
|
else
|
|
mkdir -p "$(dirname "$SERVICES_OFF")"
|
|
echo "system gdm.service" >> "$SERVICES_OFF"
|
|
echo "Keeping ${dm%.service}. Choose GNOME from its session menu when you log in."
|
|
echo "To switch later: sudo systemctl disable $dm && sudo systemctl enable gdm"
|
|
echo "then delete the line \"system gdm.service\" from $SERVICES_OFF"
|
|
fi
|
|
}
|
|
|
|
# PipeWire replaces PulseAudio; GNOME's screen sharing needs it, and calls in
|
|
# Jitsi and Element work best with it
|
|
check_sound() {
|
|
local plugins=()
|
|
is_installed pulseaudio || return 0
|
|
|
|
echo "This machine plays sound through PulseAudio. PipeWire replaces it: GNOME's"
|
|
echo "screen sharing needs it, and calls in Jitsi and Element work best with it."
|
|
if ! ask "Switch to PipeWire?" y n; then
|
|
echo "Keeping PulseAudio."
|
|
return 0
|
|
fi
|
|
# Its modules (bluetooth, ...) need it, so they go first; PipeWire does
|
|
# what they did
|
|
mapfile -t plugins < <(pacman -Qq | grep '^pulseaudio-')
|
|
if (( ${#plugins[@]} > 0 )); then
|
|
sudo pacman -R --noconfirm "${plugins[@]}" || return 1
|
|
fi
|
|
# --ask=4 answers yes to removing pulseaudio, which pipewire-pulse replaces
|
|
sudo pacman -S --needed --noconfirm --ask=4 pipewire pipewire-pulse pipewire-alsa wireplumber || return 1
|
|
echo "Switched to PipeWire. It takes over when you log out and in again."
|
|
}
|
|
|
|
check_disk || exit 1
|
|
check_btrfs || exit 1
|
|
check_display_manager || exit 1
|
|
check_sound || exit 1
|
|
exit 0
|