Script to make Hamachi run reliably under Linux
#! /bin/sh
# # Used to reliably log in/out of Hamachi # (c) 2008 Shane Tolmie of www.microchipc.com # set your specific network here NICKNAME="linux-usa" NETWORK="testing123#" PASSWORD="234ksdjf342" CONFIG_FOLDER="/hamachi" DELAY_SEC="1" # used if there is connection problems # There are two obstacles to running Hamachi reliably under Linux: # 1) not using delays between commands (the Hamachi server does not respond in time, and the login fails) # 2) not logging out of the Hamachi server properly before an OS reboot. # So, if you encounter issues, try execute the command "hamachi logout" before rebooting. # This script can be added to /etc/init.d/ (under SuSE) to automatically log in/out of Hamachi. # Once you copy the file to /etc/init.d/ you have to activate it (make it run on startup/shutdown) # - On SuSE, go into Administrator settings, then System..System Services (RunLevel). # - On other Linux distributions, there is a command add the script to the startup/shutdown sequence. # # Usage: # hamachi-daemon.sh config # adds this machine to the network (network must already exist) # hamachi-daemon.sh start # starts services # hamachi-daemon.sh stop # stops services # hamachi-daemon.sh restart # restarts services (used if there is issues connecting) # hamachi-daemon.sh list # lists machines on the network # Carry out specific functions when asked to by the system case "$1" in start) echo "Starting Hamachi" tuncfg >null hamachi -c $CONFIG_FOLDER start hamachi -c $CONFIG_FOLDER login hamachi -c $CONFIG_FOLDER go-online $NETWORK exit 0 ;; stop) echo "Stopping Hamachi" sleep $DELAY_SEC # if start was executed immediately before stop it might fail hamachi -c $CONFIG_FOLDER go-offline $NETWORK hamachi -c $CONFIG_FOLDER logout hamachi -c $CONFIG_FOLDER stop exit 0 ;; #this method has been tested and works well #this method does not seem to work without the delays restart) echo "Stopping Hamachi" hamachi -c $CONFIG_FOLDER go-offline $NETWORK sleep $DELAY_SEC hamachi -c $CONFIG_FOLDER leave $NETWORK sleep $DELAY_SEC hamachi -c $CONFIG_FOLDER logout #sleep $DELAY_SEC hamachi -c $CONFIG_FOLDER stop sleep $DELAY_SEC #wait for timeout echo "Starting Hamachi" tuncfg >null hamachi -c $CONFIG_FOLDER start #sleep $DELAY_SEC hamachi -c $CONFIG_FOLDER login sleep $DELAY_SEC hamachi -c $CONFIG_FOLDER join $NETWORK $PASSWORD sleep $DELAY_SEC hamachi -c $CONFIG_FOLDER go-online $NETWORK exit 0 ;; config) echo "Configuring Hamachi for the first time - network must already exist" tuncfg >null hamachi-init -c $CONFIG_FOLDER -f hamachi -c $CONFIG_FOLDER stop >null hamachi -c $CONFIG_FOLDER start hamachi -c $CONFIG_FOLDER login hamachi -c $CONFIG_FOLDER set-nick $NICKNAME #hamachi -c /hamachi create $NETWORK hamachi -c $CONFIG_FOLDER join $NETWORK $PASSWORD hamachi -c $CONFIG_FOLDER go-online $NETWORK exit 0 ;; list) echo "Hamachi list" tuncfg >null hamachi -c /hamachi exit 0 ;; *) echo "Usage: /etc/init.d/hamachi {start|stop|restart|config|list}" exit 1 ;; esac exit 0 |
Hamachi is not running?
Quote:
hamachi -c /hamachi list or: ./hamachi-daemon list |
All times are GMT -5. The time now is 08:24 AM. |