Skip to content

Instantly share code, notes, and snippets.

@monkstone
Last active June 20, 2021 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monkstone/04a1272ca9274a2c7e3e1bf170877bfb to your computer and use it in GitHub Desktop.
Save monkstone/04a1272ca9274a2c7e3e1bf170877bfb to your computer and use it in GitHub Desktop.
Complete installer for PiCrate (on Buster Raspbian) including jdk and jruby dependencies
#!/usr/bin/env bash
# Bash Script to install PiCrate and dependencies on Raspbian Buster
# JAVA_PATH="/opt/jdk13"
JAVA_PATH="/usr/lib/jvm/java-11-openjdk-armhf"
# JAVA_PATH="/usr/lib/jvm/java-11-openjdk-armhf"
JRUBY_VERSION="9.2.19.0"
MRI_RUBY="2.5.0"
JRUBY_PATH="/opt/jruby-${JRUBY_VERSION}"
GEM="${HOME}/.gem/ruby/${MRI_RUBY}"
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-8"
sudo apt-get install openjdk-8-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 "export JAVA_HOME=${JAVA_PATH}" >> "${HOME}/.profile"
export JAVA_HOME="${JAVA_PATH}"
sudo ${JRUBY_PATH}/bin/jgem install jruby-launcher
echo "Installed JRuby launcher"
sync
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 install_picrate {
export GEM_HOME="${GEM}"
export PATH="${GEM}"/bin:"${PATH}"
jgem install rake
jgem install picrate
}
install_picrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment