#!/bin/sh

# from env var
[ -z "$DD_PLATFORM" ] && echo '$DD_PLATFORM is not set' && exit 1
mkdir -p ${DD_PLATFORM}

# alternative: create a symbolic link to a user writable folder
## mkdir /opt
## ln -sf $HOME/platform ${DD_PLATFORM}

# For documentation docker container
mkdir -p ${DD_PLATFORM}/docs/

# For deepdetect docker container
mkdir ${DD_PLATFORM}/models/
mkdir ${DD_PLATFORM}/models/public
mkdir ${DD_PLATFORM}/models/private
mkdir ${DD_PLATFORM}/models/training
mkdir ${DD_PLATFORM}/models/pretrained

# For jupyter docker container
mkdir ${DD_PLATFORM}/notebooks

# For filebrowser docker container
mkdir ${DD_PLATFORM}/filebrowser
touch ${DD_PLATFORM}/filebrowser/database.db
mkdir ${DD_PLATFORM}/data
mkdir ${DD_PLATFORM}/examples

# main docker compose
mkdir ${DD_PLATFORM}/code
wget -nc https://www.deepdetect.com/downloads/platform/dd_docker_single_machine_latest.tar.gz -P ${DD_PLATFORM}/code/
cd ${DD_PLATFORM}/code
tar xf dd_docker_single_machine_latest.tar.gz
rm -f dd_docker_single_machine_latest.tar.gz

# Set init user UIG:GID on ${DD_PLATFORM} structure
#chown -R $USER:$USER ${DD_PLATFORM}
