2023-08-07 22:49:06 -07:00
|
|
|
#!/usr/bin/env 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)
|
2023-09-26 20:25:06 -06:00
|
|
|
IMAGE_FLAVOR=$(jq -r '."image-flavor"' < $IMAGE_INFO)
|
2023-09-22 22:47:15 -06:00
|
|
|
BASE_IMAGE_NAME=$(jq -r '."base-image-name"' < $IMAGE_INFO)
|
2023-08-07 22:49:06 -07:00
|
|
|
|
2023-09-06 13:44:45 -06:00
|
|
|
# SCRIPT VERSION
|
2023-10-02 20:39:00 -06:00
|
|
|
HWS_VER=4
|
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)
|
|
|
|
KNOWN_IMAGE_FLAVOR_FILE="/etc/bazzite/image_flavor"
|
|
|
|
KNOWN_IMAGE_FLAVOR=$(cat $KNOWN_IMAGE_FLAVOR_FILE)
|
|
|
|
|
2023-08-07 22:49:06 -07:00
|
|
|
# GLOBAL
|
|
|
|
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
|
2023-09-09 12:37:24 -06:00
|
|
|
GPU_ID=$(lspci -k | grep -A 3 -E "(VGA|3D)")
|
2023-08-07 22:49:06 -07:00
|
|
|
KARGS=$(rpm-ostree kargs)
|
|
|
|
NEEDED_KARGS=""
|
|
|
|
echo "Current kargs: $KARGS"
|
2023-09-06 13:44:45 -06:00
|
|
|
mkdir -p /etc/bazzite
|
2023-08-07 22:49:06 -07:00
|
|
|
|
2023-10-01 11:47:05 -07:00
|
|
|
# KERNEL ARGUMENTS
|
2023-08-08 10:09:30 -07:00
|
|
|
if [[ ":Jupiter:" =~ ":$SYS_ID:" ]]; then
|
|
|
|
echo "Checking for needed karg changes (Jupiter)"
|
2023-08-07 22:49:06 -07:00
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "amd_pstate" ]]; then
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=amd_pstate=active"
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "amd_iommu" ]]; then
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=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-08-09 20:07:17 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=amdgpu.gttsize=16256"
|
|
|
|
else
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=amdgpu.gttsize=8128"
|
|
|
|
fi
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "spi_amd.speed_dev" ]]; then
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=spi_amd.speed_dev=1"
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "initcall_blacklist" ]]; then
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=initcall_blacklist=simpledrm_platform_driver_init"
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
2023-10-02 18:49:45 -07:00
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "nowatchdog" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=nowatchdog"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "nmi_watchdog" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=nmi_watchdog=0"
|
|
|
|
fi
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
|
|
|
|
2023-09-09 12:37:24 -06:00
|
|
|
if grep -qz "Kernel driver in use: radeon" <<< $GPU_ID; then
|
2023-09-11 08:22:47 -07:00
|
|
|
echo "Legacy AMD hardware detected, enabling CIK and SI support in AMDGPU"
|
2023-09-09 11:27:58 -06:00
|
|
|
if [[ ! $KARGS =~ "radeon.si_support" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=radeon.si_support=0"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "radeon.cik_support" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=radeon.cik_support=0"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "amdgpu.si_support" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=amdgpu.si_support=1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "amdgpu.cik_support" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=amdgpu.cik_support=1"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-09-06 16:06:02 -06:00
|
|
|
if [[ $IMAGE_FLAVOR = "nvidia" ]]; then
|
2023-08-08 10:09:30 -07:00
|
|
|
echo "Checking for needed karg changes (Nvidia)"
|
2023-08-07 22:49:06 -07:00
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "rd.driver.blacklist" ]]; then
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=rd.driver.blacklist=nouveau"
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "modprobe.blacklist" ]]; then
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=modprobe.blacklist=nouveau"
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! $KARGS =~ "nvidia-drm.modeset" ]]; then
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=nvidia-drm.modeset=1"
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
2023-09-23 09:16:49 -06:00
|
|
|
else
|
2023-09-06 15:31:20 -06:00
|
|
|
echo "Checking for needed karg changes"
|
|
|
|
|
|
|
|
if [[ $KARGS =~ "rd.driver.blacklist" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --delete=rd.driver.blacklist=nouveau"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $KARGS =~ "modprobe.blacklist" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --delete=modprobe.blacklist=nouveau"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $KARGS =~ "nvidia-drm.modeset" ]]; then
|
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --delete=nvidia-drm.modeset=1"
|
|
|
|
fi
|
2023-08-07 22:49:06 -07:00
|
|
|
fi
|
|
|
|
|
2023-08-08 10:09:30 -07:00
|
|
|
if [[ $KARGS =~ "nomodeset" ]]; then
|
|
|
|
echo "Removing nomodeset"
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --delete=nomodeset"
|
2023-08-08 10:09:30 -07:00
|
|
|
fi
|
|
|
|
|
2023-08-08 18:08:10 -07:00
|
|
|
if [[ ! $KARGS =~ "rd.luks.options" ]]; then
|
2023-08-08 18:56:50 -07:00
|
|
|
NEEDED_KARGS="$NEEDED_KARGS --append=rd.luks.options=discard"
|
2023-08-08 18:08:10 -07:00
|
|
|
fi
|
|
|
|
|
2023-08-26 23:59:30 -03:00
|
|
|
if [[ -n "$NEEDED_KARGS" ]]; then
|
2023-08-08 10:09:30 -07:00
|
|
|
echo "Found needed karg changes, applying the following: $NEEDED_KARGS"
|
2023-08-26 23:59:30 -03: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-01 11:47:05 -07:00
|
|
|
# RUN REMAINDER OF SCRIPT ONLY IF UPDATED
|
|
|
|
if [[ -f $HWS_VER_FILE && $HWS_VER = $HWS_VER_RAN ]]; then
|
|
|
|
if [[ -f $KNOWN_IMAGE_NAME_FILE && -f $KNOWN_IMAGE_FLAVOR_FILE ]]; then
|
|
|
|
# Run script if image has been rebased
|
|
|
|
if [[ $IMAGE_NAME = $KNOWN_IMAGE_NAME && $IMAGE_FLAVOR = $KNOWN_IMAGE_FLAVOR ]]; then
|
|
|
|
echo "Hardware setup has already run. Exiting..."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $IMAGE_NAME =~ "deck" ]]; then
|
|
|
|
if [[ ":Jupiter:" =~ ":$SYS_ID:" ]]; then
|
|
|
|
# Future updates to deck on jupiter here
|
|
|
|
else
|
|
|
|
echo "Generic device detected. Performing setup..."
|
|
|
|
|
2023-10-02 20:39:00 -06:00
|
|
|
systemctl enable --now handycon.service
|
2023-10-01 11:47:05 -07:00
|
|
|
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
|
|
|
|
systemctl --global disable --now sdgyrodsu.service
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# FSTAB CONFIGURATION
|
|
|
|
if [[ $(grep "compress=zstd" /etc/fstab) ]]; then
|
|
|
|
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
|
|
|
|
else
|
|
|
|
echo "No fstab param adjustments needed"
|
|
|
|
fi
|
|
|
|
|
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
|