#!/bin/sh
FUSE_VERSION=7.2.0.fuse-720029
FUSE_VERSION=7.1.0.fuse-710023-redhat-00001
FUSE_HOME=~/Downloads/fuse-karaf-$FUSE_VERSION

echo "INFO: $FUSE_HOME/bin/start"
$FUSE_HOME/bin/start && sleep 5

echo "feature:install camel-atom" > /tmp/install-correct-feature.cli
echo "feature:install camel-foo" > /tmp/install-incorrect-feature.cli

if [ $FUSE_HOME/bin/client -f /tmp/install-correct-feature.cli &>/dev/null ]; then
	echo "FAILURE: installing a correct feature returned non-zero exit code"
	$FUSE_HOME/bin/stop && sleep 5
	exit 1
fi
	 
if $FUSE_HOME/bin/client -f /tmp/install-incorrect-feature.cli &>/dev/null; then
	echo "FAILURE: installing an incorrect feature returned zero exit code"
	$FUSE_HOME/bin/stop && sleep 5
	exit 1
fi

echo "INFO: $FUSE_HOME/bin/stop"
$FUSE_HOME/bin/stop && sleep 5
