2022-09-15 23:45:56 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# A simple Steam Deck rEFInd automated install script
|
|
|
|
|
2022-10-07 13:45:34 +08:00
|
|
|
passwd --status deck | tee ~/deck_passwd_status.txt
|
|
|
|
awk '{
|
|
|
|
if($2 =="P")
|
|
|
|
{
|
|
|
|
print "Password is already set.";
|
2023-01-03 07:35:43 +08:00
|
|
|
}
|
2022-10-07 13:45:34 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
print "Password has not been set. Please set password for deck user now.";
|
|
|
|
system("passwd");
|
|
|
|
}
|
|
|
|
}' ~/deck_passwd_status.txt
|
|
|
|
|
|
|
|
sudo steamos-readonly disable
|
2022-09-15 23:45:56 +08:00
|
|
|
sudo pacman-key --init
|
|
|
|
sudo pacman-key --populate archlinux
|
2023-02-09 11:04:18 +08:00
|
|
|
sudo pacman -Sy --noconfirm --needed refind
|
2022-09-15 23:45:56 +08:00
|
|
|
sudo refind-install
|
|
|
|
|
|
|
|
efibootmgr | tee ~/efibootlist.txt
|
2023-01-03 07:35:43 +08:00
|
|
|
WINDOWS_BOOTNUM="$(grep -A0 'Windows' ~/efibootlist.txt | grep -Eo '[0-9]{1,4}' | head -1)"
|
2022-09-15 23:45:56 +08:00
|
|
|
# Disable Windows EFI boot entry
|
|
|
|
sudo efibootmgr -b $WINDOWS_BOOTNUM -A
|
2023-01-03 07:35:43 +08:00
|
|
|
REFIND_BOOTNUM="$(grep -A0 'rEFInd Boot Manager' ~/efibootlist.txt | grep -Eo '[0-9]{1,4}' | head -1)"
|
2022-09-15 23:45:56 +08:00
|
|
|
# Delete rEFInd EFI boot entry from rEFInd-install... will be re-added later pointing to esp partition
|
|
|
|
sudo efibootmgr -b $REFIND_BOOTNUM -B
|
2022-10-07 13:45:34 +08:00
|
|
|
# Checking for duplicate rEFInd EFI boot entry, from previous script runs (or other sources)
|
2023-01-03 07:35:43 +08:00
|
|
|
REFIND_BOOTNUM_ALT="$(grep -A0 'rEFInd' ~/efibootlist.txt | grep -Eo '[0-9]{1,4}' | head -1)"
|
|
|
|
STEAMOS_BOOTNUM="$(grep -A0 'SteamOS' ~/efibootlist.txt | grep -Eo '[0-9]{1,4}' | head -1)"
|
2022-10-07 13:45:34 +08:00
|
|
|
|
|
|
|
# Deleting duplicate rEFInd boot entry, if one was found
|
|
|
|
re='^[0-9]+$'
|
|
|
|
if [[ $REFIND_BOOTNUM_ALT =~ $re ]]; then
|
|
|
|
sudo efibootmgr -b $REFIND_BOOTNUM_ALT -B
|
|
|
|
fi
|
|
|
|
|
2023-01-02 03:54:05 +08:00
|
|
|
if ! [[ $STEAMOS_BOOTNUM =~ $re ]]; then
|
2023-01-10 10:35:52 +08:00
|
|
|
# Recreate the missing SteamOS EFI entry
|
2023-01-02 13:59:16 +08:00
|
|
|
sudo efibootmgr -c -d /dev/nvme0n1 -p 1 -L "SteamOS" -l \\EFI\\steamos\\steamcl.efi
|
2023-01-02 00:38:35 +08:00
|
|
|
fi
|
|
|
|
|
2022-09-15 23:45:56 +08:00
|
|
|
yes | sudo cp -rf /boot/efi/EFI/refind/ /esp/efi
|
|
|
|
# Renaming default rEFInd config file to keep for reference and backup
|
|
|
|
sudo mv /esp/efi/refind/refind.conf /esp/efi/refind/refind-bkp.conf
|
|
|
|
CURRENT_WD=$(pwd)
|
2023-11-25 03:28:02 +08:00
|
|
|
yes | sudo cp $CURRENT_WD/refind-GUI.conf /esp/efi/refind/refind.conf
|
|
|
|
yes | sudo cp -rf $CURRENT_WD/backgrounds/ /esp/efi/refind
|
2022-09-15 23:45:56 +08:00
|
|
|
yes | sudo cp -rf $CURRENT_WD/icons/ /esp/efi/refind
|
2023-01-10 10:35:52 +08:00
|
|
|
# Creating rEFInd EFI entry
|
2023-01-02 13:59:16 +08:00
|
|
|
sudo efibootmgr -c -d /dev/nvme0n1 -p 1 -L "rEFInd" -l \\EFI\\refind\\refind_x64.efi
|
2022-09-15 23:45:56 +08:00
|
|
|
|
2023-01-19 00:26:14 +08:00
|
|
|
# Granting executable permissions to EFI entry restore script
|
2023-11-25 03:28:02 +08:00
|
|
|
chmod +x $CURRENT_WD/scripts/restore_EFI_entries.sh
|
|
|
|
mkdir -p $HOME/.local/SteamDeck_rEFInd/GUI
|
|
|
|
cp $CURRENT_WD/scripts/restore_EFI_entries.sh $HOME/.local/SteamDeck_rEFInd/
|
2023-01-19 00:26:14 +08:00
|
|
|
|
2023-01-01 14:45:28 +08:00
|
|
|
# Adding Systemctl daemon for rEFInd to be next boot priority
|
|
|
|
# Credit goes to Reddit user lucidludic for the idea :)
|
2023-11-25 03:28:02 +08:00
|
|
|
yes | sudo cp $CURRENT_WD/systemd/bootnext-refind.service /etc/systemd/system/bootnext-refind.service
|
|
|
|
sudo systemctl daemon-reload
|
2023-01-01 14:45:28 +08:00
|
|
|
sudo systemctl enable --now bootnext-refind.service
|
|
|
|
|
2023-01-03 07:35:43 +08:00
|
|
|
# Clean up temporary files, created for code clarity
|
2023-11-25 03:28:02 +08:00
|
|
|
yes | rm $HOME/deck_passwd_status.txt
|
|
|
|
yes | rm $HOME/efibootlist.txt
|
2022-09-15 23:45:56 +08:00
|
|
|
|
2022-10-07 13:45:34 +08:00
|
|
|
sudo steamos-readonly enable
|
2023-01-10 10:35:52 +08:00
|
|
|
|
|
|
|
echo -e "\nrEFInd has now been installed (assuming pacman is functional).\n"
|