summaryrefslogtreecommitdiff
path: root/scripts/kvmd-udev-hdmiusb-check
blob: ada4ceabe097ab3fa7e6ce0103cda86c8cf67e7d (plain)
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
#!/bin/bash
# ========================================================================== #
#                                                                            #
#    KVMD - The main Pi-KVM daemon.                                          #
#                                                                            #
#    Copyright (C) 2018-2021  Maxim Devaev <[email protected]>               #
#                                                                            #
#    This program is free software: you can redistribute it and/or modify    #
#    it under the terms of the GNU General Public License as published by    #
#    the Free Software Foundation, either version 3 of the License, or       #
#    (at your option) any later version.                                     #
#                                                                            #
#    This program is distributed in the hope that it will be useful,         #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of          #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           #
#    GNU General Public License for more details.                            #
#                                                                            #
#    You should have received a copy of the GNU General Public License       #
#    along with this program.  If not, see <https://www.gnu.org/licenses/>.  #
#                                                                            #
# ========================================================================== #


set -x

# udevadm info -a -p $(udevadm info -q path -n /dev/video0)

board="$1"
port="$2"

# В новом systemd поломали %b в правилах udev
[ -n "$port" ] || exit 0

# https://gist.github.com/mdevaev/6eb65be689142e5ac16da7542f50830f
model="`tr < /proc/device-tree/model -d '\000'`"

case "$board" in
	"rpi2")
		case "$model" in
			"Raspberry Pi 2 Model B Rev 1.1")
				if [ "$port" == "1-1.5:1.0" ]; then exit 0; else exit 1; fi;;
			*) exit 0;;
		esac;;
	"rpi3")
		case "$model" in
			"Raspberry Pi 3 Model B Rev 1.2")
				if [ "$port" == "1-1.5:1.0" ]; then exit 0; else exit 1; fi;;
			"Raspberry Pi 3 Model B Plus Rev 1.3")
				if [ "$port" == "1-1.2:1.0" ]; then exit 0; else exit 1; fi;;
			*) exit 0;;
		esac;;
	"rpi4")
		case "$model" in
			"Raspberry Pi 4 Model B Rev 1.1" | "Raspberry Pi 4 Model B Rev 1.2" | "Raspberry Pi 4 Model B Rev 1.4")
				if [ "$port" == "1-1.4:1.0" ]; then exit 0; else exit 1; fi;;
			*) exit 0;;
		esac;;
	*) exit 1;;
esac