#!/bin/sh

#screen -wipe
#if ! screen -list | grep -q "BernhardFront"; then
    (
        cd BernhardFront/
#        screen -d -m -S BernhardFront python start.py
        python start.py &
    )
#fi

#if ! screen -list | grep -q "Bernhard01"; then
    (
        cd Bernhard01/
#        screen -d -m -S Bernhard01 python core.py
        python core.py &
    )
#fi

#if ! screen -list | grep -q "Bernhard02"; then
    (
        cd Bernhard02/
#        screen -d -m -S Bernhard02 python core.py
        python core.py &
    )
#fi

#if ! screen -list | grep -q "Bernhard03"; then
    (
        cd Bernhard03/
#        screen -d -m -S Bernhard03 python core.py
        python core.py &
    )
#fi

#if ! screen -list | grep -q "Bernhard04"; then
    (
        cd Bernhard04/
#        screen -d -m -S Bernhard04 python core.py
        python core.py &
    )
#fi

sleep 300

num=$(ps xa | grep core.py | grep -v grep | wc -l)
while [ $num -eq 4 ]; do
    echo "All 4 instances are running..."
    sleep 3600

    num=$(ps xa | grep core.py | grep -v grep | wc -l)
done
