#!/bin/bash

#Install rest server
echo "Installing rest server and dependencies"
cd RestServer
./installscript.sh
make
make install
cd ..

#Install apache2 and dependencies
echo "Installing apache2 and php dependencies"
sudo apt install php7.0 php7.0-curl php7.0-gd php7.0-intl php7.0-mbstring php7.0-mcrypt php7.0-bz2 php7.0-cli php7.0-json php7.0-mysql php7.0-opcache php7.0-readline php7.0-xml php7.0-zip

echo "Configuring apache"
#Disable default apache config
sudo a2dissite 000-default.conf

#Copy and enable Apache Configs
cd Configs
sudo cp laravel.conf /etc/apache2/sites-available
sudo a2ensite laravel.conf

#Rewrite aktivieren
sudo a2enmod rewrite

#Service neustarten
sudo service apache2 restart
cd ..

#Laravel files
echo "Copying laravel files"
sudo cp -r Laravel/* /var/www/html/
echo "Please create a .env File in /var/www/html"

#init.d script
echo "Copying init.d script"
sudo cp Configs/humidityserver /etc/init.d/
