Skip to content

Commit e0ae166

Browse files
authored
Mon 196514 cma installation script fixes (#3231) (#3240) (#3242)
* fix: cma installation script fixes REFS: MON-196514
1 parent d28d094 commit e0ae166

2 files changed

Lines changed: 34 additions & 28 deletions

File tree

agent/installer/install-centreon-agent.ps1 renamed to agent/installer/install_cma.ps1

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@
4040
Maximum log file size
4141
.PARAMETER MaxNumber
4242
Maximum number of log files
43-
.PARAMETER CustomCheck
43+
.PARAMETER CustomCheckFile
4444
Custom check configuration
4545
.PARAMETER PluginSrc
4646
Plugin source path
47+
.PARAMETER HostTemplate
48+
Template source
4749
.EXAMPLE
4850
.\install-centreon-agent.ps1 -Endpoint "h:1"
4951
Minimal installation with just endpoint and token (prompted). Host defaults to Windows hostname, both agent and plugins installed.
@@ -85,7 +87,7 @@ param(
8587
[string]$Reverse = "",
8688

8789
[Parameter(Mandatory=$false)]
88-
[string]$Encryption = "",
90+
[string]$Encryption = "full",
8991

9092
[Parameter(Mandatory=$false)]
9193
[string]$Cert = "",
@@ -106,16 +108,19 @@ param(
106108
[string]$LogLevel = "",
107109

108110
[Parameter(Mandatory=$false)]
109-
[string]$MaxFileSize = "",
111+
[string]$MaxFileSize = "10",
110112

111113
[Parameter(Mandatory=$false)]
112-
[string]$MaxNumber = "",
114+
[string]$MaxNumber = "10",
113115

114116
[Parameter(Mandatory=$false)]
115-
[string]$CustomCheck = "",
117+
[string]$CustomCheckFile = "",
116118

117119
[Parameter(Mandatory=$false)]
118-
[string]$PluginSrc = ""
120+
[string]$PluginSrc = "",
121+
122+
[Parameter(Mandatory=$false)]
123+
[string]$HostTemplate = ""
119124

120125
)
121126

@@ -323,7 +328,8 @@ function Build-InstallerArgs {
323328
if ($LogLevel) { $args += "/LOGLEVEL=$LogLevel" }
324329
if ($MaxFileSize) { $args += "/MAXFILESIZE=$MaxFileSize" }
325330
if ($MaxNumber) { $args += "/MAXNUMBER=$MaxNumber" }
326-
if ($CustomCheck) { $args += "/CUSTOMCHECKFILE=$CustomCheck" }
331+
if ($CustomCheckFile) { $args += "/CUSTOMCHECKFILE=$CustomCheckFile" }
332+
if ($HostTemplate) {$args += "/HOSTTEMPLATE=$HostTemplate"}
327333
if ($PluginSrc) { $args += "/PLUGINSRC=$PluginSrc" }
328334

329335
return $args

agent/installer/scripts_linux/install_cma.sh

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
# -v, --version Centreon version (24.10 or 25.10, default: 24.10)
3939
# -c, --encryption Encryption mode: full, insecure, or no (default: no)
4040
# -r, --reverse Enable poller-initiated (reversed) connection mode
41-
# -a, --ca-cert Path to CA certificate file (required if encryption=full/insecure, non-reverse)
42-
# -N, --ca-name CA common name (optional, used with encryption=full/insecure)
41+
# -a, --ca Path to CA certificate file (required if encryption=full/insecure, non-reverse)
42+
# -N, --common-name CA common name (optional, used with encryption=full/insecure)
4343
# -C, --cert Path to public certificate file (required if encryption=full/insecure, reverse mode)
4444
# -k, --key Path to private key file (required if encryption=full/insecure, reverse mode)
4545
# -f, --fingerprint Certificate fingerprint for validation
@@ -48,8 +48,8 @@
4848
# -l, --log-level Log level: off, critical, error, warning, info, debug, trace (default: info)
4949
# -M, --max-file-size Maximum log file size in bytes (used with log-type=file)
5050
# -m, --max-number Maximum number of log files for rotation (used with log-type=file)
51-
# -x, --custom-check Path to custom check configuration file
52-
# -p, --components Comma-separated list of components to install: agent,plugin (default: agent,plugin)
51+
# -x, --custom-check-file Path to custom check configuration file
52+
# -p, --components Comma-separated list of components to install: agent,plugins (default: agent,plugins)
5353
# -H, --host-template Host template to use in Centreon (optional , default : OS-Linux-Centreon-Monitoring-Agent-custom)
5454
# -d, --dry-run Show what would be done without making changes
5555
# -h, --help Display this help message
@@ -59,7 +59,7 @@
5959
# ./install_cma.sh -e "192.168.1.100:4317" -t "my-auth-token"
6060
#
6161
# # Installation with plugins and custom hostname
62-
# ./install_cma.sh -e "poller.example.com:4317" -t "my-token" -n "web-server-01" -p "agent,plugin"
62+
# ./install_cma.sh -e "poller.example.com:4317" -t "my-token" -n "web-server-01" -p "agent,plugins"
6363
#
6464
# # Installation with full encryption (agent-initiated)
6565
# ./install_cma.sh -e "192.168.1.100:4317" -t "my-token" -c full -a /path/to/ca.crt
@@ -89,7 +89,7 @@ DEFAULT_LOG_LEVEL="error"
8989
DEFAULT_LOG_TYPE="file"
9090
DEFAULT_LOG_FILE="/var/log/centreon-monitoring-agent/centagent.log"
9191
DEFAULT_MAX_FILE_SIZE="10"
92-
DEFAULT_MAX_NUMBER="3"
92+
DEFAULT_MAX_NUMBER="10"
9393
DEFAULT_HOST_TEMPLATE="OS-Linux-Centreon-Monitoring-Agent-custom"
9494

9595
# Configuration paths
@@ -122,7 +122,7 @@ LOG_LEVEL="${DEFAULT_LOG_LEVEL}"
122122
MAX_FILE_SIZE="${DEFAULT_MAX_FILE_SIZE}"
123123
MAX_NUMBER="${DEFAULT_MAX_NUMBER}"
124124
CUSTOM_CHECK_FILE=""
125-
COMPONENTS="agent,plugin"
125+
COMPONENTS="agent,plugins"
126126
DRY_RUN=false
127127
OUTPUT_CONFIG=false
128128
GITHUB_TOKEN="${GITHUB_TOKEN:-}" # Optional GitHub token for API authentication
@@ -174,8 +174,8 @@ OPTIONAL OPTIONS:
174174
-v, --version <VERSION> Centreon version: 24.10 or 25.10 (default: ${DEFAULT_CENTREON_VERSION})
175175
-c, --encryption <MODE> Encryption mode: full, insecure, or no (default: ${DEFAULT_ENCRYPTION})
176176
-r, --reverse Enable poller-initiated (reversed) connection mode
177-
-a, --ca-cert <PATH> Path to CA certificate file (used with encryption=full/insecure)
178-
-N, --ca-name <NAME> CA common name (optional, used with encryption=full/insecure)
177+
-a, --ca <PATH> Path to CA certificate file (used with encryption=full/insecure)
178+
-N, --common-name <NAME> CA common name (optional, used with encryption=full/insecure)
179179
-C, --cert <PATH> Path to public certificate file (required for TLS in reverse mode)
180180
-k, --key <PATH> Path to private key file (required for TLS in reverse mode)
181181
-f, --fingerprint <STRING> Certificate fingerprint for validation
@@ -184,8 +184,8 @@ OPTIONAL OPTIONS:
184184
-l, --log-level <LEVEL> Log level: off, critical, error, warning, info, debug, trace (default: ${DEFAULT_LOG_LEVEL})
185185
-M, --max-file-size <BYTES> Maximum log file size in bytes (used with log-type=file)
186186
-m, --max-number <NUM> Maximum number of log files for rotation
187-
-x, --custom-check <PATH> Path to custom check configuration file
188-
-p, --components <LIST> Comma-separated list of components to install: agent,plugin (default: agent,plugin)
187+
-x, --custom-check-file <PATH> Path to custom check configuration file
188+
-p, --components <LIST> Comma-separated list of components to install: agent,plugins (default: agent,plugins)
189189
-H, --host-template <STRING> Host template to use in Centreon (optional)
190190
-d, --dry-run Show what would be done without making changes
191191
-h, --help Display this help message
@@ -195,7 +195,7 @@ EXAMPLES:
195195
${SCRIPT_NAME} -e "192.168.1.100:4317" -t "my-auth-token"
196196
197197
# Installation with plugins and custom hostname
198-
${SCRIPT_NAME} -e "poller.example.com:4317" -t "my-token" -n "web-server-01" -p "agent,plugin"
198+
${SCRIPT_NAME} -e "poller.example.com:4317" -t "my-token" -n "web-server-01" -p "agent,plugins"
199199
200200
# Installation with full encryption (agent-initiated)
201201
${SCRIPT_NAME} -e "192.168.1.100:4317" -t "my-token" -c full -a /path/to/ca.crt
@@ -931,7 +931,7 @@ install_cma_agent() {
931931

932932
install_centreon_plugins() {
933933
# Check if "plugin" is in the COMPONENTS list
934-
if [[ ! "${COMPONENTS}" =~ (^|,)plugin(,|$) ]]; then
934+
if [[ ! "${COMPONENTS}" =~ (^|,)plugins(,|$) ]]; then
935935
return 0
936936
fi
937937

@@ -1034,7 +1034,7 @@ generate_config_json() {
10341034
if [[ "${ENCRYPTION}" == "full" || "${ENCRYPTION}" == "insecure" ]]; then
10351035
if [[ "${REVERSE_MODE}" == "true" ]]; then
10361036
if [[ -n "${PUBLIC_CERT}" ]]; then
1037-
config_json+=$'\n'" \"certificate\": \"${PUBLIC_CERT}\","
1037+
config_json+=$'\n'" \"public_cert\": \"${PUBLIC_CERT}\","
10381038
fi
10391039
if [[ -n "${PRIVATE_KEY}" ]]; then
10401040
config_json+=$'\n'" \"private_key\": \"${PRIVATE_KEY}\","
@@ -1054,7 +1054,7 @@ generate_config_json() {
10541054
fi
10551055

10561056
if [[ -n "${CUSTOM_CHECK_FILE}" ]]; then
1057-
config_json+=$'\n'" \"check_file\": \"${CUSTOM_CHECK_FILE}\","
1057+
config_json+=$'\n'" \"custom_check_file\": \"${CUSTOM_CHECK_FILE}\","
10581058
fi
10591059

10601060
config_json="${config_json%,}"
@@ -1131,7 +1131,7 @@ parse_arguments() {
11311131
CA_CERT="$2"
11321132
shift 2
11331133
;;
1134-
-N|--commonname)
1134+
-N|--common-name)
11351135
CA_COMMON_NAME="$2"
11361136
shift 2
11371137
;;
@@ -1147,16 +1147,16 @@ parse_arguments() {
11471147
FINGERPRINT="$2"
11481148
shift 2
11491149
;;
1150-
-T|--logtype)
1150+
-T|--log-type)
11511151
LOG_TYPE="$2"
11521152
validate_log_type "${LOG_TYPE}"
11531153
shift 2
11541154
;;
1155-
-L|--logfile)
1155+
-L|--log-file)
11561156
LOG_FILE="$2"
11571157
shift 2
11581158
;;
1159-
-l|--loglevel)
1159+
-l|--log-level)
11601160
LOG_LEVEL="$2"
11611161
validate_log_level "${LOG_LEVEL}"
11621162
shift 2
@@ -1169,7 +1169,7 @@ parse_arguments() {
11691169
MAX_NUMBER="$2"
11701170
shift 2
11711171
;;
1172-
-x|--custom-check)
1172+
-x|--custom-check-file)
11731173
CUSTOM_CHECK_FILE="$2"
11741174
shift 2
11751175
;;
@@ -1185,7 +1185,7 @@ parse_arguments() {
11851185
DRY_RUN=true
11861186
shift
11871187
;;
1188-
-H| --host-template)
1188+
-H|--host-template)
11891189
HOST_TEMPLATE="$2"
11901190
shift 2
11911191
;;

0 commit comments

Comments
 (0)