aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/pistachio/base-files/lib/pistachio.sh
blob: f9a16db3ed80504faa2572815cf7d153e3c3e37d (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
#!/bin/sh
#
# Copyright (C) 2017 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

PISTACHIO_BOARD_NAME=
PISTACHIO_MODEL=

pistachio_board_detect() {
	local machine
	local name

	machine=$(cat /proc/device-tree/model)

	case "$machine" in
	"IMG Marduk (Creator Ci40)")
		name="marduk"
		;;
	*)
		name="generic"
		;;
	esac

	[ -z "$PISTACHIO_BOARD_NAME" ] && PISTACHIO_BOARD_NAME="$name"
	[ -z "$PISTACHIO_MODEL" ] && PISTACHIO_MODEL="$machine"

	[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"

	echo "$PISTACHIO_BOARD_NAME" > /tmp/sysinfo/board_name
	echo "$PISTACHIO_MODEL" > /tmp/sysinfo/model
}

pistachio_board_name() {
	local name
	[ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
	[ -z "$name" ] && name="unknown"

	echo "$name"
}