Skip to content

Commit

Permalink
add install scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-christophe81 committed Jun 20, 2024
1 parent 5078c3c commit 8c7d92e
Show file tree
Hide file tree
Showing 26 changed files with 701 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/package-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
if: ${{ matrix.package_extension == 'rpm' }}
run: |
cd selinux
for MODULE in "centreon-engine" "centreon-broker"; do
for MODULE in "centreon-engine" "centreon-broker" "centreon-agent"; do
cd $MODULE
sed -i "s/@VERSION@/${{ inputs.version }}/g" $MODULE.te
make -f /usr/share/selinux/devel/Makefile
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
run: rm -rf *-debuginfo*.${{ matrix.package_extension }}

# set condition to true if artifacts are needed
- if: ${{ true }}
- if: ${{ false }}
name: Upload package artifacts
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
with:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ log.html
output.xml
report.html

# agent
agent/scripts/centagent.service
opentelemetry-proto

# bbdo
bbdo/*_accessor.hh

Expand Down Expand Up @@ -140,3 +144,4 @@ tests/bench.unqlite
tests/resources/*_pb2.py
tests/resources/*_pb2_grpc.py
tests/resources/grpc_stream.proto
tests/resources/opentelemetry
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ endif()
# ########### CONSTANTS ###########
set(USER_BROKER centreon-broker)
set(USER_ENGINE centreon-engine)
set(USER_AGENT centreon-agent)


find_package(fmt CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
Expand Down
30 changes: 25 additions & 5 deletions agent/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ project("Centreon agent" C CXX)
# Set directories.
set(INCLUDE_DIR "${PROJECT_SOURCE_DIR}/inc/com/centreon/agent")
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(SCRIPT_DIR "${PROJECT_SOURCE_DIR}/scripts")


add_definitions("-D_GLIBCXX_USE_CXX11_ABI=1")
Expand Down Expand Up @@ -130,8 +131,6 @@ target_link_libraries(
${CENTREON_AGENT} PRIVATE
-L${PROTOBUF_LIB_DIR}
gRPC::gpr gRPC::grpc gRPC::grpc++ gRPC::grpc++_alts
# cerpc
# berpc
centagent_lib
centreon_common
centreon_grpc
Expand All @@ -157,7 +156,28 @@ if(WITH_TESTING)
add_subdirectory(test)
endif()

#if(WITH_CONF)
# add_subdirectory(conf)
#endif()

set(PREFIX_AGENT_CONF "${CMAKE_INSTALL_FULL_SYSCONFDIR}/centreon-agent")


if(WITH_CONF)
add_subdirectory(conf)
endif()

# Generate Systemd script.
message(STATUS "Generating systemd startup script.")
configure_file("${SCRIPT_DIR}/centagent.service.in"
"${SCRIPT_DIR}/centagent.service")

# Startup dir.
if(WITH_STARTUP_DIR)
set(STARTUP_DIR "${WITH_STARTUP_DIR}")
else()
set(STARTUP_DIR "/etc/systemd/system")
endif()

# Script install rule.
install(
PROGRAMS "${SCRIPT_DIR}/centagent.service"
DESTINATION "${STARTUP_DIR}"
COMPONENT "runtime")
43 changes: 43 additions & 0 deletions agent/conf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# Copyright 2024 Centreon
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# For more information : [email protected]
#

# Set directories.
set(SRC_DIR "${PROJECT_SOURCE_DIR}/conf")

# Configure files.
configure_file("${SRC_DIR}/centagent.cfg.in"
"${SRC_DIR}/centagent.cfg")

# Install files if necessary.
option(WITH_SAMPLE_CONFIG "Install sample configuration files." ON)
if (WITH_SAMPLE_CONFIG)
install(DIRECTORY "${SRC_DIR}/"
DESTINATION "${PREFIX_AGENT_CONF}"
COMPONENT "runtime"
FILES_MATCHING PATTERN "*.cfg")

install(CODE "
function(my_chown user group file)
if (APPLE OR (UNIX AND NOT CYGWIN))
execute_process(COMMAND \"chown\" \"\${user}:\${group}\" \"\${file}\")
endif ()
endfunction()
my_chown(\"${USER_AGENT}\" \"${USER_AGENT}\" \"${PREFIX_AGENT_CONF}/centagent.cfg\")
")
endif ()
121 changes: 121 additions & 0 deletions agent/conf/centagent.cfg.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#
# Copyright 2024 Centreon
#
# This file is part of Centreon Agent.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# For more information : [email protected]
#

# file: centagent.cfg
# brief: Sample main config file for Centreon Agent @VERSION@
#
# Read the documentation for more information on this configuration file. I've
# provided some comments here, but things may not be so clear without further
# explanation.
# If you want to have a list of all options,
# in a terminal, executes @CMAKE_INSTALL_FULL_BINDIR@/@CENTREON_AGENT@ --help


# var: log-file
# brief: in case of log-type=file, logs will be written in this file

log-file=@AGENT_VAR_LOG_DIR@/@[email protected]


# var: log-level
# brief: You can choose log verbosity:
# critical, error, info, debug, trace
# You can change log verbosity during runtime with USR1 and USR2 signals
# Ex: kill -USR1 <pid> to decrease verbosity (error => info for example)
# kill -USR2 <pid> to increase verbosity

log-level=info


# var: log-type
# brief: type of log output: stdout or to a file

log-type=file

# var: log-max-file-size
# brief: max log file size in bytes until rotate

log-max-file-size=10000000


# var: log-max-files
# brief: max number of log files (oldest will be removed)

log-max-files=3


# var: endpoint
# brief: This parameter is mandatory
# In normal case (agent connects to engine), this endpoint is the
# opentelemetry listening endpoint of engine
# His syntax is <ip or dns name>:port

#endpoint=<poller ip>:4317


# var: encryption
# brief: false by default
# set to true to enable encryption between engine and agent

encryption=false


# var: certificate
# brief: path of the certificate file used by encryption

#certificate=/etc/centron-agent/certif.crt


# var: private_key
# brief: path of the key file of the certificate file

#private_key=/etc/centreon-agent/certif.key


# var: ca_certificate
# brief: path of the authority certificate file used by encryption

#ca_certificate=/etc/centreon-agent/ca.crt


# var: ca_name
# brief: name of the host declared in authority certificate

#ca_name=


# var: host
# brief: name of the host declared in centreon configuration
# if not given, hostname of the computer will be used

#host=


# var: reversed-grpc-streaming
# brief: used when centreon agent is not allowed to connect to poller
# if this option if set to true, centreon agent become a
# grpc server listening on pair interface:port given by
# endpoint parameter where poller will have to connect to

reversed-grpc-streaming=false




33 changes: 33 additions & 0 deletions agent/scripts/centagent.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright 2016 Centreon
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# For more information : [email protected]
#

[Unit]
Description=Centreon Agent
PartOf=centreon.service
After=centreon.service
ReloadPropagatedFrom=centreon.service

[Service]
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/@CENTREON_AGENT@ --config-file @PREFIX_AGENT_CONF@/@[email protected]
ExecReload=/bin/kill -HUP $MAINPID
Type=simple
User=centreon-agent

[Install]
WantedBy=default.target

Loading

0 comments on commit 8c7d92e

Please sign in to comment.