Skip to content

Instantly share code, notes, and snippets.

@CrackerStealth
Last active November 7, 2015 11:50
Show Gist options
  • Save CrackerStealth/ae2d50d0f3452b80300d to your computer and use it in GitHub Desktop.
Save CrackerStealth/ae2d50d0f3452b80300d to your computer and use it in GitHub Desktop.
BASH Script to Patch OpenHAB Bluetooth Binding For Linux
#!/bin/sh
# Patch OpenHAB Bluetooth Binding For Linux
#
# Description: Patches the bluetooth binding compiled for OpenHAB with the
# libraries needed to run on Linux. You should change the path to Java below
# in the JAVA_BIN enviornmental variable.
#
# PLACE THIS SCRIPT IN AN EMPTY DIRECTORY WITH THE OPENHAB BLUETOOTH BINDING!
#
# Filename: patch_openhab_bluetooth.sh
#
# Usage: ./patch_openhab_bluetooth.sh org.openhab.binding.bluetooth-[VERSION].jar
# Setup enviornment variables
JAVA_BIN=/opt/jdk1.7.0_51/bin
BINDING_JAR=$1
# Command line parameter check
if [ -z "$BINDING_JAR" ]; then
echo "usage $0 org.openhab.binding.bluetooth-[VERSION].jar"
exit 1;
fi
# Extract and remove the bindings jar file
$JAVA_BIN/jar -xvf $BINDING_JAR
rm -f $BINDING_JAR
# Download the latest snapshot of the bluecove libraries into the lib folder
cd lib
rm -f bluecove-2.1.1-SNAPSHOT.jar
wget http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.63/bluecove-2.1.1-SNAPSHOT.jar
wget http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.63/bluecove-bluez-2.1.1-SNAPSHOT.jar
wget http://snapshot.bluecove.org/distribution/download/2.1.1-SNAPSHOT/2.1.1-SNAPSHOT.63/bluecove-gpl-2.1.1-SNAPSHOT.jar
cd ..
# Modify the Manifest file to know about the added libraries
cd META-INF
sed -i 's|.,lib/bluecove-2.1.1-SNAPSHOT.jar|.,lib/bluecove-gpl-2.1.1-SNAPSHOT.jar,lib/bluecove-bluez-2.1.1-SNAPSHOT.jar,lib/bluecove-2.1.1-SNAPSHOT.jar|g' MANIFEST.MF
cd ..
# Bundle the binding back up into a JAR file and remove source files
$JAVA_BIN/jar -cmf0 META-INF/MANIFEST.MF $BINDING_JAR lib META-INF org OSGI-INF
rm -rf ./lib ./META-INF ./org ./OSGI-INF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment