#!/usr/bin/env bash
# info_ru: Интеграция сметной системы АВС с BIM-платформами.
########################################################################
export WH_WINE_USE="wine-9.0.14-alt1-amd64"
export WINEPREFIX="abccenter"
PROG_NAME=("BIM-смета АВС-RU" "АВС Рекомпозитор")
export BASE_PFX="none"
export WH_WINDOWS_VER="10"
export WINEARCH="win64"
# export INSTALL_DLL=""

prepair_wine
# Возможны точки либо нижнее подчеркивание в URL-адресе
try_get_page "https://abccenter.ru/download-ru/"
VERDATE=$(read_page | grep -oP 'Setup_ABC-BIM-RU_\K\d+[._]\d+_\d+-\d+-\d+')
VERSION=$(read_page | grep -oP 'Setup_ABC-BIM-RU_\K\d+[._]\d+' | sed -E 's/[._]/./g')
AUTOINSTALL_EXE="${WH_TMP_DIR}/Setup_ABC-BIM-RU_${VERDATE}_trial.exe"

if try_download "https://abccenter.ru/wp-content/soft/Setup_ABC-BIM-RU_${VERDATE}_trial.exe" "${AUTOINSTALL_EXE}" ; then
    wine_run_install "${AUTOINSTALL_EXE}" /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP-
    try_remove_file "$AUTOINSTALL_EXE"

    WIN_FILE_EXEC="$DRIVE_C/ABC-Soft/ABC-RU/${VERSION}/Abc_win/Exec/Abc.exe"
    WIN_FILE_EXEC1="$DRIVE_C/ABC-Soft/ABC RECOMPOSER/abcrecomposerwl.exe"

    create_desktop "BIM-смета АВС-RU ${VERSION}" "$WIN_FILE_EXEC" "abc"
    create_desktop "АВС Рекомпозитор" "$WIN_FILE_EXEC1" "abc-recomposerwl"
fi
