Last active
April 12, 2022 14:09
-
-
Save delabassee/a11e09dcf5a85dae87a5fd6a96ce77ea to your computer and use it in GitHub Desktop.
0DL: Using OCI to Build a Java Application - VM setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##!/bin/bash | |
# Last update: | |
# 09/14 - source .path (javap) | |
# 09/11 - conf. nano to show line numbers | |
# 09/10 - small typo, Heldion default config, javap | |
# 09/02 - updated Helidon CLI URL from 2.0.2 to 2.1.0 | |
# 08/29 - added nano XML support | |
# 20/01/21 - updated Helidon CLI URL from 2.1.2, OpenJDK to 15.0.2 | |
# 01/02/21 - updated OpenJDK to JDK 16b34 | |
# 05/02/21 - updated OpenJDK to JDK 16b35 - RC1 | |
# 08/02/21 - + rpm-build for jpackage + typos | |
# 13/02/21 - updated OpenJDK to JDK 16b36 - RC2 | |
# 21/03/21 - added `astyle` for simple formatting | |
# 13/02/21 - updated OpenJDK to JDK 16b36 - RC2 | |
# Fix OEL 'setlocale: LC_CTYPE: cannot change locale' warning | |
# 01/09/21 - updated for JDK 17, bumped Helidon CLI and Maven | |
# 01/09/21 - downgrading Mvn from 3.8.2 to 3.6.3 while waiting for Helidon CLI 2.2.2 | |
# 21/11/21 switching to Oracle JDK (X64) | |
# 01/04/22 JDK 18 GA | |
# 12/04/22 HTML Snippet | |
# 12/04/22 Support for Arch64 builds | |
sudo -s eval 'printf 'LANG=en_US.utf-8\nLC_ALL=en_US.utf-8\n' > /etc/environment' | |
#JDK_URL="https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz" | |
JDK_URL_x64="https://download.java.net/java/GA/jdk18/43f95e8614114aeaa8e8a5fcf20a682d/36/GPL/openjdk-18_linux-x64_bin.tar.gz" | |
JDK_URL_Arch64="https://download.java.net/java/GA/jdk18/43f95e8614114aeaa8e8a5fcf20a682d/36/GPL/openjdk-18_linux-aarch64_bin.tar.gz" | |
MAVEN_URL="https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz" | |
#MAVEN_URL="https://downloads.apache.org/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz" | |
#HELIDON_URL="https://github.com/oracle/helidon-build-tools/releases/download/2.1.2/helidon-cli-linux-amd64" | |
HELIDON_URL="https://helidon.io/cli/latest/linux/helidon" | |
BAT_URL="https://github.com/sharkdp/bat/releases/download/v0.15.4/bat-v0.15.4-x86_64-unknown-linux-musl.tar.gz" | |
export ARCH="$(uname -m)" | |
echo $ARCH | |
if [[ "$ARCH" == "aarch64" ]]; then | |
echo "Architecture: aarch64" | |
export JDK_URL=$JDK_URL_Arch64 | |
else | |
echo "Architecture: x86_64" | |
export JDK_URL=$JDK_URL_x64 | |
fi | |
echo $'\n*** URLs ***\n' | |
echo "-> $JDK_URL" | |
echo "-> $MAVEN_URL" | |
echo "-> $HELIDON_URL" | |
echo $'\n*** Installing git, tree, bat... ***\n' | |
sudo yum -y install git tree rpm-build | |
mkdir -p $HOME/soft && curl -L $BAT_URL --output $HOME/soft/bat.tar.gz | |
mkdir -p $HOME/soft/bat && tar -xzvf $HOME/soft/bat.tar.gz -C $HOME/soft/bat --strip-components=1 | |
export PATH=$HOME/soft/bat:$PATH | |
echo $'\n*** Installing astyle... ***\n' | |
mkdir -p $HOME/soft/bin | |
wget https://delabassee.com/resources/tools/astyle -O $HOME/soft/bin/astyle && chmod +x $HOME/soft/bin/astyle | |
export PATH=$HOME/soft/bin:$PATH | |
echo $'\n*** Installing JDK... ***\n' | |
cd $HOME/soft && curl $JDK_URL --output $HOME/soft/jdk.tar.gz | |
mkdir $HOME/soft/jdk && tar -xzvf $HOME/soft/jdk.tar.gz --directory /$HOME/soft/jdk --strip 1 | |
sudo update-alternatives --install "/usr/bin/java" "java" "$HOME/soft/jdk/bin/java" 1 | |
sudo update-alternatives --install "/usr/bin/javac" "javac" "$HOME/soft/jdk/bin/javac" 1 | |
export JAVA_HOME=$HOME/soft/jdk | |
echo "JAVA_HOME=$HOME/soft/jdk" >> $HOME/.bash_profile | |
java -version | |
echo $'\n*** Installing Maven... ***\n' | |
curl $MAVEN_URL --output $HOME/soft/maven.gz | |
cd ~/soft && tar -xzvf maven.gz | |
export PATH=$HOME/soft/apache-maven-3.6.3/bin:$PATH | |
echo $'\n*** Installing Helidon CLI... ***\n' | |
curl -L $HELIDON_URL --output $HOME/soft/helidon && chmod +x $HOME/soft/helidon | |
export PATH=$HOME/soft:$PATH | |
cd $HOME | |
echo $'\n*** Configuring firewall for port 8080... ***\n' | |
sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent | |
sudo firewall-cmd --reload | |
# Set path | |
echo "PATH=$HOME/soft/bat:$HOME/soft/apache-maven-3.6.3/bin:$HOME/soft:$HOME/soft/jdk/bin/:$PATH" >> $HOME/.path | |
source .path | |
echo "source $HOME/.path" >> $HOME/.bash_profile | |
echo '<!DOCTYPE html><html><head><title>OCI</title></head><body>It works!</body></html>' > index.html | |
# Helidon default config | |
helidon version | |
sed -i 's/project.name=${init_archetype}-${init_flavor}/project.name=java-devlive/' ~/.helidon/config | |
sed -i 's/group.id=me.${user.name}-helidon/group.id=hol/' ~/.helidon/config | |
sed -i 's/artifact.id=${init_archetype}-${init_flavor}/artifact.id=demo/' ~/.helidon/config | |
sed -i 's/package.name=me.${user.name}.${init_flavor}.${init_archetype}/package.name=com.devlive/' ~/.helidon/config | |
# Nano's Java syntax highlighting & line numbers | |
echo "include /usr/share/nano/java.nanorc" >>$HOME/.nanorc | |
echo "include /usr/share/nano/xml.nanorc" >>$HOME/.nanorc | |
echo "set const" >>$HOME/.nanorc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment