Skip to content

Instantly share code, notes, and snippets.

@monkstone
Last active September 25, 2021 15:00
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/6ae9840d7b7008c177b4a9f589d14ec6 to your computer and use it in GitHub Desktop.
Save monkstone/6ae9840d7b7008c177b4a9f589d14ec6 to your computer and use it in GitHub Desktop.
Installer file for picrate-2.0
#!/usr/bin/env bash
# Bash Script to install PiCrate and dependencies on Raspbian Buster
JAVA_PATH="/usr/lib/jvm/java-11-openjdk-armhf"
JRUBY_VERSION="9.3.0.0
MRI_RUBY="2.6.0"
JRUBY_PATH="/opt/jruby-${JRUBY_VERSION}"
GEM_RC="${HOME}/.gemrc"
GEM="${HOME}/.gem/ruby/${MRI_RUBY}"
JDK_PROFILE="/etc/profile.d/jdk_home.sh"
JDK_STRING="export JAVA_HOME=\$(readlink -f /usr/bin/javac | sed \"s:/bin/javac::\")"
function gem_rc {
if [[ (-f ${GEM_RC}) ]]
then
cat "$GEM_RC"
else
touch "$GEM_RC"
echo "---" >> "$GEM_RC"
echo " gem: --no-document" >> "$GEM_RC"
fi
}
gem_rc
function java_home {
if [[ (-n ${JAVA_HOME}) ]]
then
echo "${JAVA_HOME}"
else
sudo touch "$JDK_PROFILE"
echo "${JDK_STRING}" | sudo tee -a "${JDK_PROFILE}"
fi
}
java_home
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"
}
wget_jruby
function install_jruby_links {
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_links
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