#! /bin/sh -e

service nginx status > /dev/null && service nginx reload || service nginx start
service elasticsearch status > /dev/null || service elasticsearch start
service rabbitmq-server status > /dev/null || service rabbitmq-server start
service redis-server status > /dev/null || service redis-server start

# This support mongodb-org repositories where applicable or Debian's built-in mongodb
# Too bad services are different, too bad Mongo does not have stretch packages...
if [ `dpkg -l | grep -c mongodb-org` -gt 0 ]
then
    service mongod status > /dev/null || service mongod start
else
    service mongodb status > /dev/null || service mongodb start
fi

systemctl daemon-reload
systemctl enable openpaas
systemctl start openpaas
