Skip to content

Instantly share code, notes, and snippets.

@Alexander-Barth
Last active December 9, 2022 15:43
Show Gist options
  • Save Alexander-Barth/aa5f1c3c80221729cf0dd9984692bfc1 to your computer and use it in GitHub Desktop.
Save Alexander-Barth/aa5f1c3c80221729cf0dd9984692bfc1 to your computer and use it in GitHub Desktop.
JULIA_VERSION=1.8.3
USER=student
# array with major, minor and revision number
JULIA_VERSION_PARTS=( ${JULIA_VERSION//./ } )
# just major and minor number
JULIA_VERSION_SHORT=${JULIA_VERSION_PARTS[0]}.${JULIA_VERSION_PARTS[1]}
mkdir -p /opt
if ! command -v julia &> /dev/null; then
cd /opt
wget https://julialang-s3.julialang.org/bin/linux/x64/$JULIA_VERSION_SHORT/julia-$JULIA_VERSION-linux-x86_64.tar.gz
tar -xvf julia-$JULIA_VERSION-linux-x86_64.tar.gz
rm julia-$JULIA_VERSION-linux-x86_64.tar.gz
mv julia-* julia-$JULIA_VERSION
ln -s /opt/julia-$JULIA_VERSION/bin/julia /usr/local/bin
fi
if command -v check-language-support &> /dev/null; then
sudo apt-get -y install $(check-language-support -l fr)
sudo apt-get -y install $(check-language-support -l en)
fi
# DINEOF
sudo apt-get update
sudo apt-get install -y gfortran make libarpack2-dev libnetcdf-dev libnetcdff-dev netcdf-bin openssh-server
sudo apt-get install -y python3-pip python3-setuptools python3-matplotlib libffi-dev curl emacs tmux
sudo apt-get install -y perl libopenmpi-dev openmpi-bin desktop-file-utils
sudo apt-get install -y subversion git
if dpkg --get-selections | grep -q "^ubuntu-mate-welcome[[:space:]]*install$" >/dev/null; then
# https://howtoinstall.co/en/ubuntu/xenial/ubuntu-mate-welcome?action=remove
sudo apt-get remove ubuntu-mate-welcome
fi
sudo adduser "$USER" sudo
su --login "$USER" <<'EOF'
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
python3 -m pip install --user jupyter
python3 -m pip install --user motuclient==1.8.6
julia --eval 'using Pkg; pkg"add ZMQ IJulia PyCall PyPlot Interpolations MAT JSON SpecialFunctions Interact Roots JLD2 FileIO Revise"'
julia --eval 'using Pkg; pkg"add Glob NCDatasets CSV DataStructures Compat Mustache HTTP PhysOcean DIVAnd Missings DistributedArrays"'
julia --eval 'using Pkg; pkg"dev https://github.com/Alexander-Barth/ROMS.jl"'
julia --eval 'using IJulia'
julia --eval 'using PyPlot'
cat >> ~/.emacs <<E-O-F
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
E-O-F
mkdir -p ~/.julia/config/
cat >> ~/.julia/config/startup.jl <<E-O-F
using Revise
E-O-F
# Install a desktop launcher and icon for julia
wget -O /tmp/julia.desktop https://raw.githubusercontent.com/JuliaLang/julia/e90f29db30f81f340d4f36669b27ac5a281e2a7f/contrib/julia.desktop
desktop-file-install --dir=$HOME/.local/share/applications /tmp/julia.desktop
mkdir -p ~/.local/share/icons/hicolor/scalable/apps/
wget -O ~/.local/share/icons/hicolor/scalable/apps/julia.svg https://raw.githubusercontent.com/JuliaLang/julia/30bf89f3d8e564b588b8e48993e92a551b384f2c/contrib/julia.svg
# Install a desktop launcher and icon for jupyter
mkdir /home/$USER/.icons
wget -O /home/$USER/.icons/jupyter.svg https://raw.githubusercontent.com/jupyter/jupyter.github.io/3e468a804b5608312c553feb2b9964cc9a8ab9b8/assets/main-logo.svg
cat > /tmp/jupyter.desktop <<E-O-F
[Desktop Entry]
Version=1.0
Type=Application
Name=Jupyter
Icon=/home/$USER/.icons/jupyter.svg
Exec=/home/$USER/.local/bin/jupyter notebook %F
Path=/home/$USER
Comment=Jupyter notebook
MimeType=application/x-ipynb+json;
Categories=Development;ComputerScience;Science;Math;NumericalAnalysis;DataVisualization;
Terminal=true
X-Desktop-File-Install-Version=0.22
E-O-F
desktop-file-install --dir=$HOME/.local/share/applications /tmp/jupyter.desktop
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment