#!/usr/bin/env bash

CMAKE_CONFIG_DIR="/usr/@LIB_DIR@/cmake"
PKG_CONFIG_DIR="/usr/@LIB_DIR@/pkgconfig"

if [ ! -d "${CMAKE_CONFIG_DIR}" ]
then
    mkdir "${CMAKE_CONFIG_DIR}"
fi
if [ ! -d "${PKG_CONFIG_DIR}" ]
then
    mkdir ${PKG_CONFIG_DIR}
fi

mkdir -p /usr/lib/foundationdb/backup_agent

update-alternatives --install /usr/bin/fdbcli fdbclients /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/bin/fdbcli @ALTERNATIVES_PRIORITY@ \
    --slave /usr/bin/fdbbackup fdbbackup /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/bin/fdbbackup \
    --slave /usr/bin/fdbrestore fdbrestore /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/bin/fdbbackup \
    --slave /usr/bin/dr_agent dr_agent /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/bin/fdbbackup \
    --slave /usr/bin/fdbdr fdbdr /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/bin/fdbbackup \
    --slave /usr/lib/foundationdb/backup_agent/backup_agent backup_agent /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/bin/fdbbackup \
    --slave /usr/@LIB_DIR@/libfdb_c.so libfdb_c /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/lib/libfdb_c.so \
    --slave /usr/@LIB_DIR@/pkgconfig/foundationdb-client.pc foundationdb-client.pc /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/lib/pkgconfig/foundationdb-client.pc \
    --slave /usr/@LIB_DIR@/cmake/FoundationDB-Client FoundationDB-ClientConfig /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/lib/cmake/FoundationDB-Client \
    --slave /usr/include/foundationdb fdb-client-headers /usr/lib/foundationdb-@FDB_VERSION@@FDB_BUILDTIME_STRING@/include/foundationdb
