#!/usr/bin/with-contenv bash

ARCH=$(uname -m)
if [ "${ARCH}" = "armv7l" ]; then
  echo '
*********************************************************
*********************************************************
****                                                 ****
****    julia binaries are no longer guaranteed      ****
****                                                 ****
****         to be available on arm32v7              ****
****                                                 ****
****     therefore this mod no longer supports       ****
****                                                 ****
****                  arm32v7                        ****
****                                                 ****
*********************************************************
*********************************************************
'
  exit 0
fi

if [ -d "/julia-bins" ]; then
  echo "**** Installing/updating Julia ****"
  mkdir -p /julia
  tar xf "/julia-bins/julia.tar.gz" -C \
    /julia --strip-components=1
  rm -rf /usr/local/bin/julia
  ln -s /julia/bin/julia /usr/local/bin/julia
  chmod +x /julia/bin/julia
  rm -rf /julia-bins
else
  echo "**** Latest stable version of Julia already installed ****"
fi

echo "**** Installing vscode extensions julia, julia-formatter and better-toml ****"
# extensions
install-extension julialang.language-julia
# vscode-julia-formatter
install-extension singularitti.vscode-julia-formatter
# better-toml
install-extension bungcip.better-toml
