set toggle to %TOGGLE% set conf_name to "%NAME%" set conf_user to "%USER%" set conf_pass to "%PASS%" set conf_index to -1 if application "Tunnelblick" is running then else tell application "Tunnelblick" to activate end if tell application "Tunnelblick" -- finding index of configuration in Tunnelblick (applescript sucks) set all_conf_name to (get name of configurations) repeat with i from 1 to length of all_conf_name set curr_conf to item i of all_conf_name if curr_conf is conf_name then set conf_index to i end if end repeat if conf_index is -1 then return "configuration not found" else if toggle delete all credentials for conf_name save username conf_user for conf_name if (state of configuration conf_index) is "EXITING" then save password conf_pass for conf_name connect conf_name return "CONNECTING" else if (state of configuration conf_index) is "CONNECTED" then disconnect conf_name end if end if return state of configuration conf_index end if end tell