forked from koen01/android_device_google_sunfish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.insmod.sh
53 lines (46 loc) · 1.37 KB
/
init.insmod.sh
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
#!/vendor/bin/sh
#############################################################
### init.insmod.cfg format: ###
### ----------------------------------------------------- ###
### [insmod|setprop|enable/moprobe|wait] [path|prop name] ###
### ... ###
#############################################################
# imitates wait_for_file() in init
wait_for_file()
{
filename="${1}"
timeout="${2:-5}"
expiry=$(($(date "+%s")+timeout))
while [[ ! -e "${filename}" ]] && [[ "$(date "+%s")" -le "${expiry}" ]]
do
sleep 0.01
done
}
if [ $# -eq 1 ]; then
cfg_file=$1
else
exit 1
fi
if [ -f $cfg_file ]; then
while IFS="|" read -r action arg
do
case $action in
"insmod") insmod $arg ;;
"setprop") setprop $arg 1 ;;
"enable") echo 1 > $arg ;;
"modprobe")
case ${arg} in
"-b *" | "-b")
arg="-b $(cat /vendor/lib/modules/modules.load)" ;;
"*" | "")
arg="$(cat /vendor/lib/modules/modules.load)" ;;
esac
modprobe -a -d /vendor/lib/modules $arg ;;
"wait") wait_for_file $arg ;;
esac
done < $cfg_file
fi
# set property even if there is no insmod config
# as property value "1" is expected in early-boot trigger
setprop vendor.all.modules.ready 1
setprop vendor.all.devices.ready 1