supersonic3974 (OP)
Member
Offline
Activity: 70
Merit: 10
|
|
July 09, 2011, 10:05:24 PM |
|
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
|
|
July 09, 2011, 10:35:55 PM |
|
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!
|
|
|
|
supersonic3974 (OP)
Member
Offline
Activity: 70
Merit: 10
|
|
July 09, 2011, 11:02:48 PM |
|
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.
|
|
|
|
|
supersonic3974 (OP)
Member
Offline
Activity: 70
Merit: 10
|
|
July 10, 2011, 12:02:03 AM |
|
Haha, that might work but I'm also looking for a very inexpensive solution.
|
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
July 10, 2011, 06:15:56 AM |
|
I sent him this script and it seems to be doing the job: #!/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 /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
Activity: 51
Merit: 0
|
|
July 11, 2011, 06:21:22 AM |
|
wow, nice script. I wouldve helped with something like that if i had the skills. but i dont.
|
|
|
|
imperi
|
|
July 11, 2011, 06:25:06 AM |
|
That's a great script. Thanks for sharing.
|
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
July 11, 2011, 07:10:25 AM |
|
That's a great script. Thanks for sharing.
You're welcome.
|
Just-Dice | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | Play or Invest | ██ ██████████ ██████████████████ ██████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████████████ ██████████████████████ ██████████████ ██████ | 1% House Edge |
|
|
|
bitplane
|
|
July 11, 2011, 09:49:51 AM |
|
Excuse my ignorance, but does "sudo" work from within a script like that?
|
|
|
|
supersonic3974 (OP)
Member
Offline
Activity: 70
Merit: 10
|
|
July 11, 2011, 01:58:16 PM |
|
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
|
|
July 11, 2011, 02:16:58 PM |
|
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
Activity: 41
Merit: 0
|
|
July 11, 2011, 03:06:59 PM |
|
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
Activity: 70
Merit: 10
|
|
July 11, 2011, 03:11:04 PM |
|
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
|
|
July 11, 2011, 04:33:48 PM |
|
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.
|
|
|
|
dooglus
Legendary
Offline
Activity: 2940
Merit: 1333
|
|
July 11, 2011, 05:25:15 PM |
|
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
Activity: 2940
Merit: 1333
|
|
July 11, 2011, 05:26:44 PM |
|
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
Activity: 2940
Merit: 1333
|
|
July 11, 2011, 05:39:20 PM |
|
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. #!/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
Activity: 70
Merit: 10
|
|
July 11, 2011, 06:21:03 PM |
|
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? 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
|
|
July 11, 2011, 08:29:45 PM |
|
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? I'm not sure which prog language the bash script uses. To do arithmetic in Bash (that's the language ) you need something like
|
|
|
|
|