|
| 1 | +#!/sbin/openrc-run |
| 2 | + |
| 3 | +description="Nitrux GPU and ISO compatibility check" |
| 4 | + |
| 5 | +depend() { |
| 6 | + before greetd-openrc |
| 7 | +} |
| 8 | + |
| 9 | +start() { |
| 10 | + iso_flavor="" |
| 11 | + if [ -f /etc/iso-release ]; then |
| 12 | + branch=$(grep -i '^ISO_BRANCH=' /etc/iso-release 2>/dev/null | head -n1 | cut -d= -f2) |
| 13 | + case "$branch" in |
| 14 | + nvopen|NVOPEN) |
| 15 | + iso_flavor="nvidia" |
| 16 | + ;; |
| 17 | + mesa|MESA) |
| 18 | + iso_flavor="mesa" |
| 19 | + ;; |
| 20 | + esac |
| 21 | + fi |
| 22 | + |
| 23 | + if [ -z "$iso_flavor" ]; then |
| 24 | + if ls /usr/src/nvidia-* >/dev/null 2>&1; then |
| 25 | + iso_flavor="nvidia" |
| 26 | + elif ls /usr/lib/x86_64-linux-gnu/libnvidia-tls.so.* >/dev/null 2>&1; then |
| 27 | + iso_flavor="nvidia" |
| 28 | + else |
| 29 | + iso_flavor="mesa" |
| 30 | + fi |
| 31 | + fi |
| 32 | + |
| 33 | + gpu_vendor="unknown" |
| 34 | + |
| 35 | + for dev in /sys/bus/pci/devices/*; do |
| 36 | + class=$(cat "$dev/class" 2>/dev/null) |
| 37 | + case "$class" in |
| 38 | + 0x030000|0x030200|0x0300*|0x0302*) |
| 39 | + vid=$(cat "$dev/vendor" 2>/dev/null) |
| 40 | + case "$vid" in |
| 41 | + 0x10de) |
| 42 | + gpu_vendor="nvidia" |
| 43 | + break |
| 44 | + ;; |
| 45 | + 0x8086) |
| 46 | + gpu_vendor="intel" |
| 47 | + ;; |
| 48 | + 0x1002) |
| 49 | + gpu_vendor="amd" |
| 50 | + ;; |
| 51 | + esac |
| 52 | + ;; |
| 53 | + esac |
| 54 | + done |
| 55 | + |
| 56 | + if [ "$iso_flavor" = "nvidia" ] && [ "$gpu_vendor" != "nvidia" ] && [ "$gpu_vendor" != "unknown" ]; then |
| 57 | + clear >/dev/console 2>&1 |
| 58 | + printf '%s\n' "=================================================================" >/dev/console |
| 59 | + printf '%s\n' "NITRUX RELEASE MISMATCH: NVIDIA ISO ON NON-NVIDIA GPU" >/dev/console |
| 60 | + printf '%s\n' "=================================================================" >/dev/console |
| 61 | + printf '%s\n' "This release is intended for systems with an NVIDIA GPU only." >/dev/console |
| 62 | + printf '%s\n' "Detected GPU vendor: $gpu_vendor" >/dev/console |
| 63 | + printf '%s\n' "Use 'nitrux-contemporary-liquorix-mesa' for Intel or AMD graphics." >/dev/console |
| 64 | + printf '%s\n' "The system will now halt." >/dev/console |
| 65 | + printf '%s\n' "=================================================================" >/dev/console |
| 66 | + sleep 10 |
| 67 | + reboot -f |
| 68 | + while :; do sleep 3600; done |
| 69 | + fi |
| 70 | + |
| 71 | + if [ "$iso_flavor" = "mesa" ] && [ "$gpu_vendor" = "nvidia" ]; then |
| 72 | + clear >/dev/console 2>&1 |
| 73 | + printf '%s\n' "=================================================================" >/dev/console |
| 74 | + printf '%s\n' "NITRUX RELEASE MISMATCH: MESA ISO ON NVIDIA GPU" >/dev/console |
| 75 | + printf '%s\n' "=================================================================" >/dev/console |
| 76 | + printf '%s\n' "This release is intended for Intel and AMD GPUs." >/dev/console |
| 77 | + printf '%s\n' "Detected GPU vendor: $gpu_vendor" >/dev/console |
| 78 | + printf '%s\n' "Use 'nitrux-contemporary-cachy-nvopen' for systems with an NVIDIA GPU." >/dev/console |
| 79 | + printf '%s\n' "The system will now halt." >/dev/console |
| 80 | + printf '%s\n' "=================================================================" >/dev/console |
| 81 | + sleep 10 |
| 82 | + reboot -f |
| 83 | + while :; do sleep 3600; done |
| 84 | + fi |
| 85 | + |
| 86 | + return 0 |
| 87 | +} |
0 commit comments