#!/bin/bash
set -e

# test if apache-conf already installed
if [ -e /etc/apache2/sites-enabled/sysal_stub.conf ]
then
	exit
fi

mkdir -p /var/test
chmod 777 /var/test

cwd=$(pwd)
# write apache conf
echo "# Apache conf for sysal stub
Alias /sysal/rest/AlarmInterface/RemoteWatchdog $cwd/bin/sysal-stub.pl
<Directory $cwd/bin>
       Require all granted
       Options +ExecCGI
       AddHandler cgi-script .pl
</Directory>
" > /etc/apache2/sites-available/sysal_stub.conf
a2ensite sysal_stub
a2enmod cgi

systemctl restart apache2

