Add SDKMAN! to java definition (#510)

* Improve visibility to database, ports in js-node-mongo

* Improve visibility to database, ports in js-node-postges

* Improve visibility to database, ports in php-mariadb

* Improve visibility to database, ports in python-3-postgres

* Minor script edits

* Switch to SDKMAN for java definition
This commit is contained in:
Chuck Lantz 2020-08-21 20:30:30 -07:00 коммит произвёл GitHub
Родитель b36ffd8c76
Коммит b41d7e032f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 244 добавлений и 225 удалений

Просмотреть файл

@ -1,29 +1,19 @@
ARG VARIANT=11
FROM mcr.microsoft.com/vscode/devcontainers/java:dev-${VARIANT}
# [Optional] Install Maven or Gradle
ARG INSTALL_MAVEN="false"
ARG MAVEN_VERSION=3.6.3
ARG INSTALL_GRADLE="false"
ARG GRADLE_VERSION=5.4.1
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then su vscode -c "source /usr/local/sdkman/bin/sdkman-init.sh && sdk install maven \"${MAVEN_VERSION}\""; fi \
&& if [ "${INSTALL_GRADLE}" = "true" ]; then su vscode -c "source /usr/local/sdkman/bin/sdkman-init.sh && sdk install gradle \"${GRADLE_VERSION}\""; fi
# [Optional] Install a version of Node.js using nvm for front end dev
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "source /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# [Optional] Install Maven
ARG INSTALL_MAVEN="false"
ARG MAVEN_VERSION=3.6.3
ARG MAVEN_DOWNLOAD_SHA="no-check"
ENV MAVEN_HOME=/usr/local/share/maven
COPY library-scripts/maven-debian.sh /tmp/library-scripts/
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then bash /tmp/library-scripts/maven-debian.sh ${MAVEN_VERSION} ${MAVEN_HOME} ${USERNAME} ${MAVEN_DOWNLOAD_SHA}; fi \
&& rm -f /tmp/library-scripts/maven-debian.sh
# [Optional] Install Gradle
ARG INSTALL_GRADLE="false"
ARG GRADLE_VERSION=5.4.1
ARG GRADLE_DOWNLOAD_SHA="no-check"
ENV GRADLE_HOME=/usr/local/share/gradle
COPY library-scripts/gradle-debian.sh /tmp/library-scripts/
RUN if [ "${INSTALL_GRADLE}" = "true" ]; then bash /tmp/library-scripts/gradle-debian.sh ${GRADLE_VERSION} ${GRADLE_HOME} ${USERNAME} ${GRADLE_DOWNLOAD_SHA}; fi \
&& rm -f /tmp/library-scripts/gradle-debian.sh
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

Просмотреть файл

@ -1,4 +1,4 @@
# Update the VARIANT arg in devcontainer.json to pick a Java version: 11, 14
# Update the VARIANT arg in devcontainer.json to pick a Java version: 8, 11, 14
ARG VARIANT=11
FROM openjdk:${VARIANT}-jdk-buster
@ -13,33 +13,28 @@ RUN bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "$
&& if [ ! -d "/docker-java-home" ]; then ln -s "${JAVA_HOME}" /docker-java-home; fi \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
# [Optional] Install Maven
# Install SDKMAN and optionally Maven and Gradle
ARG INSTALL_MAVEN="false"
ARG MAVEN_VERSION=3.6.3
ARG MAVEN_DOWNLOAD_SHA="no-check"
ENV MAVEN_HOME=/usr/local/share/maven
COPY library-scripts/maven-debian.sh /tmp/library-scripts/
RUN if [ "${INSTALL_MAVEN}" = "true" ]; then bash /tmp/library-scripts/maven-debian.sh ${MAVEN_VERSION} ${MAVEN_HOME} ${USERNAME} ${MAVEN_DOWNLOAD_SHA}; fi \
&& rm -f /tmp/library-scripts/maven-debian.sh
# [Optional] Install Gradle
ARG INSTALL_GRADLE="false"
ARG GRADLE_VERSION=5.4.1
ARG GRADLE_DOWNLOAD_SHA="no-check"
ENV GRADLE_HOME=/usr/local/share/gradle
COPY library-scripts/gradle-debian.sh /tmp/library-scripts/
RUN if [ "${INSTALL_GRADLE}" = "true" ]; then bash /tmp/library-scripts/gradle-debian.sh ${GRADLE_VERSION} ${GRADLE_HOME} ${USERNAME} ${GRADLE_DOWNLOAD_SHA}; fi \
&& rm -f /tmp/library-scripts/gradle-debian.sh
ENV SDKMAN_DIR="/usr/local/sdkman"
ENV PATH="${PATH}:${SDKMAN_DIR}/java/current/bin:${SDKMAN_DIR}/maven/current/bin:${SDKMAN_DIR}/gradle/current/bin"
COPY library-scripts/java-debian.sh /tmp/library-scripts/
RUN bash /tmp/library-scripts/java-debian.sh "none" "${SDKMAN_DIR}" "${USERNAME}" "true" \
&& if [ "${INSTALL_MAVEN}" = "true" ]; then bash /tmp/library-scripts/maven-debian.sh ${MAVEN_VERSION} "${SDKMAN_DIR}" ${USERNAME} "true"; fi \
&& if [ "${INSTALL_GRADLE}" = "true" ]; then bash /tmp/library-scripts/gradle-debian.sh ${GRADLE_VERSION} "${SDKMAN_DIR}" ${USERNAME} "true"; fi \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
# [Optional] Install Node.js for use with web applications - update the INSTALL_NODE arg in devcontainer.json to enable.
ARG INSTALL_NODE="true"
ARG NODE_VERSION="none"
ENV NVM_DIR=/usr/local/share/nvm
ENV NVM_SYMLINK_CURRENT=true \
PATH=${NVM_DIR}/current/bin:${PATH}
PATH="${NVM_DIR}/current/bin:${PATH}"
COPY library-scripts/node-debian.sh /tmp/library-scripts/
RUN if [ "$INSTALL_NODE" = "true" ]; then bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}"; fi \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts/node-debian.sh
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \

Просмотреть файл

@ -1,7 +1,7 @@
{
"name": "Java",
"build": {
"dockerfile": "Dockerfile",
"dockerfile": "base.Dockerfile",
"args": {
// Update the VARIANT arg to pick a Java version: 11, 14
"VARIANT": "11",

Просмотреть файл

@ -4,23 +4,18 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./gradle-debian.sh <gradle version> [gradle home] [non-root-user] [gradle SHA 256]
# Syntax: ./gradle-debian.sh [gradle version] [SDKMAN_DIR] [non-root user] [Update rc files flag]
GRADLE_VERSION=$1
GRADLE_HOME=${2:-"/usr/local/share/gradle"}
GRADLE_VERSION=${1:-"lts"}
export SDKMAN_DIR=${2:-"/usr/local/sdkman"}
USERNAME=${3:-"vscode"}
GRADLE_DOWNLOAD_SHA=${4:-"no-check"}
UPDATE_RC=${4:-"true"}
set -e
if [ -d "${GRADLE_HOME}" ]; then
echo "Gradle already installed."
exit 0
fi
if [ -z "$1" ]; then
echo -e "Required argument missing.\n\ngradle-debian.sh <gradle version> [gradle home] [non-root-user] [gradle SHA 256]"
exit 1
# Blank will install latest maven version
if [ "${GRADLE_VERSION}" = "lts" ]; then
GRADLE_VERSION=""
fi
if [ "$(id -u)" -ne 0 ]; then
@ -33,30 +28,35 @@ if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi
# Install curl, unzip if missing
if ! dpkg -s curl ca-certificates unzip > /dev/null 2>&1; then
export DEBIAN_FRONTEND=noninteractive
function updaterc() {
if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="$1"
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
fi
fi
}
export DEBIAN_FRONTEND=noninteractive
# Install curl, zip, unzip if missing
if ! dpkg -s curl ca-certificates zip unzip sed > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends curl ca-certificates unzip
apt-get -y install --no-install-recommends curl ca-certificates zip unzip sed
fi
# Install sdkman if not installed
if [ ! -d "${SDKMAN_DIR}" ]; then
curl -sSL "https://get.sdkman.io?rcupdate=false" | bash
chown -R "${USERNAME}" "${SDKMAN_DIR}"
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
fi
# Install Gradle
echo "Downloading Gradle..."
su ${USERNAME} -c "$(cat << EOF
set -e
mkdir -p /tmp/downloads
curl -sSL --output /tmp/downloads/archive-gradle.zip https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
([ "${GRADLE_DOWNLOAD_SHA}" = "no-check" ] || echo "${GRADLE_DOWNLOAD_SHA} */tmp/downloads/archive-gradle.zip" | sha256sum --check - )
unzip -q /tmp/downloads/archive-gradle.zip -d /tmp/downloads/
EOF
)"
mv -f /tmp/downloads/gradle* ${GRADLE_HOME}
chown ${USERNAME}:root ${GRADLE_HOME}
ln -s ${GRADLE_HOME}/bin/gradle /usr/local/bin/gradle
rm -rf /tmp/downloads
# Install gradle
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION}"
updaterc "export GRADLER_USER_HOME=\${HOME}/.gradle"
echo "Done!"

Просмотреть файл

@ -0,0 +1,61 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./java-debian.sh [JDK version] [SDKMAN_DIR] [non-root user] [Add to rc files flag]
JAVA_VERSION=${1:-"lts"}
export SDKMAN_DIR=${2:-"/usr/local/sdkman"}
USERNAME=${3:-"vscode"}
UPDATE_RC=${4:-"true"}
echo $JAVA_VERSION
set -e
# Blank will install latest AdoptOpenJDK version
if [ "${JAVA_VERSION}" = "lts" ]; then
JAVA_VERSION=""
fi
if [ "$(id -u)" -ne 0 ]; then
echo -e 'Script must be run a root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
exit 1
fi
# Treat a user name of "none" or non-existant user as root
if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi
export DEBIAN_FRONTEND=noninteractive
# Install curl, zip, unzip if missing
if ! dpkg -s curl ca-certificates zip unzip sed > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends curl ca-certificates zip unzip sed
fi
# Install sdkman if not installed
if [ ! -d "${SDKMAN_DIR}" ]; then
curl -sSL "https://get.sdkman.io?rcupdate=false" | bash
chown -R "${USERNAME}" "${SDKMAN_DIR}"
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
fi
fi
fi
if [ "${JAVA_VERSION}" != "none" ]; then
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install java ${JAVA_VERSION}"
fi
echo "Done!"

Просмотреть файл

@ -4,23 +4,18 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./maven-debian.sh <maven version> [maven home] [non-root user] [maven SHA 512]
# Syntax: ./maven-debian.sh [maven version] [SDKMAN_DIR] [non-root user] [Update rc files flag]
MAVEN_VERSION=$1
MAVEN_HOME=${2:-"/usr/local/share/maven"}
MAVEN_VERSION=${1:-"lts"}
export SDKMAN_DIR=${2:-"/usr/local/sdkman"}
USERNAME=${3:-"vscode"}
MAVEN_DOWNLOAD_SHA=${4:-"no-check"}
UPDATE_RC=${4:-"true"}
set -e
if [ -d "${MAVEN_HOME}" ]; then
echo "Maven already installed."
exit 0
fi
if [ -z "$1" ]; then
echo -e "Required argument missing.\n\nmaven-debian.sh <maven version> [maven home] [non-root user] [maven SHA 512]"
exit 1
# Blank will install latest maven version
if [ "${MAVEN_VERSION}" = "lts" ]; then
MAVEN_VERSION=""
fi
if [ "$(id -u)" -ne 0 ]; then
@ -33,34 +28,35 @@ if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi
# Install curl, tar if missing
if ! dpkg -s curl ca-certificates tar > /dev/null 2>&1; then
export DEBIAN_FRONTEND=noninteractive
function updaterc() {
if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="$1"
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
fi
fi
}
export DEBIAN_FRONTEND=noninteractive
# Install curl, zip, unzip if missing
if ! dpkg -s curl ca-certificates zip unzip sed > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends curl ca-certificates tar
apt-get -y install --no-install-recommends curl ca-certificates zip unzip sed
fi
# Creat folder, add maven settings
mkdir -p ${MAVEN_HOME} ${MAVEN_HOME}/ref
tee ${MAVEN_HOME}/ref/maven-settings.xml > /dev/null \
<< EOF
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${MAVEN_HOME}/ref/repository</localRepository>
</settings>
EOF
chown -R ${USERNAME}:root ${MAVEN_HOME}
# Install sdkman if not installed
if [ ! -d "${SDKMAN_DIR}" ]; then
curl -sSL "https://get.sdkman.io?rcupdate=false" | bash
chown -R "${USERNAME}" "${SDKMAN_DIR}"
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
fi
# Install Maven
echo "Downloading Maven..."
su ${USERNAME} -c "$(cat << EOF
set -e
curl -fsSL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz
([ "${MAVEN_DOWNLOAD_SHA}" = "no-check" ] || echo "${MAVEN_DOWNLOAD_SHA} */tmp/maven.tar.gz" | sha512sum -c - )
tar -xzf /tmp/maven.tar.gz -C ${MAVEN_HOME} --strip-components=1
rm -f /tmp/maven.tar.gz
EOF
)"
ln -s ${MAVEN_HOME}/bin/mvn /usr/local/bin/mvn
echo "Done!"
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION}"
updaterc "export M2=\$HOME/.m2"
echo "Done!"

Просмотреть файл

@ -1,8 +1,6 @@
README.md
test-project
definition-manifest.json
.devcontainer/library-scripts/README.md
.devcontainer/library-scripts/common-debian.sh
.devcontainer/library-scripts/node-debian.sh
.devcontainer/library-scripts
.vscode
.npmignore

Просмотреть файл

@ -72,7 +72,7 @@ chown $USER_UID:$USER_GID /home/$USERNAME/.bashrc
# Optionally install and configure zsh
if [ "$INSTALL_ZSH" = "true" ] && [ ! -d "/root/.oh-my-zsh" ]; then
apk add --no-cache zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
echo "export PATH=\$PATH:\$HOME/.local/bin" >> /root/.zshrc
cp -R /root/.oh-my-zsh /home/$USERNAME
cp /root/.zshrc /home/$USERNAME

Просмотреть файл

@ -166,7 +166,7 @@ fi
if [ "${INSTALL_ZSH}" = "true" ] && [ ! -d "/root/.oh-my-zsh" ] && [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
apt-get-update-if-needed
apt-get install -y zsh
curl -fsSLo- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash 2>&1
curl -fsSLo- https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh | bash 2>&1
echo -e "${RC_SNIPPET}\nDEFAULT_USER=\$USER\nprompt_context(){}" >> /root/.zshrc
cp -fR /root/.oh-my-zsh /etc/skel
cp -f /root/.zshrc /etc/skel

Просмотреть файл

@ -77,7 +77,7 @@ chown $USER_UID:$USER_GID /home/$USERNAME/.bashrc
# Optionally install and configure zsh
if [ "$INSTALL_ZSH" = "true" ] && [ ! -d "/root/.oh-my-zsh" ]; then
yum install -y zsh
curl -fsSLo- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh | bash 2>&1
curl -fsSLo- https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh | bash 2>&1
echo "export PATH=\$PATH:\$HOME/.local/bin" >> /root/.zshrc
cp -R /root/.oh-my-zsh /home/$USERNAME
cp /root/.zshrc /home/$USERNAME

Просмотреть файл

@ -20,8 +20,9 @@ if ! dpkg -s build-essential curl ca-certificates tar gettext libssl-dev zlib1g-
fi
echo "Downloading source for ${GIT_VERSION}..."
curl -sL https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz | tar -xzC /tmp
curl -sL https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz | tar -xzC /tmp 2>&1
echo "Building..."
(cd /tmp/git-${GIT_VERSION} && make -s prefix=/usr/local all && make -s prefix=/usr/local install)
cd /tmp/git-${GIT_VERSION}
make -s prefix=/usr/local all && make -s prefix=/usr/local install 2>&1
rm -rf /tmp/git-${GIT_VERSION}
echo "Done!"

Просмотреть файл

@ -35,7 +35,6 @@ if ! dpkg -s curl ca-certificates tar git g++ gcc libc6-dev make pkg-config > /d
apt-get -y install --no-install-recommends curl ca-certificates tar git g++ gcc libc6-dev make pkg-config
fi
# Install Go
GO_INSTALL_SCRIPT="$(cat <<EOF
set -e
@ -107,7 +106,7 @@ if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="export GOPATH=\"${TARGET_GOPATH}\"\nexport GOROOT=\"${TARGET_GOROOT}\"\nexport PATH=\"\${GOROOT}/bin:\${PATH}\""
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc /home/${USERNAME}/.zshrc
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
fi
fi
echo "Done!"

Просмотреть файл

@ -4,23 +4,18 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./gradle-debian.sh <gradle version> [gradle home] [non-root-user] [gradle SHA 256]
# Syntax: ./gradle-debian.sh [gradle version] [SDKMAN_DIR] [non-root user] [Update rc files flag]
GRADLE_VERSION=$1
GRADLE_HOME=${2:-"/usr/local/share/gradle"}
GRADLE_VERSION=${1:-"lts"}
export SDKMAN_DIR=${2:-"/usr/local/sdkman"}
USERNAME=${3:-"vscode"}
GRADLE_DOWNLOAD_SHA=${4:-"no-check"}
UPDATE_RC=${4:-"true"}
set -e
if [ -d "${GRADLE_HOME}" ]; then
echo "Gradle already installed."
exit 0
fi
if [ -z "$1" ]; then
echo -e "Required argument missing.\n\ngradle-debian.sh <gradle version> [gradle home] [non-root-user] [gradle SHA 256]"
exit 1
# Blank will install latest maven version
if [ "${GRADLE_VERSION}" = "lts" ]; then
GRADLE_VERSION=""
fi
if [ "$(id -u)" -ne 0 ]; then
@ -33,30 +28,35 @@ if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi
# Install curl, unzip if missing
if ! dpkg -s curl ca-certificates unzip > /dev/null 2>&1; then
export DEBIAN_FRONTEND=noninteractive
function updaterc() {
if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="$1"
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
fi
fi
}
export DEBIAN_FRONTEND=noninteractive
# Install curl, zip, unzip if missing
if ! dpkg -s curl ca-certificates zip unzip sed > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends curl ca-certificates unzip
apt-get -y install --no-install-recommends curl ca-certificates zip unzip sed
fi
# Install sdkman if not installed
if [ ! -d "${SDKMAN_DIR}" ]; then
curl -sSL "https://get.sdkman.io?rcupdate=false" | bash
chown -R "${USERNAME}" "${SDKMAN_DIR}"
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
fi
# Install Gradle
echo "Downloading Gradle..."
su ${USERNAME} -c "$(cat << EOF
set -e
mkdir -p /tmp/downloads
curl -sSL --output /tmp/downloads/archive-gradle.zip https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
([ "${GRADLE_DOWNLOAD_SHA}" = "no-check" ] || echo "${GRADLE_DOWNLOAD_SHA} */tmp/downloads/archive-gradle.zip" | sha256sum --check - )
unzip -q /tmp/downloads/archive-gradle.zip -d /tmp/downloads/
EOF
)"
mv -f /tmp/downloads/gradle* ${GRADLE_HOME}
chown ${USERNAME}:root ${GRADLE_HOME}
ln -s ${GRADLE_HOME}/bin/gradle /usr/local/bin/gradle
rm -rf /tmp/downloads
# Install gradle
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install gradle ${GRADLE_VERSION}"
updaterc "export GRADLER_USER_HOME=\${HOME}/.gradle"
echo "Done!"

Просмотреть файл

@ -4,24 +4,18 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./java-debian.sh [JDK major version] [JAVA_HOME] [non-root user] [Add JAVA_HOME to rc files flag]
# Syntax: ./java-debian.sh [JDK version] [SDKMAN_DIR] [non-root user] [Add to rc files flag]
export JAVA_VERSION=${1:-"11"}
export JAVA_HOME=${2:-"/opt/java/openjdk-${JAVA_VERSION}"}
JAVA_VERSION=${1:-"lts"}
export SDKMAN_DIR=${2:-"/usr/local/sdkman"}
USERNAME=${3:-"vscode"}
UPDATE_RC=${4:-"true"}
set -e
JDK_11_URI="https://github.com/AdoptOpenJDK/openjdk11-upstream-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jdk_x64_linux_11.0.8_10.tar.gz"
JDK_8_URI="https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u265-b01/OpenJDK8U-jdk_x64_linux_8u265b01.tar.gz"
JAVA_URI_VAR="JDK_${JAVA_VERSION}_URI"
JAVA_URI=${!JAVA_URI_VAR}
if [ "${JAVA_URI}" = "" ]; then
echo 'Only Java versions 8 and 11 are supported by this script.'
exit 1
# Blank will install latest AdoptOpenJDK version
if [ "${JAVA_VERSION}" = "lts" ]; then
JAVA_VERSION=""
fi
if [ "$(id -u)" -ne 0 ]; then
@ -36,41 +30,30 @@ fi
export DEBIAN_FRONTEND=noninteractive
# Install curl if missing
if ! dpkg -s curl ca-certificates > /dev/null 2>&1; then
# Install curl, zip, unzip if missing
if ! dpkg -s curl ca-certificates zip unzip sed > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends curl ca-certificates
apt-get -y install --no-install-recommends curl ca-certificates zip unzip sed
fi
# Install Java
if [ -d "${JAVA_HOME}" ]; then
echo "${JAVA_HOME} already exists. Assuming Java is already installed."
exit 0
fi
mkdir -p "${JAVA_HOME}"
chown "${USERNAME}" "${JAVA_HOME}"
su ${USERNAME} -c "$(cat << EOF
set -e
echo "Downloading JDK ${JAVA_VERSION}..."
curl -fsSL -o /tmp/openjdk.tar.gz ${JAVA_URI}
echo "Installing JDK ${JAVA_VERSION}..."
tar -xzf /tmp/openjdk.tar.gz -C ${JAVA_HOME} --strip-components=1
rm -f /tmp/openjdk.tar.gz
EOF
)"
# Add JAVA_HOME and bin directory into bashrc/zshrc files (unless disabled)
if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="export JAVA_HOME=\"${JAVA_HOME}\"\nexport PATH=\"\${JAVA_HOME}/bin:\${PATH}\""
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc /home/${USERNAME}/.zshrc
# Install sdkman if not installed
if [ ! -d "${SDKMAN_DIR}" ]; then
curl -sSL "https://get.sdkman.io?rcupdate=false" | bash
chown -R "${USERNAME}" "${SDKMAN_DIR}"
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
fi
fi
fi
echo "Done!"
if [ "${JAVA_VERSION}" != "none" ]; then
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install java ${JAVA_VERSION}"
fi
echo "Done!"

Просмотреть файл

@ -4,23 +4,18 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------
# Syntax: ./maven-debian.sh <maven version> [maven home] [non-root user] [maven SHA 512]
# Syntax: ./maven-debian.sh [maven version] [SDKMAN_DIR] [non-root user] [Update rc files flag]
MAVEN_VERSION=$1
MAVEN_HOME=${2:-"/usr/local/share/maven"}
MAVEN_VERSION=${1:-"lts"}
export SDKMAN_DIR=${2:-"/usr/local/sdkman"}
USERNAME=${3:-"vscode"}
MAVEN_DOWNLOAD_SHA=${4:-"no-check"}
UPDATE_RC=${4:-"true"}
set -e
if [ -d "${MAVEN_HOME}" ]; then
echo "Maven already installed."
exit 0
fi
if [ -z "$1" ]; then
echo -e "Required argument missing.\n\nmaven-debian.sh <maven version> [maven home] [non-root user] [maven SHA 512]"
exit 1
# Blank will install latest maven version
if [ "${MAVEN_VERSION}" = "lts" ]; then
MAVEN_VERSION=""
fi
if [ "$(id -u)" -ne 0 ]; then
@ -33,34 +28,35 @@ if [ "${USERNAME}" = "none" ] || ! id -u ${USERNAME} > /dev/null 2>&1; then
USERNAME=root
fi
# Install curl, tar if missing
if ! dpkg -s curl ca-certificates tar > /dev/null 2>&1; then
export DEBIAN_FRONTEND=noninteractive
function updaterc() {
if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="$1"
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
fi
fi
}
export DEBIAN_FRONTEND=noninteractive
# Install curl, zip, unzip if missing
if ! dpkg -s curl ca-certificates zip unzip sed > /dev/null 2>&1; then
if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
apt-get update
fi
apt-get -y install --no-install-recommends curl ca-certificates tar
apt-get -y install --no-install-recommends curl ca-certificates zip unzip sed
fi
# Creat folder, add maven settings
mkdir -p ${MAVEN_HOME} ${MAVEN_HOME}/ref
tee ${MAVEN_HOME}/ref/maven-settings.xml > /dev/null \
<< EOF
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${MAVEN_HOME}/ref/repository</localRepository>
</settings>
EOF
chown -R ${USERNAME}:root ${MAVEN_HOME}
# Install sdkman if not installed
if [ ! -d "${SDKMAN_DIR}" ]; then
curl -sSL "https://get.sdkman.io?rcupdate=false" | bash
chown -R "${USERNAME}" "${SDKMAN_DIR}"
# Add sourcing of sdkman into bashrc/zshrc files (unless disabled)
updaterc "export SDKMAN_DIR=${SDKMAN_DIR}\nsource \${SDKMAN_DIR}/bin/sdkman-init.sh"
fi
# Install Maven
echo "Downloading Maven..."
su ${USERNAME} -c "$(cat << EOF
set -e
curl -fsSL -o /tmp/maven.tar.gz https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz
([ "${MAVEN_DOWNLOAD_SHA}" = "no-check" ] || echo "${MAVEN_DOWNLOAD_SHA} */tmp/maven.tar.gz" | sha512sum -c - )
tar -xzf /tmp/maven.tar.gz -C ${MAVEN_HOME} --strip-components=1
rm -f /tmp/maven.tar.gz
EOF
)"
ln -s ${MAVEN_HOME}/bin/mvn /usr/local/bin/mvn
echo "Done!"
su ${USERNAME} -c "source ${SDKMAN_DIR}/bin/sdkman-init.sh && sdk install maven ${MAVEN_VERSION}"
updaterc "export M2=\$HOME/.m2"
echo "Done!"

Просмотреть файл

@ -58,7 +58,7 @@ if [ "${UPDATE_RC}" = "true" ]; then
RC_SNIPPET="export CARGO_HOME=\"${CARGO_HOME}\"\nexport RUSTUP_HOME=\"${RUSTUP_HOME}\"\nexport PATH=\"\${CARGO_HOME}/bin:\${PATH}\""
echo -e ${RC_SNIPPET} | tee -a /root/.bashrc /root/.zshrc >> /etc/skel/.bashrc
if [ "${USERNAME}" != "root" ]; then
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc /home/${USERNAME}/.zshrc
echo -e ${RC_SNIPPET} | tee -a /home/${USERNAME}/.bashrc >> /home/${USERNAME}/.zshrc
fi
fi
echo "Done!"