Skip to content

Commit

Permalink
add boot-options
Browse files Browse the repository at this point in the history
  • Loading branch information
biocoderh committed Oct 12, 2023
1 parent e2a7ba8 commit 9075bf2
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 34 deletions.
16 changes: 13 additions & 3 deletions .scripts/arch/base-setup
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ if [ "$SHELL" != "$PREFERED_SHELL" ] && [ -f "$PREFERED_SHELL" ]; then
chsh -s "$PREFERED_SHELL"
fi

# mitigations off
echo "Setting mitigations off"
boot-options set mitigations off

# cpufreq.default_governor performance
if grep -q "performance" /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors; then
echo "Setting cpufreq.default_governor performance"
boot-options set cpufreq.default_governor performance
fi

# bluetooth
if sudo dmesg | grep -i blue > /dev/null; then
pkgs install bluez bluez-utils
Expand All @@ -31,7 +41,7 @@ pacman -Q linux-rt-lts 2> /dev/null && LINUX_HEADERS="$LINUX_HEADERS linux-rt-lt
pacman -Q linux-zen 2> /dev/null && LINUX_HEADERS="$LINUX_HEADERS linux-zen-headers"

# broadcom-wl
lspci -vnn -d 14e4: | grep -q "wl" > /dev/null && pkgs install broadcom-wl-dkms "$LINUX_HEADERS"
lspci -vnn -d 14e4: | grep -q "wl" && pkgs install broadcom-wl-dkms "$LINUX_HEADERS"

# auto-cpufreq
if [ -d "/sys/class/power_supply/BAT0" ] && [ -f "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors" ]; then
Expand All @@ -40,9 +50,9 @@ if [ -d "/sys/class/power_supply/BAT0" ] && [ -f "/sys/devices/system/cpu/cpu0/c
fi

# Intel
lspci | grep 'VGA.*Intel' > /dev/null && pkgs install intel-gpu-tools
lspci | grep -q 'VGA.*Intel' && pkgs install intel-gpu-tools

if lspci | grep 'VGA.*JasperLake' > /dev/null; then
if lspci | grep -q 'VGA.*JasperLake'; then
pkgs install intel-media-sdk
# https://wiki.archlinux.org/title/intel_graphics#Enable_GuC_/_HuC_firmware_loading
echo "options i915 enable_guc=2" | sudo tee /etc/modprobe.d/i915.conf
Expand Down
78 changes: 78 additions & 0 deletions .scripts/common/boot-options
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/sh -e

OPERATION="$1"
OPTION="$2"
VALUE="$3"

if ! [ -d "/boot/loader/entries/" ]; then
echo "systemd-boot entries not found."
exit 1
fi

ignore_file() {
case $1 in
*fallback*) return 0 ;;
*) return 1 ;;
esac
}

case "$OPERATION" in
set)
if [ -z "$OPTION" ]; then
cat << 'EOF'
error: option not specified
Usage: boot-options set <option> [value]
EOF
exit 1
fi

if [ -z "$VALUE" ]; then
for f in /boot/loader/entries/*.conf; do
ignore_file "$f" && continue
if ! grep -q "^options.*$OPTION" "$f"; then
echo "$f"
sudo sed -i "s/^options.*/& $OPTION/" "$f"
fi
done
else
for f in /boot/loader/entries/*.conf; do
ignore_file "$f" && continue
echo "$f"
if grep -q "^options.*$OPTION" "$f"; then
# shellcheck disable=SC1087
sudo sed -i "/^options/s/[ ^]$OPTION[^ ]*/ $OPTION=$VALUE/" "$f"
else
sudo sed -i "s/^options.*/& $OPTION=$VALUE/" "$f"
fi
done
fi
;;

del)
if [ -z "$OPTION" ]; then
cat << 'EOF'
error: option not specified
Usage: boot-options del <option>
EOF
exit 1
fi

for f in /boot/loader/entries/*.conf; do
ignore_file "$f" && continue
echo "$f"
# shellcheck disable=SC1087
sudo sed -i "/^options/s/[ ^]$OPTION[^ ]*//" "$f"
done
;;

*)
cat << 'EOF'
Usage: boot-options <operation> [...]
systemd-boot options manager
operations:
boot-options set <option> [value]
boot-options del <option>
EOF
exit 1 ;;
esac
29 changes: 0 additions & 29 deletions .scripts/common/mitigations

This file was deleted.

9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,14 @@ Usage: ssh-copy-keys KEY REMOTE
Example: ssh-copy-keys .ssh/id_ed25519 [email protected]
```

- [mitigations](.scripts/common/mitigations) - set kernel boot mitigations param. Note: only systemd-boot supported.
- [boot-options](.scripts/common/boot-options) - systemd-boot options manager.
```sh
Usage: mitigations [on/off]
Usage: boot-options <operation> [...]
systemd-boot options manager

operations:
boot-options set <option> [value]
boot-options del <option>
```

- [sddm-theme](.scripts/common/sddm-theme) - set SDDM theme to conf.
Expand Down

0 comments on commit 9075bf2

Please sign in to comment.