Bitcoin Forum
November 14, 2024, 11:28:41 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Need help! Ubuntu 11.04 wireless problems  (Read 2385 times)
supersonic3974 (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
July 09, 2011, 10:05:24 PM
 #1

I recently setup a mining rig with 2 Sapphire Radeon 5850s.  I installed Ubuntu 11.04 and a TP-LINK TL-WN722N wireless adapter.  I can mine fine and I can get wireless fine.  The problem comes when theres a network interruption.  It just won't reconnect to the network for some reason.  I've tried looking through the Ubuntu forums, but I can't find anything that really helps.  It usually stops working when I'm away from the house, so I lose a lot of precious mining time.  When I get home all I have to do is open the list of networks and click the wireless network I use.  In the properties for the network, I have the "connect automatically" box checked, but it still doesn't work.

Any help would be greatly appreciated!
jondecker76
Full Member
***
Offline Offline

Activity: 238
Merit: 100


View Profile
July 09, 2011, 10:35:55 PM
 #2

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!

RollerBot Advanced Trading Platform
https://bitcointalk.org/index.php?topic=447727.0
BTC Donations for development: 1H36oTJsi3adFh68wwzz95tPP2xoAoTmhC
supersonic3974 (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
July 09, 2011, 11:02:48 PM
 #3

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.
legion050
Newbie
*
Offline Offline

Activity: 51
Merit: 0



View Profile
July 09, 2011, 11:53:40 PM
 #4

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.
supersonic3974 (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
July 10, 2011, 12:02:03 AM
 #5

Haha, that might work but I'm also looking for a very inexpensive solution.
dooglus
Legendary
*
Offline Offline

Activity: 2940
Merit: 1333



View Profile
July 10, 2011, 06:15:56 AM
 #6

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.

Just-Dice                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   Play or Invest                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   1% House Edge
legion050
Newbie
*
Offline Offline

Activity: 51
Merit: 0



View Profile
July 11, 2011, 06:21:22 AM
 #7

wow, nice script. I wouldve helped with something like that if i had the skills. but i dont.
imperi
Full Member
***
Offline Offline

Activity: 196
Merit: 101


View Profile
July 11, 2011, 06:25:06 AM
 #8

That's a great script. Thanks for sharing.
dooglus
Legendary
*
Offline Offline

Activity: 2940
Merit: 1333



View Profile
July 11, 2011, 07:10:25 AM
 #9

That's a great script. Thanks for sharing.

You're welcome.

Just-Dice                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   Play or Invest                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   1% House Edge
bitplane
Sr. Member
****
Offline Offline

Activity: 321
Merit: 250

Firstbits: 1gyzhw


View Profile WWW
July 11, 2011, 09:49:51 AM
 #10

Excuse my ignorance, but does "sudo" work from within a script like that?
supersonic3974 (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
July 11, 2011, 01:58:16 PM
 #11

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.
imperi
Full Member
***
Offline Offline

Activity: 196
Merit: 101


View Profile
July 11, 2011, 02:16:58 PM
 #12

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.
aeroSpike
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
July 11, 2011, 03:06:59 PM
 #13

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;-)
supersonic3974 (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
July 11, 2011, 03:11:04 PM
 #14

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*
teknohog
Sr. Member
****
Offline Offline

Activity: 520
Merit: 253


555


View Profile WWW
July 11, 2011, 04:33:48 PM
 #15

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.

world famous math art | masternodes are bad, mmmkay?
Every sha(sha(sha(sha()))), every ho-o-o-old, still shines
dooglus
Legendary
*
Offline Offline

Activity: 2940
Merit: 1333



View Profile
July 11, 2011, 05:25:15 PM
 #16

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.

Just-Dice                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   Play or Invest                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   1% House Edge
dooglus
Legendary
*
Offline Offline

Activity: 2940
Merit: 1333



View Profile
July 11, 2011, 05:26:44 PM
 #17

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.

Just-Dice                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   Play or Invest                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   1% House Edge
dooglus
Legendary
*
Offline Offline

Activity: 2940
Merit: 1333



View Profile
July 11, 2011, 05:39:20 PM
 #18

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

Just-Dice                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   Play or Invest                 ██             
          ██████████         
      ██████████████████     
  ██████████████████████████ 
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
██████████████████████████████
    ██████████████████████   
        ██████████████       
            ██████           
   1% House Edge
supersonic3974 (OP)
Member
**
Offline Offline

Activity: 70
Merit: 10


View Profile
July 11, 2011, 06:21:03 PM
 #19

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?
teknohog
Sr. Member
****
Offline Offline

Activity: 520
Merit: 253


555


View Profile WWW
July 11, 2011, 08:29:45 PM
 #20

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))

world famous math art | masternodes are bad, mmmkay?
Every sha(sha(sha(sha()))), every ho-o-o-old, still shines
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!