#!/bin/bash

path=/opt/albert.dist/

echo "### Creating base directories..."
mkdir -p bin libexec modules Databases cgi-bin

echo "### Copying base files..."
cp -P $path/Albert/bin/* ./bin/
cp -P $path/Albert/libexec/* ./libexec/
cp -P $path/Albert/modules/* ./modules
cp -P $path/Apache/cgi-bin/alb/alb* ./bin/
cp -P $path/Apache/cgi-bin/alb/secure/alb* ./bin/
cp -R $path/Databases .
cp -R $path/Albert/nodejs .
cp -R $path/Apache/cgi-bin/alb/* cgi-bin/
chmod -R 755 Databases
chmod -R 755 nodejs
mkdir -p sites

echo "### Creating CGI symlinks..."
cd cgi-bin
ln -s albExpander albExpander.cgi
ln -s albQuery albQuery.cgi
ln -s albSearcher albSearcher.cgi
ln -s secure/albSync albSync.cgi
ln -s albSync secure/albSync.cgi
