1212# ~/ECCO-v4-Python-Tutorial/ECCO-ACCESS/Cloud_access_to_ECCO_datasets/jupyter_env_setup.sh
1313
1414
15+
1516# # Start body of script
1617
18+ red_start=' \033[0;31m'
19+ blue_start=' \033[0;34m'
20+ nocolor_start=' \033[0m'
21+
1722# install wget
1823sudo dnf install wget -y
24+ echo -e " ${red_start} Installed wget${nocolor_start} "
1925
20- # retrieve and install miniforge in /opt/
26+ # install tmux
27+ sudo dnf install tmux -y
28+ echo -e " ${red_start} Installed tmux${nocolor_start} "
29+
30+ # retrieve and install miniforge in /tmp/
2131# assuming EBS volume is already attached to instance
32+ echo -e " ${red_start} Starting Miniforge3 installation${nocolor_start} "
2233mkdir -p /tmp
2334wget " https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh" -O /tmp/Miniforge3.sh
24- sudo bash /tmp/Miniforge3.sh -b -p /opt /conda
25- sudo chmod -R a+w /opt/conda
26- source " /opt /conda/etc/profile.d/conda.sh"
27- source " /opt /conda/etc/profile.d/mamba.sh"
35+ bash /tmp/Miniforge3.sh -b -p /tmp /conda
36+ rm -f /tmp/Miniforge.sh
37+ source " /tmp /conda/etc/profile.d/conda.sh"
38+ source " /tmp /conda/etc/profile.d/mamba.sh"
2839
29- red_start=' \033[0;31m'
30- nocolor_start=' \033[0m+'
3140echo -e " ${red_start} Completed Miniforge3 installation${nocolor_start} "
3241
3342# add conda and mamba to path
@@ -46,6 +55,7 @@ echo -e "${red_start}Created jupyter environment${nocolor_start}"
4655
4756# install python packages (using mamba) in jupyter environment
4857mamba activate jupyter
58+ echo -e " ${red_start} Installing Python packages in jupyter environment${nocolor_start} "
4959mamba install requests tqdm numpy pandas -y
5060mamba install xorg-libice libexpat libevent -y
5161mamba install nspr alsa-lib libogg libpq -y
@@ -90,34 +100,35 @@ pip install ecco_v4_py
90100
91101echo -e " ${red_start} Completed Python package installations${nocolor_start} "
92102
103+ echo -e " ${red_start} Setting up NASA Earthdata authentication${nocolor_start} "
93104# NASA Earthdata authentication
94105# check if credentials are already archived in ~/.netrc, and if not then prompt the user for them
95106earthdata_cred_stored=0
96107if [ -f ~ /.netrc ]; then
97108 if grep -q " machine urs.earthdata.nasa.gov" ~ /.netrc; then
98109 earthdata_cred_stored=1
110+ echo -e " ${red_start} Earthdata credentials already archived"
99111 fi
100112fi
101113if [ $earthdata_cred_stored -eq 0 ]; then
102114 if [ -f ~ /.netrc ]; then sudo chmod 600 ~ /.netrc; fi
103115 read -p ' NASA Earthdata username: ' uservar
104116 read -sp ' NASA Earthdata password: ' passvar
105117 echo -e " machine urs.earthdata.nasa.gov\n login ${uservar} \n password ${passvar} \n" >> ~ /.netrc
118+
119+ echo -e " \n${red_start} NASA Earthdata authentication info archived in ~\/.netrc${nocolor_start} "
106120fi
107121sudo chmod 400 ~ /.netrc
108122
109- echo -e " ${red_start} Set up NASA Earthdata authentication${nocolor_start} "
110-
111123# set up Jupyter lab, to be opened in a tmux session using password
112124PW=" $( python3 -c ' from notebook.auth import passwd; import getpass; print(passwd(getpass.getpass(), algorithm="sha256"))' ) "
113- jlab_start=" \'jupyter lab --no-browser --autoreload --port=9889 --ip=\'127.0.0.1\' --NotebookApp.token=\'\' --NotebookApp.password=\" $PW \" --notebook-dir=\" ~/ECCO-v4-Python-Tutorial/Tutorials_as_Jupyter_Notebooks\" \'"
125+ jlab_start=" \'mamba activate jupyter && jupyter lab --no-browser --autoreload --port=9889 --ip=\'127.0.0.1\' --NotebookApp.token=\'\' --NotebookApp.password=\" $PW \" --notebook-dir=\" ~/ECCO-v4-Python-Tutorial/Tutorials_as_Jupyter_Notebooks\" \'"
114126tmux new-session -d -s jupyterlab ${jlab_start}
115127
116- blue_start=' \033[0;34m'
117128echo -e " ${red_start} Started Jupyter lab in tmux session jupyterlab"
118129echo -e " ${red_start} Access from your local machine in a browser window at"
119130echo -e " ${blue_start} http://127.0.0.1:9889/"
120131echo -e " ${red_start} tmux session can be accessed with"
121132echo -e " ${blue_start} tmux -a -t jupyterlab"
122133echo -e " ${red_start} and terminated with"
123- echo -e " ${blue_start} tmux kill-ses -t jupyterlab"
134+ echo -e " ${blue_start} tmux kill-ses -t jupyterlab${nocolor_start} "
0 commit comments