Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 51 additions & 41 deletions 92 installer.sh
Original file line number Diff line number Diff line change
@@ -1,63 +1,73 @@
#!/bin/bash
# A Bash script to install Linux Libraries used on EV3Dev-lang-java.
# Author: Juan Antonio Breña Moral, bren@juanantonio.info
# Author: Jakub Vaněk, linuxtardis@gmail.com

MODULE="unknown"
MODULE_FOLDER="module2"
ROOT_URL="https://raw.githubusercontent.com/ev3dev-lang-java/installer/develop/modules"

# $1 => module name
function download_module() {
pushd "./$MODULE_FOLDER" >/dev/null
wget -qN "$ROOT_URL/$1.sh"
popd >/dev/null
}

# $1 => module name
function run_module() {
MODULE="$1"
createHeader "$1"
download_module "$1"
source "$MODULE_FOLDER/$1.sh"
}

# $1 => module name
function inc_module() {
download_module "$1"
source "$MODULE_FOLDER/$1.sh"
}

function init_installer() {
echo "Init installer"
rm -rf "$MODULE_FOLDER"
mkdir -p "$MODULE_FOLDER"
}

echo
echo "##############################"
echo "# EV3Dev-lang-java Installer #"
echo "##############################"
echo "# Last update: 2018/03/30 #"
echo "# Last update: 2018/04/14 #"
echo "##############################"
echo

OFF=0
MODULE="EMPTY"
MODULE_FOLDER="module2"
function runModule(){
if ! [ "$2" == "$OFF" ]; then
createHeader $1
fi
local domain="https://raw.githubusercontent.com/ev3dev-lang-java/installer/develop/modules"
wget -N "$domain/$1.sh"
MODULE=$1
mv ./$1.sh ./$MODULE_FOLDER/$1.sh
source "$MODULE_FOLDER/$1.sh"
}

function initInstaller(){
echo "Init installer"
mkdir -p $MODULE_FOLDER
rm ./$MODULE_FOLDER/*
}
#Init
init_installer
inc_module vars
inc_module utilities

MODE_HELP="help"
MODE_JDK="jdk"
MODE_BATTERY_MONITOR="batteryMonitor"
MODE_COPY_INSTALLER="copy-installer"
MODE_EXTENDED="extended"
run_module platform

#Init
initInstaller
runModule utilities 0

if [ "$1" == "$MODE_HELP" ]; then
runModule help
fi
if [ "$1" == "help" ]; then
run_module help

if [ "$1" == "$MODE_COPY_INSTALLER" ]; then
CREDENTIAL=$2
runModule copy-installer
fi
elif [ "$1" == "copy-installer" ]; then
CREDENTIAL="$2"
run_module copy-installer

runModule platform
runModule java
elif [ "$1" == "batteryMonitor" ]; then
run_module java
run_module battery-monitor

if [ "$1" == "$MODE_BATTERY_MONITOR" ]; then
runModule battery-monitor
fi
elif [ "$1" == "extended" ]; then
run_module java
run_module native-libraries

if [ "$1" == "$MODE_EXTENDED" ]; then
runModule native-libraries
else
run_module java
fi

exit 0
61 changes: 23 additions & 38 deletions 61 modules/battery-monitor.sh
Original file line number Diff line number Diff line change
@@ -1,51 +1,36 @@
#!/bin/bash

function installBatteryMonitor() {
cd /home/robot
wget https://github.com/ev3dev-lang-java/batteryMonitor/raw/release/v0.2.0-RELEASE/releases/batteryMonitor-0.2.0-RELEASE.zip

#TODO Move block to function
isInstalled unzip
if [ "$INSTALLED" == "$INSTALLED_NO" ]; then
if [ "$PLATFORM" == "$EV3" ]; then

mkdir -p packages
cd packages
wget http://ftp.us.debian.org/debian/pool/main/u/unzip/unzip_6.0-16+deb8u3_armel.deb
sudo dpkg -i unzip_6.0-16+deb8u3_armel.deb
cd ..
else
apt-get install unzip
fi

fi

#TODO Move to a function
unzip batteryMonitor-0.2.0-RELEASE.zip
mv batteryMonitor-0.2.0-RELEASE batteryMonitor
cd batteryMonitor
chmod +x ./start.sh
chmod +x ./stop.sh
cp batteryMonitor-service.sh /etc/init.d
cd /etc/init.d
chmod +x batteryMonitor-service.sh
function battmon_install() {
wget "$BATTMON_URL" -O "$BATTMON_FILE"

apt-get install unzip

unzip "$BATTMON_FILE"
mv "$BATTMON_ZIPBASE" "$BATTMON_BASE"
chmod +x "$BATTMON_BASE/start.sh"
chmod +x "$BATTMON_BASE/stop.sh"
chmod +x "$BATTMON_BASE/batteryMonitor-service.sh"
ln -s "$BATTMON_BASE/batteryMonitor-service.sh" "/etc/init.d"

update-rc.d batteryMonitor-service.sh defaults
cd /home/robot/batteryMonitor
./start.sh &
"$BATTMON_BASE/start.sh" &
}

if [ "$PLATFORM" == "$UNKNOWN" ]; then
echo "This platform: $PLATFORM is not suitable for Battery Monitor."
echo
else
if [ "$PLATFORM" == "ev3" ] ||
[ "$PLATFORM" == "brickpi" ] ||
[ "$PLATFORM" == "brickpi3" ] ||
[ "$PLATFORM" == "pistorms" ]; then

if [ -d "/home/robot/batteryMonitor" ]; then
if [ -d "$BATTMON_BASE" ]; then
echo "We have detected a previous installation."
echo "We will skip this step."
else
installBatteryMonitor
battmon_install
fi

else
echo "This platform: $PLATFORM is not suitable for Battery Monitor."
echo
fi

createHeader "END $MODULE"
createHeader "END $MODULE"
14 changes: 7 additions & 7 deletions 14 modules/copy-installer.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash

if [ -e "/home/robot/installer/installer.sh" ]; then
echo $CREDENTIAL
ssh $CREDENTIAL 'uptime'
ssh $CREDENTIAL 'sudo mkdir /home/robot/installer/'
scp "/home/robot/installer/installer.sh" "$CREDENTIAL:/home/robot/installer"
ssh $CREDENTIAL 'sudo chmod +x /home/robot/installer.sh'
if [ -e "$INSTALLER_EXE" ]; then
chmod +x "$INSTALLER_EXE"

echo "SSHing to: $CREDENTIAL"
ssh "$CREDENTIAL" "uptime; sudo mkdir -p $INSTALLER_DIR"
scp "$INSTALLER_EXE" "$CREDENTIAL:$INSTALLER_DIR"
exit
else
echo "Sorry, the installer didn´t detect the installer"
echo "on /home/robot/installer"
echo "try to review your installation on your EV3 Brick."
echo
exit 1
fi
fi
10 changes: 5 additions & 5 deletions 10 modules/experimental/bluetooth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ echo "##############################"
echo ""

#2. Install Bluetooth
if [ "$PLATFORM" == "$EV3" ];
if [ "$PLATFORM" == "ev3" ];
then
echo $EV3
echo "EV3"
#isInstalled libbluetooth-dev
#wget http://ftp.us.debian.org/debian/pool/main/b/bluez/libbluetooth-dev_5.23-2+b1_armel.deb
#dpkg --force-depends-version -i libbluetooth-dev_5.23-2+b1_armel.deb
else
echo $BRICKPI
isInstalled libbluetooth-dev
echo "BrickPi"
isInstalled "$BT_BRICKPI_PKG"
#apt-get install libbluetooth-dev
fi
fi
91 changes: 63 additions & 28 deletions 91 modules/java.sh
Original file line number Diff line number Diff line change
@@ -1,49 +1,84 @@
#!/bin/bash

function installJavaForEV3() {
if [ ! -d /opt/jri-10-build-050 ]; then
wget https://github.com/ev3dev-lang-java/openjdk-ev3/releases/download/v0.5.0/jri10-ev3.tar.gz
tar -zxvf "/home/robot/installer/jri10-ev3.tar.gz" -C /opt
mv /opt/jri-ev3/ /opt/jri-10-build-050
update-alternatives --install /usr/bin/java java /opt/jri-10-build-050/bin/java 10
java -version
java -Xshare:dump
else

function java_install_bundle() {
if [ -d "$JAVA_PATH_NEW" ]; then
echo "Sorry, we detected a previous installation in path: /opt/jri-10-build-050"
echo
exit 1
fi

if [ ! -f "$JAVA_ZIP" ]; then
echo "Downloading new Java..."
wget "$JAVA_URL" -O "$JAVA_ZIP"
else
echo "Java archive found, using cached."
fi

# extract it, rename it and point the symlink to it
echo "Java package acquired, installing..."
tar -xf "$JAVA_ZIP" -C "$JAVA_OPT"
mv "$JAVA_PATH_ZIP" "$JAVA_PATH_NEW"
update-alternatives --install /usr/bin/java java "$JAVA_EXE" 1

JAVA_REAL_EXE="$JAVA_EXE"
}

#TODO Upgrade this function with the support of OpenJDK 10
function installJavaForBrickPi() {
apt-key adv --recv-key --keyserver keyserver.ubuntu.com EEA14886
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | sudo tee -a /etc/apt/sources.list
function java_install_ppa() {
###
# Add Debian Buster repo to Stretch

# prevent distro upgrade
cat >/etc/apt/preferences.d/jdk <<EOF
Package: *
Pin: release a=stable
Pin-Priority: 200

Package: *
Pin: release a=testing
Pin-Priority: 100
EOF
# workaround for cyclic dependency
ln -sf "$JDEB_TMP_LINK" "/usr/bin/java"

# add repo, update
echo "$JDEB_REPO" | sudo tee "/etc/apt/sources.list.d/jdk.list"
apt-get update
apt-get install --yes --no-install-recommends oracle-java8-installer
java -Xshare:dump

#Review in the future how to accept licence automatically
#https://askubuntu.com/questions/190582/installing-java-automatically-with-silent-option
# install package
# (the symlink above gets discarded, but
# it is needed during the installation)
apt-get install --yes --no-install-recommends "$JDEB_PKG"

JAVA_REAL_EXE="$(which java)"
}

#1. Detect Java
#1.1 Install Java
#1.2 Create JAVA_HOME PENDING

if type -p java; then
echo "Found java executable in PATH"
java -version
JAVA_REAL_EXE="$(which java)"

elif [[ -n "$JAVA_HOME" ]] && [[ -x "$JAVA_HOME/bin/java" ]]; then
echo "Found java executable in JAVA_HOME"
JAVA_REAL_EXE="$JAVA_HOME/bin/java"

else
echo "No java detected"

if [ "$PLATFORM" == "$EV3" ]; then
installJavaForEV3
elif [ "$PLATFORM" == "$BRICKPI" ]; then
installJavaForBrickPi
elif [ "$PLATFORM" == "$BRICKPI3" ]; then
installJavaForBrickPi
elif [ "$PLATFORM" == "$PISTORMS" ]; then
installJavaForBrickPi
if [ "$PLATFORM" == "ev3" ]; then
java_install_bundle
elif [ "$PLATFORM" == "brickpi" ] ||
[ "$PLATFORM" == "brickpi3" ] ||
[ "$PLATFORM" == "pistorms" ]; then
java_install_ppa
fi
fi
fi

echo "Installation complete. Java version:"
"$JAVA_REAL_EXE" -version

echo "Dumping class cache..."
"$JAVA_REAL_EXE" -Xshare:dump
23 changes: 14 additions & 9 deletions 23 modules/native-libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,24 @@

#This installation is the same for EV3 Brick & BrickPi/PiStorms

if [ "$PLATFORM" == "$UNKNOWN" ]; then
echo "This platform: $PLATFORM is not suitable for Battery Monitor."
echo
else
if [ "$PLATFORM" == "ev3" ] ||
[ "$PLATFORM" == "brickpi" ] ||
[ "$PLATFORM" == "brickpi3" ] ||
[ "$PLATFORM" == "pistorms" ]; then

apt-get update
isInstalled libopencv2.4-java
if [ "$INSTALLED" == "$INSTALLED_NO" ]; then

if [ "$(isInstalled libopencv2.4-java)" == "no" ]; then
apt-get install --yes --no-install-recommends libopencv2.4-java
fi
isInstalled librxtx-java
if [ "$INSTALLED" == "$INSTALLED_NO" ]; then

if [ "$(isInstalled librxtx-java)" == "no" ]; then
apt-get install --yes --no-install-recommends librxtx-java
fi

else
echo "This platform: $PLATFORM is not suitable for Battery Monitor."
echo
fi

createHeader "END $MODULE"
createHeader "END $MODULE"
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.