#   BAREOS® - Backup Archiving REcovery Open Sourced
#
#   Copyright (C) 2019-2022 Bareos GmbH & Co. KG
#
#   This program is Free Software; you can redistribute it and/or
#   modify it under the terms of version three of the GNU Affero General Public
#   License as published by the Free Software Foundation and included
#   in the file LICENSE.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#   Affero General Public License for more details.
#
#   You should have received a copy of the GNU Affero General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#   02110-1301, USA.
message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")

file(COPY "${CMAKE_CURRENT_LIST_DIR}/conffiles/"
     DESTINATION "${CMAKE_SOURCE_DIR}/conffiles/"
)

add_custom_command(
  OUTPUT univention-install-config-registry
  COMMAND
    ${CMAKE_SOURCE_DIR}/core/platforms/univention/create_ucs_template_files.sh
    conffiles/
  COMMAND univention-install-config-registry -v
  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

add_custom_target(run ALL DEPENDS univention-install-config-registry)

install(
  FILES "job-generic.template"
  DESTINATION "${confdir}/autogenerated/clients/"
  RENAME "generic.template"
)

install(
  FILES "job-windows.template"
  DESTINATION "${confdir}/autogenerated/clients/"
  RENAME "windows.template"
)

install(
  # This file contains the Bareos repository signature public. During the
  # automatic build process, It will be added. For manual builds, download the
  # file from
  # http://download.bareos.org/bareos/release/<RELEASE>/<DISTRIBUTION>/Release.k
  # ey
  FILES "bareos-release.key"
  DESTINATION "${confdir}"
)

install(
  FILES "univention-bareos.cron"
  RENAME "univention-bareos"
  DESTINATION "${sysconfdir}/cron.d/"
)

install(FILES "univention-bareos.py"
        DESTINATION "/usr/lib/univention-directory-listener/system/"
)

install(PROGRAMS "62univention-bareos.inst"
        DESTINATION "/usr/lib/univention-install/"
)

install(PROGRAMS "63univention-bareos.uinst"
        DESTINATION "/usr/lib/univention-uninstall/"
)

install(FILES "univention-bareos.schema"
        DESTINATION "/usr/share/univention-bareos/"
)

install(PROGRAMS "bareos-dir-restart" "bareos-dir-restart-on-change"
        DESTINATION "/usr/share/univention-bareos/"
)

install(CODE "set(CMAKE_SOURCE_DIR \"${CMAKE_SOURCE_DIR}\")")
install(
  SCRIPT
    ${CMAKE_SOURCE_DIR}/core/cmake/install-univention-extra-configuration.cmake
)
