#!/bin/bash

# Astmanproxy doesn't behave completely as init.d expects a daemon
# to behave so we needt this wrapper for when init.d starts astmanproxy
# DO NOT CALL THIS SCRIPT DIRECTLY. Only use 'service astmanproxy ...'

LOG=/tmp/astmanproxy.start

function cleanup()
{
    rm -f $LOG
    exit $1
}

/usr/sbin/astmanproxy 2> $LOG || cleanup 1
cat $LOG | egrep -i "^abort|^cannot|^unable" > /dev/null && cleanup 1
cleanup 0

