Commit d456caae authored by Willi Rath's avatar Willi Rath

Add possibility to look up IP

parent 67facd8f
......@@ -3,7 +3,7 @@
# Sebastian Wahl 08/2018
#
# tested on ursus/taurus, science0[1,2].geomar.de, bdata2.hlrn.de, nesh-fe1.rz.uni-kiel.de
#
#
# TODO:
# - add option to provide an input file with the tasks to do e.g
# $0 hosts.txt
......@@ -25,9 +25,9 @@ function connect() {
ssh -f -D localhost:${socks_5_port} $hname sleep 15
page=$(ssh $hname "\${HOME}/miniconda3/bin/python \${HOME}/miniconda3/bin/jupyter notebook list" | grep http | awk '{print$1}')
if [[ "$(uname)" == "Darwin" ]]; then
if [[ "$(uname)" == "Darwin" ]]; then
chrome=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
if [[ -f "$chrome" ]]; then
# TODO: disable warning output
"$chrome" --new-window --user-data-dir="/tmp/chromium_user_data_$(date -Ins)" --proxy-server='socks5://localhost:'${socks_5_port} $page &
......@@ -42,15 +42,15 @@ function connect() {
if which chromium-browser >/dev/null; then
chromium-browser --new-window --user-data-dir="/tmp/chromium_user_data_$(date -Ins)" \
--proxy-server="socks5://localhost:${socks_5_port}" $page &
# delete user data older than 30 days
# delete user data older than 30 days
echo " Cleaning tmp data on /tmp (if any)"
find /tmp/ -maxdepth 1 -mtime +30 -name "chromium_user_data*" -exec rm -rf {} \;
else
echo
echo " ERROR: chrome browser needs to be installed. On Ubuntu try sudo apt-get install chromium-browser and try again."
echo " ERROR: chrome browser needs to be installed. On Ubuntu try sudo apt-get install chromium-browser and try again."
echo
fi
fi
fi
}
......@@ -73,11 +73,11 @@ if [[ $# -lt 2 ]]; then
echo
echo " $0 user@host.example.com start "
echo " to start an existing jupyterlab environment on <user@host.example.com> and connect afterwards"
echo " if jupyterlab is already running on <user@host.example.com> you will be connected with the existing instance."
echo
echo " if jupyterlab is already running on <user@host.example.com> you will be connected with the existing instance."
echo
echo " $0 user@host.example.com stop "
echo " to stop jupyterlab running on <user@host.example.com>"
echo
echo " to stop jupyterlab running on <user@host.example.com>"
echo
echo " $0 user@host.example.com install "
echo " to install a new miniconda environment. (WARNING: takes 5-10 minutes, an existing"
echo " $HOME/miniconda3 will be saved before starting the install process."
......@@ -101,10 +101,11 @@ port=
# see issues on gitlab
ip="127.0.0.1"
[[ $# -eq 3 ]] && ip=$3
[[ "$ip" == "lookup" ]] && ip="\$(getent hosts \${HOSTNAME} | awk '{print \$1}')"
if [[ "$task" == "start" ]] || [[ "$task" == "stop" ]]; then
page=$(ssh $hname "\${HOME}/miniconda3/bin/python \${HOME}/miniconda3/bin/jupyter notebook list" | grep http | awk '{print$1}')
port=$(echo $page | awk -F: '{print$3}' | awk -F/ '{print$1}')
port=$(echo $page | awk -F: '{print$3}' | awk -F/ '{print$1}')
fi
echo
......@@ -113,11 +114,11 @@ if [[ "$task" == "start" ]]; then
echo " No Jupyterlab server running on $hname. Will start a server and connect to it "
# TODO: avoid hitting Ctrl+C --> how to I start this in the backgroud adding & does not work
echo " Wait until you see the URL of the server and then hit Ctrl+C to continue"
ssh $hname "\${HOME}/miniconda3/bin/python \${HOME}/miniconda3/bin/jupyter lab --no-browser --ip $ip"
ssh $hname "\${HOME}/miniconda3/bin/python \${HOME}/miniconda3/bin/jupyter lab --no-browser --ip $ip"
echo " Jupyterlab on $hname started"
else
echo " Jupyterlab on $hname, port $port already running. Connecting to existing server."
fi
fi
echo
connect $hname
......@@ -128,7 +129,7 @@ elif [[ "$task" == "stop" ]]; then
ssh $hname "\${HOME}/miniconda3/bin/python \${HOME}/miniconda3/bin/jupyter notebook stop $port"
else
echo " No Jupyterlab running on $hname"
fi
fi
echo
elif [[ "$task" == "install" ]]; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment