Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Automatically restart Logmein Hamachi Internet
If you are having trouble with Logmein Hamachi starting up correctly, the following script will check to see if the connection is up. If it is, it will attempt to restart and then send you an email when it's done.

You'll need to update these variables with your own data:
email_address='XXXXXXX@gmail.com'

hamachi_network="xxx-xxx-xxx"
Also update the machine names and IP address (e.g. test_ip_address) in the case statement.

You can use the command hamachi list (from a Terminal window) to get your network ID and IP addresses.

Once you set this up, you can run this from any of your connected machines and it will try to connect to the other machine. If it cannot, it attempts to get Hamachi working again.

Here's the script:
#!/bin/bash
# Script to restart the Hamachi connection if it is not working
#
# user command "hamachi list" to find the hamachi network you are connecting to
#
 
email_address='XXXXXXX@gmail.com'
hamachi_network="xxx-xxx-xxx"
public_ip_address='google.com'
 
#
 
machine_name=`uname -n`
case $machine_name in
 
        Mac1.local)  test_ip_address="25.xxx.xxx.xxx"
                        test_machine="Mac1"
                        ;;
 
        Mac2.local) test_ip_address="25.xxx.xx.xx"
                        test_machine="Mac2"            
                        ;;      
        *) echo "You are using an unknown machine, named [$machine_name]. Exiting"
           exit
        ;;
esac
 
echo "Checking Logmein Hamachi network connectivity..."
echo "You are using [$machine_name]. Checking IP Address [$test_ip_address] on [$test_machine]"
IS=`/sbin/ping -c 5 $public_ip_address 2> /dev/null | grep -c "64 bytes"`
if (test "$IS" -eq  "0") then
   echo "Your internet connection does not appear to be working. Aborting check"
   exit
fi
 
IS=`/sbin/ping -c 5 $test_ip_address 2> /dev/null | grep -c "64 bytes"`
if (test "$IS" -gt "2") then
   echo "Your Logmein Hamachi connection appears to be working."
   exit
else
   echo "There appears to be a problem with your Logmein Hamachi connection."
   echo "I will check again in 10 seconds..."
   sleep 10
   IS=`/sbin/ping -c 5 $test_ip_address 2> /dev/null | grep -c "64 bytes"`
   if (test "$IS" -gt "2") then
       echo "Your Logmein Hamachi connection appears to be working now."
       exit
   else
       echo "There is still a problem with your Logmein Hamachi connection. Attempting to fix by restarting Logmein Hamachi..."
       hamachi logout
       sleep 10
       hamachi login
       sleep 10
       hamachi go-offline $hamachi_network
       sleep 10
       hamachi go-online $hamachi_network
       echo "OK, we should be back up!"
       echo "Your Logmein Hamachi connection on $machine_name needed to be cycled on/off.
 
Could not connect to [$test_ip_address].
 
It may also mean that $test_machine is down." | mail -s "Hamachi Connection Down on $(date '+%m/%d/%y @ %H:%M:%S')" $email_address -f ipdown@no-reply.com -F "Hamachi Connection Problem on $machine_name"
   fi
fi

[crarko adds: I haven't tested this one.]
    •    
  • Currently 1.20 / 5
  You rated: 2 / 5 (10 votes cast)
 
[11,999 views]  

Automatically restart Logmein Hamachi | 1 comments | Create New Account
Click here to return to the 'Automatically restart Logmein Hamachi' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically restart Logmein Hamachi
Authored by: earthsaver on Jun 27, '14 12:00:52PM

I don't need to ensure that two computers are always connected to each other across Hamachi, however I do need to ensure that one server always has an active Hamachi network connection so that others can connect to it.

Can you offer a modified script I can set to run periodically to check Hamachi's connection status and reset it if necessary?

---
- Ben Rosenthal
MacBook Pro 2.8GHz | Mavericks
iPad 3 4G | iOS 7
iPhone 5 | iOS 7



[ Reply to This | # ]