#!/bin/sh

[ -d opt ] && rm -rf opt;  mkdir -p opt

[ -d opt/flarmradar ] || mkdir -p opt/flarmradar
tar -xzf ../../jboss-as-7.1.1.Final.tar.gz -C opt/flarmradar && mv opt/flarmradar/jboss-as-7.1.1.Final opt/flarmradar/server
cp ../../jboss_standalone.xml opt/flarmradar/server/standalone/configuration/standalone.xml
cp ../../flarmradar.sh opt/flarmradar/flarmradar.sh
cp ../../h2.server.properties opt/flarmradar/.h2.server.properties

[ -f ../../../assembly/target/flarmradar.ear ] || ( echo "Missing build artifact 'flarmradar.ear', build the project first" && exit 1 )
cp ../../../assembly/target/flarmradar.ear opt/flarmradar/server/standalone/deployments/flarmradar.ear

[ -d opt/flarmradar/data ] || mkdir opt/flarmradar/data

[ `which equivs-build` ] || ( echo "Missing 'equivs-build', install package equivs first" && exit 1 )
equivs-build flarmradar

exit 0
