Skip to content

Commit

Permalink
post-install: reduce verbosity (#2751)
Browse files Browse the repository at this point in the history
* post install: avoid message "no such file or directory" when looking for logs
* post install: avoid info and warning messages when registering to capi
* lint (backtick)
  • Loading branch information
mmetc committed Jan 18, 2024
1 parent 5d0d5ac commit fa8d5b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if [ "$1" = configure ]; then
[ -s /etc/crowdsec/local_api_credentials.yaml ] || cscli machines add -a --force --error

if [ "$CAPI" = true ]; then
cscli capi register
cscli capi register --error
fi

else
Expand Down
2 changes: 1 addition & 1 deletion rpm/SPECS/crowdsec.spec
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ if [ $1 == 1 ]; then
fi
if [ ! -f "%{_sysconfdir}/crowdsec/online_api_credentials.yaml" ] ; then
install -m 600 /dev/null /etc/crowdsec/online_api_credentials.yaml
cscli capi register
cscli capi register --error
fi
if [ ! -f "%{_sysconfdir}/crowdsec/local_api_credentials.yaml" ] ; then
install -m 600 /dev/null /etc/crowdsec/local_api_credentials.yaml
Expand Down
10 changes: 4 additions & 6 deletions wizard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ detect_services () {
DETECTED_SERVICES=()
HMENU=()
# list systemd services
SYSTEMD_SERVICES=`systemctl --state=enabled list-unit-files '*.service' | cut -d ' ' -f1`
SYSTEMD_SERVICES=$(systemctl --state=enabled list-unit-files '*.service' | cut -d ' ' -f1)
# raw ps
PSAX=`ps ax -o comm=`
PSAX=$(ps ax -o comm=)
for SVC in ${SUPPORTED_SERVICES} ; do
log_dbg "Checking if service '${SVC}' is running (ps+systemd)"
for SRC in "${SYSTEMD_SERVICES}" "${PSAX}" ; do
Expand Down Expand Up @@ -191,7 +191,6 @@ log_locations[linux]='/var/log/syslog,/var/log/kern.log,/var/log/messages'

# $1 is service name, such those in SUPPORTED_SERVICES
find_logs_for() {
ret=""
x=${1}
# we have trailing and starting quotes because of whiptail
SVC="${x%\"}"
Expand All @@ -209,7 +208,7 @@ find_logs_for() {
# Split /var/log/nginx/*.log into '/var/log/nginx' and '*.log' so we can use find
path=${poss_path%/*}
fname=${poss_path##*/}
candidates=`find "${path}" -type f -mtime -5 -ctime -5 -name "$fname"`
candidates=$(find "${path}" -type f -mtime -5 -ctime -5 -name "$fname" 2>/dev/null)
# We have some candidates, add them
for final_file in ${candidates} ; do
log_dbg "Found logs file for '${SVC}': ${final_file}"
Expand Down Expand Up @@ -713,8 +712,7 @@ main() {
${CSCLI_BIN_INSTALLED} machines add --force "$(cat /etc/machine-id)" -a -f "${CROWDSEC_CONFIG_PATH}/${CLIENT_SECRETS}" || log_fatal "unable to add machine to the local API"
log_dbg "Crowdsec LAPI registered"

${CSCLI_BIN_INSTALLED} capi register || log_fatal "unable to register to the Central API"
log_dbg "Crowdsec CAPI registered"
${CSCLI_BIN_INSTALLED} capi register --error || log_fatal "unable to register to the Central API"

systemctl enable -q crowdsec >/dev/null || log_fatal "unable to enable crowdsec"
systemctl start crowdsec >/dev/null || log_fatal "unable to start crowdsec"
Expand Down

0 comments on commit fa8d5b6

Please sign in to comment.