Skip to content

Commit

Permalink
add script check (#104)
Browse files Browse the repository at this point in the history
* add script check
  • Loading branch information
haobibo authored Jun 26, 2024
1 parent 7d9dce9 commit d1cf5e4
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 67 deletions.
9 changes: 5 additions & 4 deletions docker_atom/work/script-setup-db-clients.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ setup_postgresql_client() {
echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
# will download ~9MB files and use ~55MB disk after installation
sudo apt-get update && sudo apt-get -y install "postgresql-client-${VER_PG}"
echo "@ Version of psql client: $(psql --version)"

type psql && echo "@ Version of psql client: $(psql --version)" || return -1 ;
}


setup_mysql_client() {
# will download ~5MB files and use ~76MB disk after installation
sudo apt-get update && sudo apt-get -y install mysql-client
echo "@ Version of mysql client: $(mysql --version)"
type mysql && echo "@ Version of mysql client: $(mysql --version)" || return -1 ;
}


Expand All @@ -25,7 +26,7 @@ setup_mongosh_client() {
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse" > /etc/apt/sources.list.d/mongodb-org-6.0.list
# will download ~38MB files and use ~218MB disk after installation
sudo apt-get update && sudo apt-get -y install mongodb-mongosh
echo "@ Version of mongosh client: $(mongosh --version)"
type mongosh && echo "@ Version of mongosh client: $(mongosh --version)" || return -1 ;
}


Expand All @@ -34,5 +35,5 @@ setup_redis_client() {
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update && sudo apt-get -y install redis-tools
echo "@ Version of redis-cli: $(redis-cli --version)"
type redis-cli && echo "@ Version of redis-cli: $(redis-cli --version)" || return -1 ;
}
111 changes: 57 additions & 54 deletions docker_atom/work/script-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ source /opt/utils/script-utils.sh

setup_mamba() {
# Notice: mamba use $CONDA_PREFIX to locate base env
ARCH="linux-64" && MICROMAMBA_VERSION="latest" \
ARCH="linux-64" && MICROMAMBA_VERSION="latest" \
&& MAMBA_URL="https://micromamba.snakepit.net/api/micromamba/${ARCH}/${MICROMAMBA_VERSION}" \
&& mkdir -pv /opt/mamba /etc/conda \
&& install_tar_bz $MAMBA_URL bin/micromamba && mv /opt/bin/micromamba /opt/mamba/mamba \
&& ln -sf /opt/mamba/mamba /usr/bin/ \
&& touch /etc/conda/.condarc \
&& printf "channels:\n" >> /etc/conda/.condarc \
&& printf " - conda-forge\n" >> /etc/conda/.condarc
&& printf " - conda-forge\n" >> /etc/conda/.condarc ;

echo "@ Version of mamba:" && mamba info
type mamba && echo "@ Version of mamba: $(mamba info)" || return -1 ;
}


setup_conda_postprocess() {
type conda || return -1 ;

# If python exists, set pypi source
if [ -f "$(which python)" ]; then
cat >/etc/pip.conf <<EOF
Expand All @@ -38,10 +40,10 @@ EOF
&& conda config --system --set show_channel_urls true \
&& conda config --system --set report_errors false \
&& conda config --system --set channel_priority strict \
&& conda update --all --quiet --yes
&& conda update --all --quiet --yes ;

# remove non-necessary folder/symlink "python3.1" exists
rm -rf "${CONDA_PREFIX}"/bin/python3.1 "${CONDA_PREFIX}"/lib/python3.1
rm -rf "${CONDA_PREFIX}"/bin/python3.1 "${CONDA_PREFIX}"/lib/python3.1 ;

# These conda pkgs shouldn't be removed (otherwise will cause RemoveError) since they are directly required by conda: pip setuptools pycosat pyopenssl requests ruamel_yaml
# CONDA_PY_PKGS=$(conda list | grep "py3" | cut -d " " -f 1 | sed "/#/d;/conda/d;/pip/d;/setuptools/d;/pycosat/d;/pyopenssl/d;/requests/d;/ruamel_yaml/d;") \
Expand All @@ -50,31 +52,31 @@ EOF
# && rm -rf "${CONDA_PREFIX}"/pkgs/*

# Print Conda and Python packages information in the docker build log
echo "@ Version of Conda & Python:" && conda info && conda list | grep -v "<pip>"
echo "@ Version of Conda & Python:" && conda info && conda list | grep -v "<pip>" ;
}

setup_conda_with_mamba() {
local PREFIX="${CONDA_PREFIX:-/opt/conda}"
mkdir -pv "${PREFIX}"
VERSION_PYTHON=${1:-"3.11"}; shift 1;
mamba install -y --root-prefix="${PREFIX}" --prefix="${PREFIX}" -c "conda-forge" conda pip python="${VERSION_PYTHON}"
setup_conda_postprocess
VERSION_PYTHON=${1:-"3.12"}; shift 1;
local PREFIX="${CONDA_PREFIX:-/opt/conda}" \
&& mkdir -pv "${PREFIX}" \
&& mamba install -y --root-prefix="${PREFIX}" --prefix="${PREFIX}" -c "conda-forge" conda pip python="${VERSION_PYTHON}" \
&& setup_conda_postprocess ;
}

setup_conda_download() {
# https://docs.conda.io/projects/miniconda/en/latest/index.html
## https://docs.conda.io/projects/miniconda/en/latest/index.html
mkdir -pv "${CONDA_PREFIX}" \
&& wget -qO- "https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-$(arch).sh" -O /tmp/conda.sh \
&& bash /tmp/conda.sh -f -b -p "${CONDA_PREFIX}/" \
&& rm -rf /tmp/conda.sh \
&& setup_conda_postprocess
&& setup_conda_postprocess ;
}

setup_nvtop() {
# The compiliation requries CMake 3.18 or higher. default version in CUDA 11.2 images is 3.16.3
## The compiliation requries CMake 3.18 or higher. default version in CUDA 11.2 images is 3.16.3
curl -sL https://apt.kitware.com/keys/kitware-archive-latest.asc | sudo tee /etc/apt/trusted.gpg.d/kitware.asc \
&& echo "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/kitware.list \
&& apt-get -qq update -yq --fix-missing && apt-get -qq install -yq --no-install-recommends cmake
&& apt-get -qq update -yq --fix-missing && apt-get -qq install -yq --no-install-recommends cmake ;

# Install Utilities "nvtop" from source: libdrm-dev libsystemd-dev used by AMD/Intel GPU support, libudev-dev used by ubuntu18.04
LIB_PATH=$(find / -name "libnvidia-ml*" 2>/dev/null) \
Expand All @@ -86,9 +88,9 @@ setup_nvtop() {
&& cmake .. -DCMAKE_LIBRARY_PATH="$(dirname ${LIB_PATH})" -DNVIDIA_SUPPORT=ON -DAMDGPU_SUPPORT=ON -DINTEL_SUPPORT=ON \
&& make && sudo make install \
&& cd "${DIRECTORY}" && rm -rf /tmp/nvtop \
&& sudo apt-get -qq remove -y libncurses5-dev libdrm-dev libsystemd-dev libudev-dev
&& sudo apt-get -qq remove -y libncurses5-dev libdrm-dev libsystemd-dev libudev-dev ;

nvtop --version
type nvtop && echo "Version of nvtop: $(nvtop --version)" || return -1 ;
}


Expand Down Expand Up @@ -116,18 +118,20 @@ setup_java_base() {

echo "Installing JDK version ${VER_JDK} from: ${URL_OPENJDK}" \
&& install_tar_gz "${URL_OPENJDK}" && mv /opt/jdk* /opt/jdk \
&& ln -sf /opt/jdk/bin/* /usr/bin/ \
&& echo "@ Version of Java (java/javac):" && java -version && javac -version
&& ln -sf /opt/jdk/bin/* /usr/bin/

type java && echo "@ Version of Java (java): $(java -version)" || return -1 ;
type javac && echo "@ Version of Java (javac): $(javac -version)" || return -1 ;
}


setup_java_maven() {
VERSION_MAVEN=$(curl -sL https://maven.apache.org/download.cgi | grep 'latest' | head -1 | grep -Po '\d[\d.]+') \
&& install_zip "http://archive.apache.org/dist/maven/maven-3/${VERSION_MAVEN}/binaries/apache-maven-${VERSION_MAVEN}-bin.zip" \
&& mv "/opt/apache-maven-${VERSION_MAVEN}" /opt/maven \
&& ln -sf /opt/maven/bin/mvn* /usr/bin/
&& ln -sf /opt/maven/bin/mvn* /usr/bin/ ;

echo "@ Version of Maven: $(mvn --version)"
type mvn && echo "@ Version of Maven: $(mvn --version)" || return -1 ;
}


Expand All @@ -141,25 +145,24 @@ setup_node() {
&& mv /opt/node* /opt/node \
&& ln -sf /opt/node/bin/n* /usr/bin/ \
&& echo 'export PATH=${PATH}:/opt/node/bin' >> /etc/profile.d/path-node.sh \
&& npm install -g npm \
&& cd /tmp && corepack enable && yarn set version stable

echo "@ Version of Node and npm: $(node -v) $(npm -v)" \
&& echo "@ Version of Yarn: $(yarn -v)"
&& npm install -g npm ;
# cd /tmp && corepack enable && yarn set version stable && echo "@ Version of Yarn: $(yarn -v)"
type node && echo "@ Version of Node and node: $(node -v)" || return -1 ;
type npm && echo "@ Version of Node and npm: $(npm -v)" || return -1 ;
}


setup_GO() {
GO_VERSION=$(curl -sL https://github.com/golang/go/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+') \
&& GO_URL="https://dl.google.com/go/go${GO_VERSION}.linux-$(dpkg --print-architecture).tar.gz" \
&& install_tar_gz "${GO_URL}" go \
VER_GO=$(curl -sL https://github.com/golang/go/releases.atom | grep 'releases/tag' | grep -v 'rc' | head -1 | grep -Po '\d[\d.]+') \
&& URL_GO="https://dl.google.com/go/go${VER_GO}.linux-$(dpkg --print-architecture).tar.gz" \
&& install_tar_gz "${URL_GO}" go \
&& ln -sf /opt/go/bin/go* /usr/bin/ \
&& echo 'export GOROOT="/opt/go"' >> /etc/profile.d/path-go.sh \
&& echo 'export GOBIN="$GOROOT/bin"' >> /etc/profile.d/path-go.sh \
&& echo 'export GOPATH="$GOROOT/path"' >> /etc/profile.d/path-go.sh \
&& echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> /etc/profile.d/path-go.sh
&& echo 'export GOROOT="/opt/go"' >> /etc/profile.d/path-go.sh \
&& echo 'export GOBIN="$GOROOT/bin"' >> /etc/profile.d/path-go.sh \
&& echo 'export GOPATH="$GOROOT/path"' >> /etc/profile.d/path-go.sh \
&& echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> /etc/profile.d/path-go.sh ;

echo "@ Version of golang: $(go version)"
type go && echo "@ Version of golang: $(go version)" || return -1 ;
}


Expand All @@ -170,10 +173,10 @@ setup_rust() {
&& curl -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain stable \
&& echo 'export CARGO_HOME="/opt/cargo"' >> /etc/profile.d/path-rust.sh \
&& echo 'export RUSTUP_HOME="/opt/rust"' >> /etc/profile.d/path-rust.sh \
&& echo 'export PATH=$PATH:/opt/cargo/bin' >> /etc/profile.d/path-rust.sh
&& echo 'export PATH=$PATH:/opt/cargo/bin' >> /etc/profile.d/path-rust.sh ;

echo "@ Version of rustup: $(rustup --version)" \
&& echo "@ Version of rustc: $(rustc --version)"
type rustup && echo "@ Version of rustup: $(rustup --version)" || return -1 ;
type rustc && echo "@ Version of rustc: $(rustc --version)" || return -1 ;
}


Expand All @@ -184,9 +187,9 @@ setup_julia() {
&& ln -fs /opt/julia/bin/julia /usr/bin/julia \
&& mkdir -p /opt/julia/pkg \
&& echo "import Libdl; push!(Libdl.DL_LOAD_PATH, \"/opt/conda/lib\")" >> /opt/julia/etc/julia/startup.jl \
&& echo "DEPOT_PATH[1]=\"/opt/julia/pkg\"" >> /opt/julia/etc/julia/startup.jl
&& echo "DEPOT_PATH[1]=\"/opt/julia/pkg\"" >> /opt/julia/etc/julia/startup.jl ;

echo "@ Version of Julia: $(julia --version)"
type julia && echo "@ Version of Julia: $(julia --version)" || return -1 ;
}


Expand All @@ -198,9 +201,9 @@ setup_lua_base() {
&& mv /opt/lua-* /tmp/lua && cd /tmp/lua \
&& make linux test && make install INSTALL_TOP=${LUA_HOME:-"/opt/lua"} \
&& ln -sf ${LUA_HOME:-"/opt/lua"}/bin/lua* /usr/bin/ \
&& rm -rf /tmp/lua
&& rm -rf /tmp/lua ;

echo "@ Version of LUA installed: $(lua -v)"
type lua && echo "@ Version of LUA installed: $(lua -v)" || return -1 ;
}

setup_lua_rocks() {
Expand All @@ -212,36 +215,36 @@ setup_lua_rocks() {
&& mv /opt/luarocks-* /tmp/luarocks && cd /tmp/luarocks \
&& ./configure --prefix=${LUA_HOME:-"/opt/lua"} --with-lua-include=${LUA_HOME:-"/opt/lua"}/include && make install \
&& ln -sf /opt/lua/bin/lua* /usr/bin/ \
&& rm -rf /tmp/luarocks
&& rm -rf /tmp/luarocks ;

echo "@ Version of luarocks: $(luarocks --version)"
type luarocks && echo "@ Version of luarocks: $(luarocks --version)" || return -1 ;
}

setup_traefik() {
TRAEFIK_VERSION=$(curl -sL https://github.com/traefik/traefik/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+') \
&& TRAEFIK_URL="https://github.com/traefik/traefik/releases/download/v${TRAEFIK_VERSION}/traefik_v${TRAEFIK_VERSION}_linux_$(dpkg --print-architecture).tar.gz" \
&& install_tar_gz "${TRAEFIK_URL}" traefik \
&& ln -sf /opt/traefik /usr/bin/
&& ln -sf /opt/traefik /usr/bin/ ;

echo "@ Version of traefik: $(traefik version)"
type traefik && echo "@ Version of traefik: $(traefik version)" || return -1 ;
}


setup_bazel() {
BAZEL_VERSION=$(curl -sL https://github.com/bazelbuild/bazel/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+' ) \
&& BAZEL_URL="https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh" \
&& curl -o /tmp/bazel.sh -sL "${BAZEL_URL}" && chmod +x /tmp/bazel.sh \
&& /tmp/bazel.sh && rm /tmp/bazel.sh
VER_BAZEL=$(curl -sL https://github.com/bazelbuild/bazel/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+' ) \
&& URL_BAZEL="https://github.com/bazelbuild/bazel/releases/download/${VER_BAZEL}/bazel-${VER_BAZEL}-installer-linux-x86_64.sh" \
&& curl -o /tmp/bazel.sh -sL "${URL_BAZEL}" && chmod +x /tmp/bazel.sh \
&& /tmp/bazel.sh && rm /tmp/bazel.sh ;

echo "@ Version of bazel: $(bazel --version)"
type bazel && echo "@ Version of bazel: $(bazel --version)" || return -1 ;
}


setup_gradle() {
GRADLE_VERSION=$(curl -sL https://github.com/gradle/gradle/releases.atom | grep 'releases/tag' | grep -v 'M' | head -1 | grep -Po '\d[\d.]+' ) \
&& install_zip "https://downloads.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip" \
VER_GRADLE=$(curl -sL https://github.com/gradle/gradle/releases.atom | grep 'releases/tag' | grep -v 'M' | head -1 | grep -Po '\d[\d.]+' ) \
&& install_zip "https://downloads.gradle.org/distributions/gradle-${VER_GRADLE}-bin.zip" \
&& mv /opt/gradle* /opt/gradle \
&& ln -sf /opt/gradle/bin/gradle /usr/bin
&& ln -sf /opt/gradle/bin/gradle /usr/bin ;

echo "@ Version of gradle: $(gradle --version)"
type gradle && echo "@ Version of gradle: $(gradle --version)" || return -1 ;
}
12 changes: 7 additions & 5 deletions docker_core/work/script-setup-R.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ setup_R_base() {
&& echo "options(repos=structure(c(CRAN=\"https://cloud.r-project.org\")))" >> /etc/R/Rprofile.site \
&& R -e "install.packages(c('devtools'),clean=T,quiet=T);" \
&& R -e "install.packages(c('devtools'),clean=T,quiet=F);" \
&& ( type java && type R && R CMD javareconf || true ) \
&& echo "@ Version of R: $(R --version)"
&& ( type java && type R && R CMD javareconf || true ) ;

type R && echo "@ Version of R: $(R --version)" || return -1 ;
}


Expand Down Expand Up @@ -38,8 +39,9 @@ setup_R_rstudio() {
&& echo "provider=sqlite" >> /etc/rstudio/db.conf \
&& echo "directory=/etc/rstudio/" >> /etc/rstudio/db.conf \
&& printf "USER=root rserver --www-port=8888" > /usr/local/bin/start-rstudio.sh \
&& chmod u+x /usr/local/bin/start-rstudio.sh \
&& echo "@ Version of rstudio-server: $(rstudio-server version)"
&& chmod u+x /usr/local/bin/start-rstudio.sh ;

type rstudio-server && echo "@ Version of rstudio-server: $(rstudio-server version)" || return -1 ;
}


Expand All @@ -63,7 +65,7 @@ setup_R_rshiny() {
# hack shiny-server to allow run in root user: https://github.com/rstudio/shiny-server/pull/391
sed -i "s/throw new Error/logger.warn/g" /opt/shiny-server/lib/worker/app-worker.js

echo "@ Version of shiny-server: $(shiny-server --version)"
type shiny-server && echo "@ Version of shiny-server: $(shiny-server --version)" || return -1 ;
}


Expand Down
10 changes: 6 additions & 4 deletions docker_docker_kit/work/script-setup-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ setup_docker_compose() {
&& COMPOSE_URL="https://github.com/docker/compose/releases/download/v${COMPOSE_VERSION}/docker-compose-linux-${ARCH}" \
&& echo "Downloading Compose from: ${COMPOSE_URL}" \
&& sudo curl -o /usr/bin/docker-compose -sL ${COMPOSE_URL} \
&& sudo chmod +x /usr/bin/docker-compose \
&& echo "@ Version of docker-compose: $(docker-compose --version)"
&& sudo chmod +x /usr/bin/docker-compose ;

type docker-compose && echo "@ Version of docker-compose: $(docker-compose --version)" || return -1 ;
}

setup_docker_syncer() {
Expand All @@ -20,6 +21,7 @@ setup_docker_syncer() {
&& mkdir -pv /tmp/image_syncer && tar -zxvf /tmp/image_syncer.tgz -C /tmp/image_syncer \
&& sudo chmod +x /tmp/image_syncer/image-syncer \
&& sudo mv /tmp/image_syncer/image-syncer /usr/bin/ \
&& rm -rf /tmp/image_syncer* \
&& echo "@ image-syncer installed to: $(which image-syncer)"
&& rm -rf /tmp/image_syncer* ;

type image-syncer && echo "@ image-syncer installed to: $(which image-syncer)" || return -1 ;
}

0 comments on commit d1cf5e4

Please sign in to comment.