OSDN Git Service

0-auto-detect: correct dhcpcd options
[android-x86/bootable-newinstaller.git] / initrd / scripts / 0-auto-detect
1 #
2 # By Chih-Wei Huang <cwhuang@linux.org.tw>
3 # Last updated 2009/12/10
4 #
5 # License: GNU Public License
6 # We explicitely grant the right to use the scripts
7 # with Android-x86 project.
8 #
9
10 error()
11 {
12         echo $*
13         return 1
14 }
15
16 # An auto detect function provided by kinneko
17 auto_detect()
18 {
19         tmp=/tmp/dev2mod
20         echo 'dev2mod() { while read dev; do case $dev in' > $tmp
21         sort -r /lib/modules/`uname -r`/modules.alias | \
22                 sed -n 's/^alias  *\([^ ]*\)  *\(.*\)/\1)modprobe \2;;/p' >> $tmp
23         echo 'esac; done; }' >> $tmp
24         source $tmp
25         cat /sys/bus/*/devices/*/modalias | dev2mod
26 }
27
28 find_network_dev_name()
29 {
30         wififound=0
31         rmline=`grep -n "#REMOVE FROM HERE" init.rc|cut -d':' -f1`
32         rmline=`expr $rmline + 1`
33         sed -i -e "$rmline,\$d" init.rc
34         dhcpcdopts="-o domain_name_servers -BKL"
35         for netdev in `ls /sys/class/net`; do
36                 if [ $netdev = "lo" -o $netdev = "wmaster0" ]; then
37                         continue
38                 fi              
39                 w=/sys/class/net/$netdev
40                 if [ -d $w/wireless -o -d $w/phy80211 ]; then
41                         if [ $wififound -eq 0 ]; then
42                                 sed -i "s|\(^ *service wpa_supplicant .*\)\(-i.*\)\( -c.*$\)|\1-i $netdev\3|g" init.rc
43                                 wififound=1
44                         fi
45                 fi
46                 echo "service dhcpcd$netdev /system/bin/dhcpcd $dhcpcdopts $netdev" >> init.rc
47                 echo -e "   group system dhcp\n   disabled\n   oneshot\n" >> init.rc
48         done
49 }
50
51 load_modules()
52 {
53         if [ -n "$FOUND" ]; then
54                 BTDEV="bnep rfcomm sco btusb"
55                 for m in $PREDEV $EXTMOD $BTDEV; do
56                         modprobe $m
57                 done
58                 [ -n "$FB0DEV" -a -z "$UVESA_MODE" ] && modprobe $FB0DEV
59                 [ -n "$LANDEV" ] && modprobe $LANDEV
60                 [ -n "$WIFDEV" ] && modprobe $WIFDEV
61                 [ -n "$SNDDEV" ] && modprobe $SNDDEV
62                 [ -n "$CAMDEV" ] && modprobe $CAMDEV
63         else
64                 auto_detect
65         fi
66
67         mdev -s
68         [ -c /dev/video0 ] || modprobe vivi
69         [ -d /proc/asound/card0 ] || modprobe snd-dummy
70         [ -c /dev/fb0 ] || modprobe uvesafb mode_option=${UVESA_MODE:-800x600}-16 ${UVESA_OPTION:-mtrr=3 scroll=redraw}
71         find_network_dev_name
72 #       find_wifi_dev_name
73 }