#!/bin/sh
#
# Install all files given on the cmd line using
# felix:install -s $(readlink -f $file)
#

SSHPORT=$(cat /etc/osgi-runner/conf.d/gogo-ssh.properties | egrep '^\s*gogo\.ssh\.port\s*=' |cut -f2 -d'=' |tr -d ' ' |tr -d '\r')

if [ -z "$SSHPORT" ] ; then
  echo "FATAL: Unable to detect sshPort setting in /etc/osgi-runner/conf.d/gogo-ssh.properties"
  exit 1
fi

absfiles=

for file in $*
do
	if echo $file | grep -q '^file://'
	then
		absfile=$file
	else
		absfile='file://'$(readlink -f $file)
	fi
	absfiles=${absfiles:+$absfiles }$absfile
done

ssh -p $SSHPORT localhost extras:install -s -r -w $absfiles
