Last active
October 29, 2019 20:06
-
-
Save monkstone/e9df8ea776aed58ce1c4de8e12982aad to your computer and use it in GitHub Desktop.
Script to install picrate on raspberrypi
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 | |
JRVERSION="9.2.8.0" | |
MRI_RUBY="2.5.0" | |
GEM="${HOME}/.gem/ruby/${MRI_RUBY}" | |
JDK_VERSION="8" | |
function install_jruby { | |
echo "installing jruby please wait" | |
if [ ! -f "jruby-dist-${JRVERSION}-bin.tar.gz" ]; then | |
wget "https://repo1.maven.org/maven2/org/jruby/jruby-dist/${JRVERSION}/jruby-dist-${JRVERSION}-bin.tar.gz" | |
fi | |
if [[ "$?" != 0 ]]; then | |
echo "JRuby-${JRVERSION} Download failed" | |
else | |
CWD=$PWD # remember current directory | |
cd /opt | |
sudo tar xzvf "$CWD/jruby-dist-${JRVERSION}-bin.tar.gz" | |
cd "$CWD" | |
fi | |
sudo update-alternatives --install /usr/bin/jruby jruby /opt/jruby-${JRVERSION}/bin/jruby 100 | |
sudo update-alternatives --install /usr/bin/jgem jgem /opt/jruby-${JRVERSION}/bin/jgem 100 | |
sudo update-alternatives --install /usr/bin/jirb jirb /opt/jruby-${JRVERSION}/bin/jirb 100 | |
} | |
function check_jruby { | |
if [ ! -d "/opt/jruby-${JRVERSION}" ]; then | |
install_jruby | |
else | |
echo "jruby ${JRVERSION} already installed" | |
fi | |
} | |
check_jruby | |
function set_gem_home { | |
mkdir -p ${GEM} | |
echo "export JAVA_HOME=\"/usr/lib/java-${JDK_VERSION}-openjdk-armhf\"" >> ~/.profile | |
echo "export GEM_HOME=\"\${HOME}/.gem/ruby/${MRI_RUBY}\"" >> ~/.profile | |
echo "export GEM_PATH=\"\${HOME}/.gem/ruby/${MRI_RUBY}\"" >> ~/.profile | |
echo "export PATH=\"\${PATH}:\${GEM_PATH}/bin\"" >> ~/.profile | |
echo "gem: --no-document" >> ~/.gemrc | |
source ~/.profile | |
} | |
function check_gemhome { | |
if [[ ! -d ${GEM} ]]; then | |
set_gem_home | |
else | |
echo "Gem home already set" | |
fi | |
} | |
check_gemhome | |
function install_picrate { | |
echo "installing examples please wait" | |
source "${HOME}/.profile" | |
jgem install picrate -v 1.2.1 | |
picrate -i samples | |
} | |
install_picrate | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment