#! /bin/sh #---------------------------------------------------------------------------- # /etc/init.d/eth - configuration of your ethernet card # # Creation: 2001-10-15 fm # Last Update: $Id$ # # Copyright (c) 2001-2013 the eisfair team, team(at)eisfair(dot)org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- script='eth:' . /etc/init.d/functions . /etc/config.d/base if [ "$ETH_DO_DEBUG" = yes ] then set -x fi # --------------------------------------------------------------------------- # show mapping message only on start # --------------------------------------------------------------------------- show_mapping_msg () { _job=${1} _drv_old=${2} _drv=${3} case ${_job} in start) echo " Mapping ethernet driver ${_drv_old} to ${_drv} ..." ;; esac } # --------------------------------------------------------------------------- # drv mapping # --------------------------------------------------------------------------- drv_mapping () { _job=${1} case ${drv} in eepro100) # comes from 2.4.35-wt1 _old_drv_=${drv} drv=e100 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; "e1000old"|"intel-gige") # e1000old comes from 2.4.35-wt1, intel-gige comes from 2.4.26 _old_drv_=${drv} drv=e1000 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; r1000) # comes from 2.4.35-wt1 _old_drv_=${drv} drv=r8169 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; "r8101"|"r8168") # comes from 2.4.35-wt1 # only map to r8169 for kernel versions before 2.4.0 because r8101 and r8168 from # realtec are part of kernel 2.4.0 and supporting more chips than vanilla r8169 kerneldate=`uname -v | awk '{print $(NF-5), $(NF-4), $(NF-3), $(NF-2), $(NF-1), $NF}'` if [ "`date -d "$kerneldate" +%s`" -lt 1371406939 ] then _old_drv_=${drv} drv=r8169 show_mapping_msg ${_job} ${_old_drv_} ${drv} fi ;; velocityget) # comes from 2.4.35-wt1 _old_drv_=${drv} drv=via-velocity show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; "rtl8139"|"rtl8139-orig") # comes from 2.4.26 _old_drv_=${drv} drv=8139too show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; ns820) # comes from 2.4.26 _old_drv_=${drv} drv=ns83820 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; myson803) # comes from 2.4.26 _old_drv_=${drv} drv=fealnx show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; sk98lin) # comes from 2.4.35-wt1 _old_drv_=${drv} # 2 different drivers replacing sk98lin: skge and sky2 # in case of 2 cards: the last driver wins :( # there are more cards for sky2, let this driver win in case of 2 cards # kernel26test # modinfo sky2 | grep alias | wc -l # 39 # kernel26test # modinfo skge | grep alias | wc -l # 11 lspciout="`lspci -nnk | grep 'Ethernet controller' -A3 | grep 'Kernel modules' | cut -d: -f2`" for driver in skge sky2 do if [ -n "`echo "$lspciout" | grep "$driver"`" ] then drv="$driver" fi done show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; esac } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- case $1 in start) boot_mesg " * Loading ethernet drivers ..." idx=1 while [ "$idx" -le "$ETH_DRV_N" ] do eval drv='$ETH_DRV_'$idx eval opt='$ETH_DRV_'$idx'_OPTION' case $drv in *_cs) echo " Ethernet driver $drv should be loaded by pcmcia cardmgr in a few seconds ..." ;; *) drv_mapping "start" modprobe $drv $opt rtc=$? if [ $rtc != 0 -a "$opt" != "" ] then echo " Loading of ethernet driver $drv failed, trying again without options ..." modprobe $drv # some drivers (e.g. ne.o) don't want options anymore rtc=$? fi if [ $rtc != 0 ] then echo $script" Ethernet driver $drv $opt failed!" >>/bootmsg.txt fi ;; esac idx=`/usr/bin/expr $idx + 1` done evaluate_retval ;; stop) boot_mesg " * Unloading ethernet drivers ..." idx=1 while [ "$idx" -le "$ETH_DRV_N" ] do eval drv='$ETH_DRV_'$idx case $drv in *_cs) : ;; *) drv_mapping case $drv in "e100"|"e1000"|"e1000e"|"skge") # modules must keep loaded for wol echo " Don't unloading ethernet driver $drv for wake on lan ..." ;; *) rmmod $drv 2>/dev/null ;; esac ;; esac idx=`/usr/bin/expr $idx + 1` done evaluate_retval ;; esac set +x