Hermann
Posts: 6
Joined: Fri May 11, 2012 7:02 pm

Re: Wi-Fi and keyboard problem

Wed Aug 15, 2012 12:40 am

I had the same problem. file /etc/init.d/disable-ethernet said something about ASCII with CRLF. After converting the file to "Unix style" (CR only) it worked.

kzkz wrote:Thanks for the solution, you saved my life! :)

But I have problem with the script, I get errors:

root@raspberrypi:/etc/init.d# service disable-ethernet stop
: not found/disable-ethernet: 2: /etc/init.d/disable-ethernet:
: not found/disable-ethernet: 19: /etc/init.d/disable-ethernet:
/etc/init.d/disable-ethernet: 20: .: Can't open /lib/lsb/init-functions

User avatar
Robpol86
Posts: 18
Joined: Wed Jul 18, 2012 7:29 pm
Location: San Francisco, CA
Contact: Website

Re: Wi-Fi and keyboard problem

Wed Aug 15, 2012 1:01 am

Yet that's what I suspected. Not sure how you fixed it but I would run "sudo apt-get install dos2unix" then "sudo dos2unix /etc/init.d/disable-ethernet".

Thanks for the input.

Hermann
Posts: 6
Joined: Fri May 11, 2012 7:02 pm

Re: Wi-Fi and keyboard problem

Wed Aug 15, 2012 1:13 am

I am using Notepad++ on my Windose machine which I can highly recommend. (Notepad++... not the other one ;) )
It has a feature to convert any text to CR only.

Thanks for the script! I'm still fighting to get my WUSB54GC dongle to work...
Robpol86 wrote:Yet that's what I suspected. Not sure how you fixed it but I would run "sudo apt-get install dos2unix" then "sudo dos2unix /etc/init.d/disable-ethernet".

Thanks for the input.

selectnone
Posts: 55
Joined: Fri Jun 22, 2012 10:16 pm

Re: Wi-Fi and keyboard problem

Tue Aug 21, 2012 11:19 pm

Robpol86 wrote:I wrote an init script so I can easily enable/disable the NIC:

To enable the script during boot, run: sudo insserv disable-ethernet
To disable the script from running during boot: sudo insserv -r disable-ethernet
To disable Ethernet and fix WiFi, run: sudo service disable-ethernet start
To re-enable Ethernet (be sure to remove the WiFi device before running), run: sudo service disable-ethernet stop

Here is the script. Save it in /etc/init.d/disable-ethernet and then run sudo chmod 755 /etc/init.d/disable-ethernet:

Code: Select all

#!/bin/bash
 
### BEGIN INIT INFO
# Provides:          disable-ethernet
# Required-Start:    $local_fs
# Required-Stop:     
# Default-Start:     S
# Default-Stop:      
# Short-Description: Disables on-board Ethernet to fix WiFi+Lapdock
# Description:       When using the Raspberry Pi Model B on the
#                    Motorola Atrix Lapdock, inserting certain WiFi
#                    adapters into either the RPi's spare USB port or
#                    the Lapdock's USB ports causes the on-board
#                    Ethernet and WiFi adapter to malfunction.
#                    Disabling the on-board Ethernet driver allows
#                    the WiFi adapter to work simultaneously with the
#                    Lapdock.
### END INIT INFO
 
. /lib/lsb/init-functions
 
DEVICE_DIR=/sys/bus/usb/drivers/smsc95xx
BUS_ID="1-1.1:1.0"
INT_TOGGLE=true #issue ifdown and ifup?
#INT_TOGGLE=false
 
is_enabled () {
    [ -L "$DEVICE_DIR/$BUS_ID" ] && return 0 || return 1
}
 
toggle_int () {
    is_enabled || return 0 #ethernet not enabled
    [ "$(ls -1 "$DEVICE_DIR/$BUS_ID/net" |wc -l)" -eq "1" ] || return 0 #something wrong
    $INT_TOGGLE || return 0 #user doesn't want this
    [ ! -f /run/network/ifstate ] && return 0 #run level S
    int_name=$(ls -1 "$DEVICE_DIR/$BUS_ID/net")
    if [ "$1" == "up" ]; then
        log_action_begin_msg "Bringing on-board interface up"
        ifup $int_name
    else
        log_action_begin_msg "Bringing on-board interface down"
        ifdown $int_name
    fi
    log_action_end_msg $?
}
 
case "$1" in
    start)
        if ! is_enabled; then
            log_failure_msg "Service already running. Exiting."
            exit 0
        fi
        toggle_int down
        log_action_begin_msg "Disabling on-board network interface"
        echo "$BUS_ID" > $DEVICE_DIR/unbind
        log_action_end_msg $?
        exit $?
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop)
        if is_enabled; then
            log_failure_msg "Service not running. Exiting."
            exit 0
        fi
        log_action_begin_msg "Enabling on-board network interface"
        echo "$BUS_ID" > $DEVICE_DIR/bind
        log_action_end_msg $?
        toggle_int up
        exit $?
        ;;
    status)
        if is_enabled; then
            echo "Service is NOT running: on-board interface enabled" >&2
            exit 1
        else
            echo "Service is running: on-board interface disabled"
            exit 0
        fi
        ;;
    *)
        echo "Usage: $0 start|stop|status" >&2
        exit 3
        ;;
esac
It worked, thanks very much!

(my adapter broke a while ago, I've only just got it up and running again...)

Return to “Troubleshooting”