#!/bin/sh
SERVICE1='php7.0-fpm'
SERVICE2='apache2'

echo "env[MYSQL_DATABASE]= $MYSQL_DATABASE">> /etc/php/7.0/fpm/pool.d/www.conf
echo "env[MYSQL_USER]= $MYSQL_USER">> /etc/php/7.0/fpm/pool.d/www.conf
echo "env[MYSQL_PASSWORD]= $MYSQL_PASSWORD">> /etc/php/7.0/fpm/pool.d/www.conf
echo "env[MYSQL_HOST]= $MYSQL_HOST">> /etc/php/7.0/fpm/pool.d/www.conf

chown $myuser:$mygroup -R /var/www/html

if (( $(ps -ef | grep -v grep | grep $SERVICE1 | wc -l) > 0 ))
then
echo "$SERVICE1 is running!!!"
else
    echo "starting $SERVICE1"
    service $SERVICE1 start
fi


if (( $(ps -ef | grep -v grep | grep $SERVICE2 | wc -l) > 0 ))
then
echo "$SERVICE2 is running!!!"
else
    echo "starting $SERVICE2"
    service $SERVICE2 start
fi

tail -f /error.log