#!/bin/sh
#
#

if [ "$1" = "" ]
 then
  BASE=/applications/assp;
 else
  BASE=$1;
fi
export BASE
pidfile=$BASE/pid


if [ `cat $pidfile`  ]
	then 
	echo "Stopping ASSP with PID `cat $pidfile` in $BASE"
	password=$BASE/password.txt
	echo `cat $password` | sudo -S kill -TERM `cat $pidfile`
fi

sleep 10

echo "Restarting ASSP Anti-SPAM Proxy server in $BASE"

echo `cat $password` | sudo -S perl $BASE/assp.pl $BASE

if [ `cat $pidfile`  ]
	then 
	echo "ASSP is running with PID `cat $pidfile`"
fi
