#!/bin/bash

DAEMONS_COUNT=1
RESULT=$(ps aux | grep "[a]ny2txt.jar" -c )

if [ $RESULT -lt $DAEMONS_COUNT ] ; then
        echo "any2txt is offline! Restarting..." | mail -s "any2txt crash" "tomasz.walkowiak@pwr.edu.pl"
        COUNTER=$RESULT
        while [ $COUNTER -lt $DAEMONS_COUNT ]; do
                cd /home/tomekw/any2txt
                exec java -jar any2txt.jar &
                cd /usr/share/webmin/cron/
                let COUNTER+=1
        done
fi

