#! /bin/sh #---------------------------------------------------------------------------- # /etc/init.d/eth - configuration of your ethernet card # # Creation: 2001-10-15 fm # Last Update: $Id$ # # Copyright (c) 2001-2012 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 kernel_version=`uname -r` # --------------------------------------------------------------------------- # 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 "${kernel_version}" in 2.4.26*) case ${drv} in rtl8139-orig) _old_drv_=${drv} drv=8139too show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; via-rhine) _old_drv_=${drv} drv=rhinefet show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; # fm: via-rhine crashes kernel esac ;; 2.4.35*) case ${drv} in "rtl8139"|"rtl8139-orig") _old_drv_=${drv} drv=8139too show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; ns820) _old_drv_=${drv} drv=ns83820 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; intel-gige) _old_drv_=${drv} drv=e1000 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; myson803) _old_drv_=${drv} drv=fealnx show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; esac ;; 2.6.32-*) case ${drv} in eepro100) _old_drv_=${drv} drv=e100 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; e1000old) _old_drv_=${drv} drv=e1000 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; "r1000"|"r8101"|"r8168") _old_drv_=${drv} drv=r8169 show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; velocityget) _old_drv_=${drv} drv=via-velocity show_mapping_msg ${_job} ${_old_drv_} ${drv} ;; esac ;; esac } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- case $1 in start) boot_mesg " * Loading ethernet drivers ..." idx=1 case "$kernel_version" in 2.2.*) insmod 8390 2>/dev/null insmod pci-scan 2>/dev/null ;; esac 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 ..." ;; *) case "$kernel_version" in 2.2.*) insmod $drv $opt rtc=$? ;; *) 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 ;; esac 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) : ;; *) case "$kernel_version" in 2.2.*) rmmod $drv ;; 2.4.35-wt*) drv_mapping case $drv in "e1000"|"e1000e") # only unload old modules, new modules must keep loaded for wol kerneldate=`uname -v | awk '{print $(NF-5), $(NF-4), $(NF-3), $(NF-2), $(NF-1), $NF}'` if [ "`date -d "$kerneldate" +%s`" -lt 1250388457 ] then rmmod $drv 2>/dev/null else echo "Don't unloading ethernet driver $drv for wake on lan ..." fi ;; *) rmmod $drv 2>/dev/null ;; esac ;; 2.6.32-*) drv_mapping case $drv in "e100"|"e1000"|"e1000e") # modules must keep loaded for wol echo "Don't unloading ethernet driver $drv for wake on lan ..." ;; *) rmmod $drv 2>/dev/null ;; esac ;; *) drv_mapping rmmod $drv 2>/dev/null ;; esac ;; esac idx=`/usr/bin/expr $idx + 1` done case "$kernel_version" in 2.2.*) rmmod pci-scan 2>/dev/null rmmod 8390 2>/dev/null ;; esac evaluate_retval ;; esac set +x