Advertisement
s243a

loadNdiswrapperModule() - Network Wizard

Nov 29th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.00 KB | None | 0 0
  1. loadNdiswrapperModule ()
  2. {
  3.     #  Dougal: ask the user if there's an interface for the HW, so we know
  4.     #+ to remove the driver for it.
  5.     askWhichInterfaceForNdiswrapper || return
  6.     showNdiswrapperGUI
  7.     [ $? -eq 0 ] || return
  8.     ndiswrapper -m
  9.     #v4.00 bugfix...
  10.     NATIVEMOD=""
  11.     nwINTERFACE="$(grep '^alias .* ndiswrapper$' /etc/modprobe.conf | cut -f 2 -d ' ')"
  12.     #most likely 'wlan0'
  13.     #if this interface is already claimed by a native linux driver,
  14.     #then get rid of it...
  15.     ## Dougal: this isn't good: the interface name is not the problem, it's the HW!
  16.     ## Add a dialog at the top for it.
  17.     if [ -n "$nwINTERFACE" -a -e "/sys/class/net/$nwINTERFACE" ];then
  18.       NATIVEMOD="$(readlink /sys/class/net/${nwINTERFACE}/device/driver/module)"
  19.       NATIVEMOD=${NATIVEMOD##*/}
  20.       if [ "$NATIVEMOD" != "ndiswrapper" ];then
  21.         #note 'ndiswrapper -l' also returns the native linux module.
  22.         if iwconfig | grep "^${nwINTERFACE} " | grep 'IEEE' | grep -q 'ESSID' ;then
  23.           rmmod "$NATIVEMOD"
  24.           sleep 6
  25.           [ $INTERFACE_NUM -gt 0 ] && INTERFACE_NUM=$((INTERFACE_NUM-1))
  26.           #...needed later to determine that number of interfaces has changed with ndiswrapper.
  27.           #INTERFACES="$(ifconfig -a | grep -F 'Link encap:Ethernet' | cut -f1 -d' ' | tr '\n' ' ')"
  28.           getInterfaceList
  29.           #...also needed later.
  30.         fi
  31.       else
  32.         NATIVEMOD=""
  33.       fi
  34.     fi
  35.  
  36.     tryLoadModule "ndiswrapper"
  37.     ndRETVAL=$?
  38.  
  39.     #v4.00...
  40.     if [ $ndRETVAL -eq 0 ];then
  41.       #well let's be radical, blacklist the native driver...
  42.       if [ "$NATIVEMOD" != "" ];then
  43.         #if ! grep "^${NATIVEMOD}$" "$BLACKLIST_FILE" ;then
  44.         . /etc/rc.d/MODULESCONFIG
  45.         case $SKIPLIST in *" $NATIVEMOD "*|*" ${NATIVEMOD//_/-} "*) ;; *)
  46.           Xdialog --title "$L_TITLE_Puppy_Network_Wizard" --yesno \
  47. "$L_MESSAGE_Blacklist_Nativemod_p1 ${NATIVEMOD} $L_MESSAGE_Blacklist_Nativemod_p2" 0 0
  48.           if [ $? -eq 0 ] ; then
  49.             #echo "$NATIVEMOD" >> "$BLACKLIST_FILE"
  50.             blacklist_module "$NATIVEMOD"
  51.           fi
  52.           ;;
  53.         esac
  54.         #fi
  55.       fi
  56.     fi #if [ $ndRETVAL -eq 0 ];then
  57.     return $ndRETVAL
  58. } # end loadNdiswrapperModule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement