#!/bin/bash

set -Eeo pipefail
if ! [ "$(ls -A "/opt/VideoGrace/Server/db")" ]; then
    echo "Папка с базой пуста, копирую пустую структуру"
    cp -n /home/vg_inst/vgserver/db/* /opt/VideoGrace/Server/db
    chmod 777 /opt/VideoGrace/Server/db
    chmod 777 /opt/VideoGrace/Server/db/main.db
    mkdir -p /var/log/vgserver
    chmod 777 /var/log/vgserver
fi

exec /opt/VideoGrace/Server/VideoGraceServer /no-service /opt/VideoGrace/Server/vgserver.conf

