#!/bin/sh

prefix=/usr
exec_prefix=/usr
libdir=/usr/lib
datarootdir=${prefix}/share
datadir=/usr/share

# Wait for Techne to get up and running.

echo "Waiting for Techne..."

while [ -z "$(netstat -ln -A inet | tail -n +3 | awk '{print $4}' | grep ':29176')" ]; do
    sleep 1
done

# Launch the browser.

${libdir}/techne/browser.bin http://localhost:29176 &

# Wait for Techne to stop listening and suicide.

while [ "$(netstat -ln -A inet | tail -n +3 | awk '{print $4}' | grep ':29176')" ]; do
    sleep 1
done

kill $!
