-
-
Notifications
You must be signed in to change notification settings - Fork 183
/
Copy pathublue-system-setup
executable file
·105 lines (85 loc) · 3.19 KB
/
ublue-system-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env bash
IMAGE_INFO="/usr/share/ublue-os/image-info.json"
IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO)
IMAGE_FLAVOR=$(jq -r '."image-flavor"' < $IMAGE_INFO)
# SCRIPT VERSION
HWS_VER=1
HWS_VER_FILE="/etc/ublue/hws_version"
HWS_VER_RAN=$(cat $HWS_VER_FILE)
# IMAGE IDENTIFIERS
KNOWN_IMAGE_NAME_FILE="/etc/ublue/image_name"
KNOWN_IMAGE_NAME=$(cat $KNOWN_IMAGE_NAME_FILE)
KNOWN_IMAGE_FLAVOR_FILE="/etc/ublue/image_flavor"
KNOWN_IMAGE_FLAVOR=$(cat $KNOWN_IMAGE_FLAVOR_FILE)
# GLOBAL
SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)"
GPU_ID=$(lspci -k | grep -A 3 -E "(VGA|3D)")
KARGS=$(rpm-ostree kargs)
NEEDED_KARGS=""
echo "Current kargs: $KARGS"
mkdir -p /etc/ublue
if grep -qz "Kernel driver in use: radeon" <<< $GPU_ID; then
echo "Legacy AMD hardware detected, enabling CIK and SI support in AMDGPU"
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
if [[ $IMAGE_FLAVOR = "nvidia" ]]; then
echo "Checking for needed karg changes (Nvidia)"
if [[ ! $KARGS =~ "rd.driver.blacklist" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=rd.driver.blacklist=nouveau"
fi
if [[ ! $KARGS =~ "modprobe.blacklist" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=modprobe.blacklist=nouveau"
fi
if [[ ! $KARGS =~ "nvidia-drm.modeset" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=nvidia-drm.modeset=1"
fi
else
echo "Checking for needed karg changes"
if [[ $KARGS =~ "rd.driver.blacklist=nouveau" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=rd.driver.blacklist=nouveau"
fi
if [[ $KARGS =~ "modprobe.blacklist=nouveau" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=modprobe.blacklist=nouveau"
fi
if [[ $KARGS =~ "nvidia-drm.modeset" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=nvidia-drm.modeset=1"
fi
fi
if [[ $KARGS =~ "nomodeset" ]]; then
echo "Removing nomodeset"
NEEDED_KARGS="$NEEDED_KARGS --delete-if-present=nomodeset"
fi
if [[ ! $KARGS =~ "rd.luks.options" ]]; then
NEEDED_KARGS="$NEEDED_KARGS --append=rd.luks.options=discard"
fi
if [[ -n "$NEEDED_KARGS" ]]; then
echo "Found needed karg changes, applying the following: $NEEDED_KARGS"
plymouth display-message --text="Updating kargs - Please wait, this may take a while" || true
rpm-ostree kargs ${NEEDED_KARGS} --reboot || exit 1
else
echo "No karg changes needed"
fi
# Run script 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
echo $HWS_VER > $HWS_VER_FILE
echo $IMAGE_NAME > $KNOWN_IMAGE_NAME_FILE
echo $IMAGE_FLAVOR > $KNOWN_IMAGE_FLAVOR_FILE