OSDN Git Service

init: avoid using init modprobe
[android-x86/bootable-newinstaller.git] / initrd / scripts / 0-auto-detect
1 #
2 # By Chih-Wei Huang <cwhuang@linux.org.tw>
3 # Last updated 2015/10/23
4 #
5 # License: GNU Public License
6 # We explicitely grant the right to use the scripts
7 # with Android-x86 project.
8 #
9
10 # An auto detect function provided by kinneko
11 auto_detect()
12 {
13         tmp=/tmp/dev2mod
14         echo 'dev2mod() { while read dev; do case $dev in' > $tmp
15         sort -r /lib/modules/`uname -r`/modules.alias | \
16                 sed -n 's/^alias  *\([^ ]*\)  *\(.*\)/\1)busybox modprobe \2;;/p' >> $tmp
17         echo 'esac; done; }' >> $tmp
18         source $tmp
19         cat /sys/bus/*/devices/*/modalias | dev2mod
20         cat /sys/devices/virtual/wmi/*/modalias | dev2mod
21 }
22
23 find_network_dev_name()
24 {
25         INITRC=init.x86.rc
26         DHCPCD="/system/bin/dhcpcd -o domain_name_servers"
27         rmline=`grep -n "#REMOVE FROM HERE" $INITRC | cut -d':' -f1`
28         rmline=`expr $rmline + 1`
29         sed -i -e "$rmline,\$d" $INITRC
30         for netdev in `ls /sys/class/net`; do
31                 case "$netdev" in
32                         lo|ip6tnl*|sit*|tun*|eth0|wlan0|wmaster*)
33                                 ;;
34                         *)
35                                 echo -e "\nservice dhcpcd_$netdev $DHCPCD -ABDKL\n    class main\n    disabled\n    oneshot\n" >> $INITRC
36                                 echo -e "service iprenew_$netdev $DHCPCD -n\n    class main\n    disabled\n    oneshot" >> $INITRC
37                                 ;;
38                 esac
39         done
40 }
41
42 load_modules()
43 {
44         if [ -z "$FOUND" ]; then
45                 auto_detect
46         fi
47
48         # 3G modules
49         for m in $EXTMOD; do
50                 busybox modprobe $m
51         done
52 }