Skip to main content

Automatic Start-up Hamachi for Ubuntu Hardy Heron


Previously, I have written about creating a start-up Hamachi service script for Ubuntu Feisty Fawn. This time, with a little modification to the script, I will illustrate how to create a similar start-up script for Ubuntu Hardy Heron.

Hamachi, a powerful VPN service that allows user to communicate securely from a remote network over an Internet connection, is also known as LogMeIn Hamachi, after taken over by another company. It is available in various operating systems; that is, Microsoft Windows, Linux and Mac OS X. However, automatic start-up is not the default option during installation. Here, I will illustrate how you can do so in Ubuntu Hardy Heron (which is also applicable to most other Linux distributions).

I assume that you are able to successfully install Hamachi as a user basis. If not, you can find out from the README instruction when you download the installation script.

(configure your automatic start-up script for Ubuntu...)

Follow the instruction below.
  1. Create the start-up script for hamachi, as shown below. Remember to change the user name "keith" (line 5) to your system user name in Ubuntu (or your Linux distribution).


    #!/bin/bash
    ###################################
    ### Start-up script for Hamachi ###
    ###################################
    USER=keith
    case "$1" in
    start)
    /sbin/tuncfg
    /bin/su - $USER -c "hamachi start"
    ;;
    stop)
    /bin/su - $USER -c "hamachi stop"
    ;;
    restart|force-reload)
    /bin/su - $USER -c "hamachi start"
    /bin/su - $USER -c "hamachi stop"
    ;;
    *)
    exit 1
    ;;
    esac

    exit 0

  2. Make the script executable:

    chmod +x hamachi

  3. Move the script to /etc/init.d/ directory:

    sudo mv hamachi /etc/init.d

  4. Finally, run the following command to automatically link the script to the appropriate run-level during system boot up:

    sudo update-rc.d hamachi defaults

    It will then build the link as shown below:

    Adding system startup for /etc/init.d/hamachi ...
    /etc/rc0.d/K20hamachi -> ../init.d/hamachi
    /etc/rc1.d/K20hamachi -> ../init.d/hamachi
    /etc/rc6.d/K20hamachi -> ../init.d/hamachi
    /etc/rc2.d/S20hamachi -> ../init.d/hamachi
    /etc/rc3.d/S20hamachi -> ../init.d/hamachi
    /etc/rc4.d/S20hamachi -> ../init.d/hamachi
    /etc/rc5.d/S20hamachi -> ../init.d/hamachi

  5. Finally, reboot your system and Hamachi will be automatically loaded and connected to the server.

Hamachi is one of the simplest way to link different networks across the Internet into one single Intranet. Many people made use of this for gaming and some several other purposes.

It is definitely very helpful if you are located far away from your server, and that someone could simply help you restart your server without needing to give administrative privilege to login to the server. Hamachi is then automatically loaded.

Special thank to an unknown guest who helped to improve the scripting.

Awesome

thanks a lot!

Nice

Thanks a lot, works like a charm!

not working

followed the directions on this page to the letter, but when i reboot, hamachi does not start. when i run 'sudo /etc/init.d/hamachi start' it return this error:

tuncfg: already running
Cannot access lock file /home/josh/.hamachi//.lock

simpler solution?

Hi, why not simply a

/sbin/tuncfg
/usr/bin/hamachi start

in the /etc/rc.local?
I have tried it and it seems not working :S

Verified Working

This solution has been verified to work in Ubuntu 9.04 (Jaunty Jackalope) as well. I assume it would also work in 8.10 and of course 8.04 LTS.

Consistent failure

I have tried this recipe and several others.
I can get the automatic start to work easily on any of the recent 32bit Ubuntus, but have failed consistently for the 64bit. After using a "hamachi" script that work fine on 32bit, I moved it to a 64bit system and it fails. After this failure, if I start a terminal and
>hamachi login
>hamachi go-online myNetwork myPassword
it works fine. There is some indication that the network interface is not functional until after I log in to my account. However, this is a weak conjecture, as all I have to go on is an seemingly late pop-up notice that "the workstation is now connected to the wired network". Can any guru out there confirm or deny that the 64bit versions have something different about the way the network is initialized? Perhaps it has something to do with iPV6.

Older Engineer - 64bit Ubuntu Does Work

Hi Older Engineer,

I have tried on several Linux systems before and I can tell you that it is almost indepedent of the platform that it is running. One of my home PC is running on 64-bit Ubuntu and I have the script running up and fine.

I don't see that there is any problem with the script. Perhaps, what you have described above is probably the issue. If you are utilise IPv6 to run your network, then you may want to revert back to IPv4, because Hamachi generally links up with IPv4 protocol. Nonetheless, I cannot confirm if that might be the case.

Regards,
Keith

How do you uninstall this?

How do you uninstall this?

Please email me. Thanks!