Created
September 8, 2014 23:37
-
-
Save Gabelbombe/7c3880465d5761ad45a8 to your computer and use it in GitHub Desktop.
VPN connect and run setup commands in under osx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function tab () | |
{ | |
osascript 2>/dev/null <<EOF | |
tell application "System Events" | |
tell process "Terminal" to keystroke "t" using command down | |
end | |
tell application "Terminal" | |
activate | |
do script with command "cd \"$PWD\"; $*" in window 1 | |
end tell | |
EOF | |
} | |
function connect () | |
{ | |
clear | |
sudo killall -9 java resin netextender | |
osascript 2>/dev/null <<EOF | |
tell application "System Events" | |
tell process "Terminal" to keystroke "t" using command down | |
end | |
tell application "Terminal" | |
activate | |
do script with command " | |
cd $F_PATH | |
netextender $V_SERVER_ADDRESS \ | |
--username=$F_USER \ | |
--password=$F_PASS \ | |
--domain=$F_DOMAIN & | |
exec bash ## needs bash reinit | |
sleep 3 ## waiting for extender to load | |
bash start_apache.command & | |
clear | |
bash run_resin.jd.command | |
" in window 1 | |
end tell | |
EOF | |
} | |
function disconnect () | |
{ | |
sudo killall -9 java netextender | |
rPID=$(ps aux |grep 'run_resin' |grep -v grep|awk '{print$2}') | |
[ ! -z "${rPID}" ] && { | |
sudo kill -9 $rPID | |
} | |
## kill mDNSResponder again | |
mPID=$(ps aux |grep 'mDNS' |grep -v grep |awk '{print$2}') | |
[ ! -z "${mPID}" ] && { | |
sudo kill -9 $mPID | |
} | |
sudo killall -HUP mDNSResponder | |
} | |
function close () | |
{ | |
osascript -e 'tell application "System Events" to tell process "Terminal" to keystroke "w" using command down' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment