summaryrefstree
path: root/vendor/bin/init.insmod.sh
blob: 267f7bb918e5ea1808ce5207c239f3e4efbba42e (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
#!/vendor/bin/sh
# SPDX-FileCopyrightText: 2016-2023 Unisoc (Shanghai) Technologies Co., Ltd
# SPDX-License-Identifier: LicenseRef-Unisoc-General-1.0

if [ $# -eq 1 ]; then
	cfg_file=$1
elif [ $# -eq 2 ]; then
	cfg_file=$1
	if [[ $2 == "cali" || $2 == "charger" ]]; then
		bootmode=".$2"
	else
		bootmode=
	fi
else
	# Set property even if there is no insmod config
	# to unblock early-boot trigger
	setprop vendor.all.modules.ready 1
	exit 1
fi

if [ -f $cfg_file ]; then
	while IFS="|" read -r action arg
	do
		args=`echo $arg | sed 's/|/ /g'`
		case $action in
			"insmod") insmod $args ;;
			"setprop") setprop $arg 1 ;;
			"enable") echo 1 > $arg ;;
			"modprobe")
				case $(arg) in
					"-b *" | "-b")
						arg="-b $(cat /vendor/lib/modules/modules.load$bootmode)" ;;
					 "*"|"")
						arg="$(cat /vendor/lib/modules/modules.load$bootmode)" ;;
				esac
				modprobe -s -a -d /vendor/lib/modules $arg ;;
			"modprobe_gki_modules")
				case $(arg) in
					 "*"|"")
						arg="$(cat /system/lib/modules/modules.load)" ;;
				esac
				modprobe -s -a -d /system/lib/modules $arg ;;
		esac
	done < $cfg_file
fi