#!/bin/bash

cd "`dirname "$0"`/../../"
if [ -e pid.txt ]; then
	PID=`cat pid.txt`
	if ps ax | grep $PID | grep -q freepopsd; then
		kill $PID
		Contents/MacOS/fmessage 'FreePOPs stopped.'
		exit 0
	fi
	rm -f pid.txt
fi
	
src/freepopsd.* -b 127.0.0.1 &

echo $! > pid.txt
if [ ! -e no_startup_message ]; then
	Contents/MacOS/fmessage -b 'Do not show me this message again' \
		'FreePOPs started. To stop it, double click again.' 
	rc=$?
	if [ $rc = 4 ]; then
		touch no_startup_message
	fi
fi

# eof
