#!/bin/bash

BASEDIR=$(dirname $0)
cd $BASEDIR
cd ..
echo "calle the composer first"
composer install

cd scripts
PS3='Select your system: '
options=("Development" "DEV-Master" "QS" "Staging")
select opt in "${options[@]}"
do
    case $opt in
        "Development")
            echo "download the dump and import"
            OXID_ENV=development ./ftp2pimcore.sh
            break
            ;;
        "DEV-Master")
            echo "download the dump and import"
            OXID_ENV=dm ./dump2pimcore.sh
            break
            ;;
        "QS")
            echo "download the dump and import"
            OXID_ENV=qs ./dump2pimcore.sh
            break
            ;;
        "Staging")
            echo "download the dump and import"
            OXID_ENV=staging ./dump2pimcore.sh
            break
            ;;
        *) echo "invalid option $REPLY";;
    esac
done

cd ..

if test -f "configurations/$OXID_ENV/.htaccess"; then
    echo "copy .htaccess"
    cp configurations/$OXID_ENV/.htaccess source/.htaccess
fi
echo "DONE"
