Last active
September 26, 2021 07:55
-
-
Save monkstone/e691abd48777e261652ac8107728fb00 to your computer and use it in GitHub Desktop.
Auto Installer for picrate-2.5.0
This file contains hidden or 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
#!/usr/bin/env bash | |
# Bash Script to install PiCrate and dependencies on Raspbian Buster | |
# JAVA_PATH="/opt/jdk13" | |
# JAVA_PATH="/usr/lib/jvm/java-8-openjdk-armhf" | |
JAVA_PATH="/usr/lib/jvm/java-11-openjdk-armhf" | |
JRUBY_VERSION="9.0.0.0" | |
MRI="2.5.0" | |
JRUBY_PATH="/opt/jruby-${JRUBY_VERSION}" | |
GEM="${HOME}/.gem/ruby/${MRI}" | |
GEMRC="${HOME}/.gemrc" | |
PROFILD="/etc/profile.d/jdk_home.sh" | |
JHOME="export JAVA_HOME=\$(readlink -f /usr/bin/javac | sed \"s:/bin/javac::\")" | |
function install_java { | |
if [ -x "$(command -v java)" ] | |
then | |
java -version | |
else | |
local commands=(update upgrade) | |
for cmd in "${commands[@]}" | |
do # update before install | |
sudo apt-get "${cmd}" | |
done | |
echo "Installing openjdk-11" | |
sudo apt-get install openjdk-11-jdk | |
fi | |
} | |
install_java | |
function wget_jruby { | |
wget "https://repo1.maven.org/maven2/org/jruby/jruby-dist/${JRUBY_VERSION}/jruby-dist-${JRUBY_VERSION}-bin.tar.gz" | |
sudo tar xzvf "${HOME}/jruby-dist-${JRUBY_VERSION}-bin.tar.gz" -C /opt | |
echo "Downloaded JRuby" | |
if [[ (-n ${JAVA_HOME}) ]] | |
then | |
echo "JAVA_HOME=${JAVA_HOME}" | |
else | |
echo "Run attached script.sh as follows" | |
echo "sudo bash script.sh" | |
fi | |
} | |
wget_jruby | |
function install_jruby { | |
local commands=(jruby jgem jirb) | |
for cmd in "${commands[@]}" | |
do | |
sudo update-alternatives --install /usr/bin/"${cmd}" "${cmd}" "${JRUBY_PATH}/bin/${cmd}" 100 | |
done | |
} | |
install_jruby | |
function create_gem_home { | |
if [[ (-n ${GEM_HOME}) ]] | |
then | |
echo "GEM_HOME=${GEM_HOME}" | |
else | |
mkdir -p "${GEM}" | |
commands=( | |
"GEM_HOME=${GEM}" | |
"GEM_PATH=${GEM}" | |
"PATH=\"\${GEM_PATH}/bin:\${PATH}\"" | |
) | |
for cmd in "${commands[@]}" | |
do | |
echo "export ${cmd}" >> ~/.profile | |
done | |
fi | |
} | |
create_gem_home | |
function no_docs { | |
if [[ (-f ${GEMRC}) ]] | |
then | |
cat "${GEMRC}" | |
else | |
touch "${GEMRC}" | |
echo "gem: --no-document" >> "${GEMRC}" | |
fi | |
} | |
no_docs | |
function install_picrate { | |
export GEM_HOME="${GEM}" | |
export PATH="${GEM}"/bin:"${PATH}" | |
jgem install rake | |
jgem install picrate | |
} | |
install_picrate |
This file contains hidden or 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
# run this script with sudo | |
PROFILD="/etc/profile.d/jdk_home.sh" | |
JHOME="export JAVA_HOME=\$(readlink -f /usr/bin/javac | sed \"s:/bin/javac::\")" | |
echo "Setting JAVA_HOME automagically on next boot" | |
sudo touch "${PROFILD}" | |
sudo echo "${JHOME}" > "${PROFILD}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment