#!/bin/bash #defines IMG_WARN='gtk-dialog-warning' IMG_ERROR='gtk-dialog-error' IMG_INFO='gtk-dialog-info' IMG_SUCCESS='gtk-apply' #functions #prints messages to console or display using notify-daemon if installed #params: #1. type (info,warning,error,success) #2. message function print_message () { if [ "$NOTIFY" == "1" ] then if [ "$1" == "info" ] then IMG="$IMG_INFO";fi if [ "$1" == "warning" ] then IMG="$IMG_WARN";fi if [ "$1" == "error" ] then IMG="$IMG_ERROR";fi if [ "$1" == "success" ] then IMG="$IMG_SUCCESS";fi notify-send Hamachi "$2" -i $IMG else echo "$1:$2" fi } #main logic #check if notify-send is installed if which notify-send then NOTIFY=1; else NOTIFY=0 fi #check if tuncfg runs, if not start it if ps -C tuncfg > /dev/null then print_message 'info' 'tuncfg allready running...nothing to do!' else print_message 'info' 'starting tuncfg..' if gksu tuncfg then print_message 'success' 'tuncfg successfuly started!' else print_message 'error' 'failed to start tuncfg..' fi fi #start hamachi service if hamachi start then print_message 'success' 'hamachi successfuly started!' else print_message 'error' 'failed to start hamachi..' fi #login to hamachi if hamachi login then print_message 'success' 'hamachi successfuly loged in!' else print_message 'error' 'hamachi failed to login!' fi #go online in mgolisch.home network if hamachi go-online mynetwork then print_message 'success' 'hamachi gone online in network mynetwork!' else print_message 'error' 'hamachi failed to go online in network mynetwork!' fi