#!/bin/sh
#
# Author: Michael Conrad <do5mc at aprs4r.org>
#

if [ -z "$APRS4R_LIB" ]; then
  APRS4R_LIB=/usr/lib/ruby/site_ruby/1.9
fi

if [ -z "$APRS4R_LOG" ]; then
  APRS4R_LOG=/var/log/aprs4r
fi

if [ -z "$APRS4R_LOCK" ]; then
  APRS4R_LOCK=/var/lock/aprs4r
fi

# create aprs4r lock file 
/bin/touch $APRS4R_LOCK

# create aprs4r log directory
/bin/mkdir -p $APRS4R_LOG

# limit virtual memory 
if [ ! -z "$APRS4R_ULIMIT" ]; then 
  ulimit -v $APRS4R_ULIMIT
fi

/usr/bin/ruby $APRS4R_LIB/aprs4r.rb $1 >> $APRS4R_LOG/aprs4r-stdout.log 2>> $APRS4R_LOG/aprs4r-stderr.log
