2023-12-23 09:56:09 -08:00
|
|
|
#!/usr/bin/bash
|
2023-09-22 11:59:29 -06:00
|
|
|
|
|
|
|
IMAGE_INFO="/usr/share/ublue-os/image-info.json"
|
2023-09-22 22:47:15 -06:00
|
|
|
IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO)
|
2024-01-05 17:59:55 -08:00
|
|
|
IMAGE_BRANCH=$(jq -r '."image-branch"' < $IMAGE_INFO)
|
2023-09-26 20:25:06 -06:00
|
|
|
IMAGE_FLAVOR=$(jq -r '."image-flavor"' < $IMAGE_INFO)
|
2023-10-13 14:33:43 -07:00
|
|
|
FEDORA_VERSION=$(jq -r '."fedora-version"' < $IMAGE_INFO)
|
2023-08-07 22:49:06 -07:00
|
|
|
|
2023-09-06 13:44:45 -06:00
|
|
|
# SCRIPT VERSION
|
2024-04-28 17:36:58 -07:00
|
|
|
HWS_VER=39
|
2023-09-06 13:44:45 -06:00
|
|
|
HWS_VER_FILE="/etc/bazzite/hws_version"
|
2023-09-27 15:56:19 -07:00
|
|
|
HWS_VER_RAN=$(cat $HWS_VER_FILE)
|
2023-09-06 13:44:45 -06:00
|
|
|
|
2023-09-06 15:22:25 -06:00
|
|
|
# IMAGE IDENTIFIERS
|
|
|
|
KNOWN_IMAGE_NAME_FILE="/etc/bazzite/image_name"
|
|
|
|
KNOWN_IMAGE_NAME=$(cat $KNOWN_IMAGE_NAME_FILE)
|
2024-01-06 00:16:39 -08:00
|
|
|
KNOWN_IMAGE_BRANCH_FILE="/etc/bazzite/image_branch"
|
2024-01-05 21:15:42 -08:00
|
|
|
KNOWN_IMAGE_BRANCH=$(cat $KNOWN_IMAGE_BRANCH_FILE)
|
2023-09-06 15:22:25 -06:00
|
|
|
KNOWN_IMAGE_FLAVOR_FILE="/etc/bazzite/image_flavor"
|
|
|
|
KNOWN_IMAGE_FLAVOR=$(cat $KNOWN_IMAGE_FLAVOR_FILE)
|
2023-10-13 14:33:43 -07:00
|
|
|
KNOWN_FEDORA_VERSION_FILE="/etc/bazzite/fedora_version"
|
|
|
|
KNOWN_FEDORA_VERSION=$(cat $KNOWN_FEDORA_VERSION_FILE)
|
2023-09-06 15:22:25 -06:00
|
|
|
|
2023-08-07 22:49:06 -07:00
|
|
|
# GLOBAL
|
|
|
|
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
|
2024-04-28 17:36:58 -07:00
|
|
|
VEN_ID="$(cat /sys/devices/virtual/dmi/id/chassis_vendor)"
|
|
|
|
CPU_VENDOR=$(grep "vendor_id" "/proc/cpuinfo" | uniq | awk -F": " '{ print $2 }')
|
2024-05-02 01:28:12 +02:00
|
|
|
CPU_MODEL=$(grep "model name" "/proc/cpuinfo" | uniq | awk -F": " '{ print $2 }')
|
2023-11-05 17:43:03 +01:00
|
|
|
MINIMUM_FREE_ZRAM=$(awk '/MemTotal/ {printf "%.0f", $2 * 0.01}' /proc/meminfo)
|
|
|
|
CURRENT_FREE_ZRAM=$(sysctl vm.min_free_kbytes | awk '{print $3}')
|
2023-08-07 22:49:06 -07:00
|
|
|
KARGS=$(rpm-ostree kargs)
|
2023-10-21 00:56:11 -07:00
|
|
|
NEEDED_KARGS=()
|
2023-08-07 22:49:06 -07:00
|
|
|
|
2023-10-01 11:47:05 -07:00
|
|
|
# KERNEL ARGUMENTS
|
2023-10-20 17:43:18 -07:00
|
|
|
echo "Current kargs: $KARGS"
|
|
|
|
|
2024-04-20 23:06:44 -07:00
|
|
|
if /usr/libexec/hwsupport/valve-hardware; then
|
2023-11-13 22:06:48 -08:00
|
|
|
echo "Checking for needed karg changes (Jupiter/Galileo)"
|
2023-08-07 22:49:06 -07:00
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "amd_iommu" ]]; then
|
2023-10-21 00:56:11 -07:00
|
|
|
NEEDED_KARGS+=("--append-if-missing=amd_iommu=off")
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "amdgpu.gttsize" ]]; then
|
2023-08-13 10:37:21 -07:00
|
|
|
if [[ "$(awk '/MemTotal/{print $(NF-1)}' /proc/meminfo)" == "31664740" ]]; then
|
2023-08-14 00:23:40 -07:00
|
|
|
echo "32GB RAM Steam Deck detected"
|
2023-10-21 00:56:11 -07:00
|
|
|
NEEDED_KARGS+=("--append-if-missing=amdgpu.gttsize=16256")
|
2023-08-09 20:07:17 -07:00
|
|
|
else
|
2023-10-21 00:56:11 -07:00
|
|
|
NEEDED_KARGS+=("--append-if-missing=amdgpu.gttsize=8128")
|
2023-08-09 20:07:17 -07:00
|
|
|
fi
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
2023-11-16 11:30:44 -08:00
|
|
|
fi
|
|
|
|
|
2024-01-04 10:56:52 -08:00
|
|
|
if [[ $IMAGE_NAME =~ "deck" && ":AOKZOE A1 AR07:" =~ ":$SYS_ID:" ]]; then
|
2024-01-04 11:38:23 -08:00
|
|
|
echo "AOKZOE A1 on deck build detected, fixing edid"
|
2024-01-06 22:17:25 -08:00
|
|
|
if [[ ! $KARGS =~ "drm.edid_firmware" ]]; then
|
2024-01-03 21:14:18 -08:00
|
|
|
NEEDED_KARGS+=("--append-if-missing=drm.edid_firmware=eDP-1:edid/aokzoea1ar07_edid.bin")
|
|
|
|
fi
|
2024-02-09 17:14:11 -08:00
|
|
|
fi
|
2024-02-09 16:43:53 -08:00
|
|
|
|
2024-04-28 17:36:58 -07:00
|
|
|
if [[ ":Framework:" =~ ":$VEN_ID:" ]]; then
|
|
|
|
if [[ "GenuineIntel" == "$CPU_VENDOR" ]]; then
|
|
|
|
if [[ ! $KARGS =~ "hid_sensor_hub" ]]; then
|
|
|
|
echo "Intel Framework Laptop detected, applying needed keyboard fix"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=module_blacklist=hid_sensor_hub");
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2024-04-23 10:07:55 -07:00
|
|
|
if [[ ":83E1:" =~ ":$SYS_ID:" ]]; then
|
2024-01-24 22:38:10 -08:00
|
|
|
if [[ ! $KARGS =~ "video" ]]; then
|
|
|
|
echo "Adding panel orientation for Lenovo Legion Go"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=video=eDP-1:panel_orientation=left_side_up")
|
|
|
|
fi
|
2024-03-19 14:35:23 -07:00
|
|
|
if [[ ! $KARGS =~ "amdgpu.gttsize" ]]; then
|
|
|
|
echo "Adding GTTSize for Lenovo Legion Go"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=amdgpu.gttsize=8128")
|
|
|
|
fi
|
|
|
|
if [[ ! $KARGS =~ "amdgpu.sg_display" ]]; then
|
|
|
|
echo "Adding SG Display for Lenovo Legion Go"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=amdgpu.sg_display=0")
|
|
|
|
fi
|
|
|
|
elif [[ ":ROG Ally RC71L_RC71L:ROG Ally RC71L:" =~ ":$SYS_ID:" ]]; then
|
|
|
|
if [[ ! $KARGS =~ "amdgpu.gttsize" ]]; then
|
|
|
|
echo "Adding GTTSize for ASUS Ally"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=amdgpu.gttsize=8128")
|
|
|
|
fi
|
|
|
|
if [[ ! $KARGS =~ "amdgpu.sg_display" ]]; then
|
|
|
|
echo "Adding SG Display for ASUS Ally"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=amdgpu.sg_display=0")
|
|
|
|
fi
|
2024-05-02 01:28:12 +02:00
|
|
|
elif [[ ":G1617-01:" =~ ":$SYS_ID:" && ! $CPU_MODEL =~ 8640U|8840U ]]; then
|
2024-01-30 21:33:21 -08:00
|
|
|
if [[ ! $KARGS =~ "video" ]]; then
|
2024-05-02 01:28:12 +02:00
|
|
|
echo "Adding panel orientation for GPD Win Mini 2023"
|
2024-01-30 21:33:21 -08:00
|
|
|
NEEDED_KARGS+=("--append-if-missing=video=eDP-1:panel_orientation=right_side_up")
|
|
|
|
fi
|
2024-02-18 05:53:47 +01:00
|
|
|
elif [[ ":WIN2:" =~ ":$SYS_ID:" ]]; then
|
|
|
|
if [[ ! $KARGS =~ "video" ]]; then
|
|
|
|
echo "Adding panel orientation for GPD Win 2"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=video=eDP-1:panel_orientation=right_side_up")
|
|
|
|
fi
|
2024-01-24 22:38:10 -08:00
|
|
|
fi
|
|
|
|
|
2024-04-20 23:06:44 -07:00
|
|
|
if /usr/libexec/hwsupport/simpledeckytdp-supported-hardware; then
|
2024-01-29 10:12:18 -08:00
|
|
|
if [[ ! $KARGS =~ "iomem" ]]; then
|
|
|
|
echo "Adding needed kargs for ryzenadj"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=iomem=relaxed")
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-08-08 10:09:30 -07:00
|
|
|
if [[ $KARGS =~ "nomodeset" ]]; then
|
|
|
|
echo "Removing nomodeset"
|
2023-10-21 00:56:11 -07:00
|
|
|
NEEDED_KARGS+=("--delete-if-present=nomodeset")
|
2023-08-08 10:09:30 -07:00
|
|
|
fi
|
|
|
|
|
2024-04-11 15:50:02 -07:00
|
|
|
if [[ ! $KARGS =~ "gpu_sched.sched_policy" && ! $IMAGE_FLAVOR =~ "nvidia" ]]; then
|
2024-02-09 09:08:49 -08:00
|
|
|
echo "Fixing GPU scheduler default"
|
|
|
|
NEEDED_KARGS+=("--append-if-missing=gpu_sched.sched_policy=0")
|
|
|
|
fi
|
|
|
|
|
2023-08-26 23:59:30 -03:00
|
|
|
if [[ -n "$NEEDED_KARGS" ]]; then
|
2023-10-21 00:56:11 -07:00
|
|
|
echo "Found needed karg changes, applying the following: ${NEEDED_KARGS[*]}"
|
2023-10-16 15:51:46 -07:00
|
|
|
plymouth display-message --text="Updating kargs - Please wait, this may take a while" || true
|
2023-10-21 00:56:11 -07:00
|
|
|
rpm-ostree kargs ${NEEDED_KARGS[*]} --reboot || exit 1
|
2023-08-08 10:14:29 -07:00
|
|
|
else
|
|
|
|
echo "No karg changes needed"
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
2023-09-06 13:44:45 -06:00
|
|
|
|
2023-10-03 22:55:55 -07:00
|
|
|
if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegame" ]]; then
|
2024-04-20 23:06:44 -07:00
|
|
|
if /usr/libexec/hwsupport/valve-hardware; then
|
2023-11-23 10:27:57 -08:00
|
|
|
if [[ ":Jupiter:" =~ ":$SYS_ID:" ]]; then
|
|
|
|
RESOLUTION=$(lshw -json -c display | jq -r .[]."configuration"."resolution")
|
|
|
|
if [[ "${RESOLUTION}" = "1200,1920" ]]; then
|
|
|
|
echo "Jupiter with DeckHD detected, disabling BIOS updates..."
|
|
|
|
systemctl disable --now jupiter-biosupdate.service
|
2023-11-23 15:55:08 -08:00
|
|
|
elif [[ "$(awk '/MemTotal/{print $(NF-1)}' /proc/meminfo)" == "31664740" ]]; then
|
|
|
|
echo "Jupiter with 32GB RAM detected, disabling BIOS updates..."
|
|
|
|
systemctl disable --now jupiter-biosupdate.service
|
2023-11-23 10:27:57 -08:00
|
|
|
fi
|
2023-11-20 21:11:37 -07:00
|
|
|
fi
|
2023-11-23 10:27:57 -08:00
|
|
|
|
|
|
|
systemctl enable --now jupiter-fan-control.service
|
|
|
|
systemctl enable --now vpower.service
|
2023-10-01 11:47:05 -07:00
|
|
|
else
|
|
|
|
echo "Generic device detected. Performing setup..."
|
|
|
|
systemctl disable --now jupiter-fan-control.service
|
|
|
|
systemctl disable --now vpower.service
|
|
|
|
systemctl disable --now jupiter-biosupdate.service
|
|
|
|
systemctl disable --now jupiter-controller-update.service
|
|
|
|
systemctl disable --now ryzenadj.service
|
|
|
|
systemctl disable --now batterylimit.service
|
|
|
|
fi
|
2024-02-23 10:21:11 -08:00
|
|
|
systemctl enable --now ds-inhibit.service
|
2023-10-01 11:47:05 -07:00
|
|
|
fi
|
|
|
|
|
2023-10-12 16:48:49 -07:00
|
|
|
# FSTAB CONFIGURATION
|
2024-04-28 08:45:08 -07:00
|
|
|
if [[ ! -e /etc/ublue-os/.fstab_adjusted.flag && $(grep "compress=zstd" /etc/fstab) ]]; then
|
2024-04-28 08:49:34 +01:00
|
|
|
echo "Applying fstab param adjustments"
|
|
|
|
if grep -q '64GB' <<< "$(lsblk -o MODEL)"; then
|
|
|
|
echo "64GB eMMC detected"
|
|
|
|
sed -i 's/compress=zstd:1/noatime,lazytime,discard=sync,compress-force=zstd:3,space_cache=v2/g' /etc/fstab
|
|
|
|
else
|
|
|
|
sed -i 's/compress=zstd:1/noatime,lazytime,commit=120,discard=async,compress-force=zstd:1,space_cache=v2/g' /etc/fstab
|
|
|
|
fi
|
|
|
|
touch /etc/ublue-os/.fstab_adjusted.flag
|
2023-10-12 16:48:49 -07:00
|
|
|
else
|
2024-04-28 08:49:34 +01:00
|
|
|
echo "No fstab param adjustments needed"
|
2023-10-12 16:48:49 -07:00
|
|
|
fi
|
|
|
|
|
2023-11-05 17:43:03 +01:00
|
|
|
# ZRAM MINIMUM-FREE CONFIGURATION
|
|
|
|
echo "Current minimum-free ZRAM value: $CURRENT_FREE_ZRAM"
|
|
|
|
|
|
|
|
if ((MINIMUM_FREE_ZRAM > CURRENT_FREE_ZRAM)); then
|
|
|
|
sysctl -w "vm.min_free_kbytes=${MINIMUM_FREE_ZRAM}"
|
|
|
|
echo "Found needed minimum-free ZRAM changes, applying the following: ${MINIMUM_FREE_ZRAM}"
|
|
|
|
else
|
|
|
|
echo "No minimum-free ZRAM changes needed"
|
|
|
|
fi
|
|
|
|
|
2024-04-23 19:15:46 -07:00
|
|
|
# WAYDROID FIX
|
|
|
|
if [[ -f "/var/lib/waydroid/lxc/waydroid/config" ]]; then
|
|
|
|
echo "Removing unneeded apparmor entry from Waydroid LXC"
|
|
|
|
sed -i '/lxc\.apparmor\.profile\s*=\s*unconfined/d' "/var/lib/waydroid/lxc/waydroid/config"
|
|
|
|
fi
|
|
|
|
|
2023-10-03 21:25:04 -07:00
|
|
|
# HOSTNAME FIX
|
|
|
|
# If the hostname is too long Distrobox will fail during setup
|
|
|
|
# Let's check the length and reset it to something sensible if that happens.
|
2024-01-28 00:17:52 -08:00
|
|
|
if (( $(hostname | wc -m) > 20 )); then
|
2023-10-03 21:25:04 -07:00
|
|
|
hostnamectl set-hostname bazzite
|
|
|
|
fi
|
|
|
|
|
2023-11-20 09:54:46 -07:00
|
|
|
# Set default target to graphical, fixes rebase from base image
|
2024-01-06 22:17:25 -08:00
|
|
|
if grep -qv "graphical.target" <<< "$(systemctl get-default)"; then
|
2023-11-20 09:54:46 -07:00
|
|
|
systemctl set-default graphical.target
|
|
|
|
fi
|
|
|
|
|
2023-10-20 15:50:54 -07:00
|
|
|
mkdir -p /etc/bazzite
|
2023-09-06 13:44:45 -06:00
|
|
|
echo $HWS_VER > $HWS_VER_FILE
|
2023-09-06 15:22:25 -06:00
|
|
|
echo $IMAGE_NAME > $KNOWN_IMAGE_NAME_FILE
|
|
|
|
echo $IMAGE_FLAVOR > $KNOWN_IMAGE_FLAVOR_FILE
|
2023-10-13 14:33:43 -07:00
|
|
|
echo $FEDORA_VERSION > $KNOWN_FEDORA_VERSION_FILE
|
2024-01-05 18:04:30 -08:00
|
|
|
echo $IMAGE_BRANCH > $KNOWN_IMAGE_BRANCH_FILE
|