Pages:
Author

Topic: Need help! Ubuntu 11.04 wireless problems (Read 2388 times)

legendary
Activity: 2940
Merit: 1333
July 11, 2011, 04:02:04 PM
#21
Thank you so much for the updated code.  I'll have to try it out when I get home.

Just curious, would this work in the code?

Code:
ping_pause=5*60

I'm not sure which prog language the bash script uses.

Also, would it be possible to have the bounce prog create a log of the time and date for each time there is a failed ping attempt?

Yean, $((5*60)) to do maths, not just 5*60

And in .xprofile:

Code:
/path/to/script >> ~/bounce-log.txt &

will make it append to the end of bounce-log.txt while it's running.

You'll see all the successful pings in there too, so comment that line out if you don't want them.
sr. member
Activity: 520
Merit: 253
555
Thank you so much for the updated code.  I'll have to try it out when I get home.

Just curious, would this work in the code?

Code:
ping_pause=5*60

I'm not sure which prog language the bash script uses.

To do arithmetic in Bash (that's the language Cheesy) you need something like
Code:
ping_pause=$((5*60))
member
Activity: 70
Merit: 10
Thank you so much for the updated code.  I'll have to try it out when I get home.

Just curious, would this work in the code?

Code:
ping_pause=5*60

I'm not sure which prog language the bash script uses.

Also, would it be possible to have the bounce prog create a log of the time and date for each time there is a failed ping attempt?
legendary
Activity: 2940
Merit: 1333
For some reason it won't work right when it's set as a startup program.  I think it has to do with the fact that the bounce program starts before the network manager connects to the router.  It also does not work right if you start the bounce program while its not connected to the network.  So I commented out the .xprofile file and manually started bounce after the network connected and my miner has been working ever since!  I also adjusted the ping rate to every 5 min.

Right.  I'll update it so that it waits for you to get connected before it starts pinging.

Here's an updated copy.  You should be able to run this from your .xprofile - it doesn't give up if the network is down when you first run it.

Code:
#!/bin/bash

########################################################################
#
#   we need to be able to restart the network-manager to reconnect
#   automatically.  this usually requires us to type our password, but
#   since we want to be able to run this unattended, we need to tell
#   sudo that we can restart network-manager without typing our password
#   to set that up, run these two commands in a terminal while logged in
#   as your regular user:
#
#     echo "$(whoami) ALL=(ALL) NOPASSWD: /etc/init.d/network-manager" | sudo tee /etc/sudoers.d/network-manager
#     sudo chmod 0440 /etc/sudoers.d/network-manager
#   
########################################################################

ping_pause=10                   # how long, in seconds, to wait between ping attempts
restart_pause=60                # how long, in seconds, to wait after restarting networking

########################################################################

log() {
    echo "$(date) $@"
}

restart-network() {
    log "restarting networking"
    sudo /etc/init.d/network-manager restart > /dev/null
    # give it a minute to reconnect before we start checking again
    log "waiting $restart_pause seconds"
    sleep $restart_pause
}
   
# find the address of our router
log "finding router address"
while true
do
    router=$(route | grep ^default | awk '{print $2}')

    if [[ -z $router ]]
    then
        log "can't determine router"
        restart-network
    else
        break
    fi
done
log "router address '$router'"

# ping it repeatedly
while true
do
    log "pinging router '$router'"
    if ! ping -c 1 $router > /dev/null
    then
        log "ping failed"
        restart-network
    fi
    sleep $ping_pause
done
legendary
Activity: 2940
Merit: 1333
For some reason it won't work right when it's set as a startup program.  I think it has to do with the fact that the bounce program starts before the network manager connects to the router.  It also does not work right if you start the bounce program while its not connected to the network.  So I commented out the .xprofile file and manually started bounce after the network connected and my miner has been working ever since!  I also adjusted the ping rate to every 5 min.

Right.  I'll update it so that it waits for you to get connected before it starts pinging.
legendary
Activity: 2940
Merit: 1333
Excuse my ignorance, but does "sudo" work from within a script like that?

Read the comment at the top of the script.  There are two command lines embedded within the comment which you need to run once.  Once you've run then, the 'sudo' line will work from within an unattended script.
sr. member
Activity: 520
Merit: 253
555
I'd like to use a wired connection.  The only problem is that the only wired connection is on the other side of the house from my room and my parents are using it for their computer.

In that case, you need a switch so you get many connections out of that one. Then find a long enough cable.

You should never rely on wireless connections for things that need to be "always on". There are many more things to go wrong, compared to wired, though I believe that script helps to some extent. I have tried to go wireless with a miner (and similar things before Bitcoin), but in the end you need to go wired for anything serious. WLAN is designed for intermittent usage, like checking your mail in a cafe, not serious server-type uses.

As for the noise issue, there are ways to make a completely silent rig, in this case about 818 Mhash/s. Heat is still a problem during the summer, though.
member
Activity: 70
Merit: 10
I had it down there for a while and they started complaining "The fans are too loud...", "It's heating up the room...", "We keep tripping over that power cord that is suspended across the room..."  *sigh*
newbie
Activity: 41
Merit: 0
The only problem is that the only wired connection is on the other side of the house from my room and my parents are using it for their computer.
Explain to your parents that mining is much more important than whatever they are doing;-)
full member
Activity: 196
Merit: 101
Excuse my ignorance, but does "sudo" work from within a script like that?

You run the script in the first place using sudo. That way it doesn't need to enter a password to use it, since it is logged in as root.
member
Activity: 70
Merit: 10
Thank you so much for your help dooglus!  I had to play around with it for a few days, but now it works perfectly.  For some reason it won't work right when it's set as a startup program.  I think it has to do with the fact that the bounce program starts before the network manager connects to the router.  It also does not work right if you start the bounce program while its not connected to the network.  So I commented out the .xprofile file and manually started bounce after the network connected and my miner has been working ever since!  I also adjusted the ping rate to every 5 min.

Btw, I'll be sending you that donation when I get home from work today.
sr. member
Activity: 321
Merit: 250
Firstbits: 1gyzhw
Excuse my ignorance, but does "sudo" work from within a script like that?
legendary
Activity: 2940
Merit: 1333
That's a great script. Thanks for sharing.

You're welcome.
full member
Activity: 196
Merit: 101
That's a great script. Thanks for sharing.
newbie
Activity: 51
Merit: 0
wow, nice script. I wouldve helped with something like that if i had the skills. but i dont.
legendary
Activity: 2940
Merit: 1333
I sent him this script and it seems to be doing the job:

Code:
#!/bin/bash

########################################################################
#
#   we need to be able to restart the network-manager to reconnect
#   automatically.  this usually requires us to type our password, but
#   since we want to be able to run this unattended, we need to tell
#   sudo that we can restart network-manager without typing our password
#   to set that up, run these two commands in a terminal while logged in
#   as your regular user:
#
#     echo "$(whoami) ALL=(ALL) NOPASSWD: /etc/init.d/network-manager" | sudo tee /etc/sudoers.d/network-manager
#     sudo chmod 0440 /etc/sudoers.d/network-manager
#   
########################################################################

# how long, in seconds, to wait between ping attempts
pause=10

########################################################################

# find the address of our router
router=$(route | grep ^default | awk '{print $2}')

if [[ -z $router ]]
then
    echo "can't determine router - is network down already?"
    exit 1
fi

while true
do
    echo "$(date) pinging router '$router'"
    if ! ping -c 1 $router > /dev/null
    then
echo "$(date) ping failed; restarting network-manager"
sudo /etc/init.d/network-manager restart

        # give it a minute to reconnect before we start checking again
sleep 60
    fi
    sleep $pause
done

The two commands mentioned in comments at the top of the script need to be run if you want to run the script as a regular user and have it be able to restart the network-manager without prompting for a password.

The script needs to be saved to a file, then set as executable ("chmod +x scriptname").

It can be run automatically on login by putting

Code:
/path/to/script/scriptname &

in .xprofile in your home directory, which probably doesn't exist.  Just make it.

In my case, that's "/home/chris/bounce &", but call it what you like and put it where you like.
member
Activity: 70
Merit: 10
Haha, that might work but I'm also looking for a very inexpensive solution.
newbie
Activity: 51
Merit: 0
easiest thing to do is a bridge.

http://www.dlink.com/products/?pid=663

it will be seen as just a Wired LAN to the computer.
member
Activity: 70
Merit: 10
I'm just a beginner with linux so I wouldn't know where to start with the bash script.

I'd like to use a wired connection.  The only problem is that the only wired connection is on the other side of the house from my room and my parents are using it for their computer.
full member
Activity: 238
Merit: 100
You can write a simple bash script that attempts to ping something on the local network every 10 seconds or so, and if it fails, run an /etc/init.d/networking restart or something similar.

I too had a lot of issues with wireless and eventually just went with a wired connection.  It was well worth the effort to switch over!
Pages:
Jump to: