#!/bin/bash

PREFIX="/"

for dir in \
    "$PREFIX"\
    "$PREFIX/opt"\
    "$PREFIX/opt/opengnsys"\
    "$PREFIX/opt/opengnsys/bin"\
    "$PREFIX/opt/opengnsys/engine"\
    "$PREFIX/opt/opengnsys/log"
do
    [ -d "$dir" ] || (sudo mkdir $dir && sudo chown $(whoami):$(whoami) $dir && echo "Creating dir: $dir")
done


echo "Getting the new engine"
[ -d $SVN_DIR ] && sudo rm -rf $SVN_DIR
svn export -q $SVN_URL/branches/version2 $SVN_DIR/engine

echo "Copying ogr"
cp -rf $SVN_DIR/ogr/ogr $PREFIX/opt/opengnsys/bin

echo "Coping libogr"
cp -rf $SVN_DIR/ogr/libogr.py $PREFIX/opt/opengnsys/lib/python

echo "Copying runtest"
cp -rf $SVN_DIR/runtest/runtest.py $PREFIX/opt/opengnsys/bin

echo "Copying engine"
cp -rf $SVN_DIR/engine/* $PREFIX/opt/opengnsys/engine

echo "Copying new client_daemon"
cp -rf $SVN_DIR/client_daemon/client_daemon.py $PREFIX/opt/opengnsys/bin
