#!/bin/sh

if [ $# != 2 ]; then
    echo "usage: $0 svc dir"
    exit 1
fi

svc=$1
dir=$2

chdir $dir || exit 1

for i in env/*; do
    v=`basename $i`
    c=`cat $i`
    eval "$v=$c; export $v"
done

UID=@l_ruid@
GID=@l_rgid@
export UID GID

in=/dev/null
out=/dev/null

if [ -f seed ]; then
    in='seed';
fi

$svc <$in >$out 2>&1 &

echo $!
