#!/bin/sh

SCRIPT=$(readlink -f "$0")
DISTRPATH=$(dirname "$SCRIPT")

mkdir -p /opt/VideoGrace/Server/
mkdir -p /opt/VideoGrace/Server/bin
mkdir -p /opt/VideoGrace/Server/img
mkdir -p /opt/VideoGrace/Server/template
mkdir -p /opt/VideoGrace/Server/js
mkdir -p /opt/VideoGrace/Server/db
mkdir -p /opt/VideoGrace/Server/doc
mkdir -p /opt/VideoGrace/Server/locale
cp -n $DISTRPATH/vgserver/vgserver.conf /opt/VideoGrace/Server/
cp $DISTRPATH/vgserver/VideoGraceServer /opt/VideoGrace/Server/
cp $DISTRPATH/vgserver/Recorder /opt/VideoGrace/Server/
chmod +x /opt/VideoGrace/Server/VideoGraceServer
chmod +x /opt/VideoGrace/Server/Recorder
cp $DISTRPATH/vgserver/bin/* /opt/VideoGrace/Server/bin/
cp $DISTRPATH/vgserver/template/* /opt/VideoGrace/Server/template/
cp $DISTRPATH/vgserver/js/* /opt/VideoGrace/Server/js/
cp $DISTRPATH/vgserver/img/* /opt/VideoGrace/Server/img/
cp -n $DISTRPATH/vgserver/db/* /opt/VideoGrace/Server/db
cp $DISTRPATH/vgserver/doc/* /opt/VideoGrace/Server/doc/
cp $DISTRPATH/vgserver/locale/* /opt/VideoGrace/Server/locale/
chmod 777 /opt/VideoGrace/Server/db
chmod 777 /opt/VideoGrace/Server/db/main.db
mkdir -p /var/log/vgserver
chmod 777 /var/log/vgserver
