#!/usr/bin/env bash
# info_ru:  Сервис обновления ПО
########################################################################
export PROG_URL="https://daobit.ru"
export WH_WINE_USE="wine_x_tkg_10-0_i586" # wine-9.0.9-alt1-i586"
export WINEPREFIX="daobit"
export PROG_NAME="Сервис обновления ПО"
export PROG_ICON="daobitcservice"
export BASE_PFX="daobit_pfx_x86_v01"
export WH_WINDOWS_VER="10"
export WINEARCH="win32"
export INSTALL_DLL="dotnet7 dotnetdesktop7 arial renderer=gdi"

AUTOINSTALL_EXE="${WH_TMP_DIR}/setup_cs.exe"
AUTOINSTALL_UNPACK="${WH_TMP_DIR}/setup_cs"
AUTOINSTALL_SETUP="${WH_TMP_DIR}/setup_cs/SETUP.EXE"

prepair_wine
if try_download "https://files.daobit.ru/CSERVICE/SFX/setup_cs.exe" "${AUTOINSTALL_EXE}" ; then

    # фикс постоянного запроса обновления Windows
    get_and_set_reg_file --add 'Software\DAO\DAOSETUP' 'SkipKBCheck' 'REG_DWORD' "1" "userdef"

    unpack "${AUTOINSTALL_EXE}" "${AUTOINSTALL_UNPACK}"
    wine_run_install "${AUTOINSTALL_SETUP}" /cd /targetdir="C:\\\\Program Files\\\\DAO\\\\CSERVICE" /auto /hide

    WIN_FILE_EXEC="$DRIVE_C/Program Files/DAO/CSERVICE/CService32.exe"
    create_desktop "$PROG_NAME" "$WIN_FILE_EXEC" "$PROG_ICON"
    try_remove_dir "$AUTOINSTALL_UNPACK"
    try_remove_file "$AUTOINSTALL_EXE"
fi
