Skip to content

Commit

Permalink
support: migrated to supportconfig.rc
Browse files Browse the repository at this point in the history
ALP will not support the deprecated scplugin.rc framework. This commit,
then, migrates our support script to work with supportconfig.rc.

This patch has been originally contributed by Jason Record on the linked
Bugzilla entry.

Fixes bsc#1216389

Signed-off-by: Miquel Sabaté Solà <[email protected]>
  • Loading branch information
mssola committed Dec 14, 2023
1 parent 803d2b2 commit 29d042a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 35 deletions.
2 changes: 1 addition & 1 deletion support/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Supportconfig plugin development notes
======================================

Library of useful functions is installed by supportutils at: /usr/lib/supportconfig/resources/scplugin.rc
Library of useful functions is installed by supportutils at: /usr/lib/supportconfig/resources/supportconfig.rc

plugin functions begin with 'p'.

Expand Down
67 changes: 33 additions & 34 deletions support/rmt
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@
# Modified: 2018 April 18
#############################################################

SVER=0.0.2
RCFILE="/usr/lib/supportconfig/resources/scplugin.rc"
SVER='0.0.3'
RCFILE="/usr/lib/supportconfig/resources/supportconfig.rc"
OF='output-rmt.txt'

[ -s $RCFILE ] && . $RCFILE || { echo "ERROR: Initializing resource file: $RCFILE"; exit 1; }

## Our own helper functions
validate_rpm_if_installed() {
THISRPM=$1
echo "#==[ Validating RPM ]=================================#"
log_write $OF '#==[ Validating RPM ]=================================#'
if rpm -q "$THISRPM" >/dev/null 2>&1; then
echo "# rpm -V $THISRPM"

if rpm -V "$THISRPM"; then
echo "Status: Passed"
if rpm -V $THISRPM >> ${LOG}/${OF} 2>&1; then
log_write $OF "Status: Passed"
else
echo "Status: WARNING"
log_write $OF "Status: WARNING"
fi
else
echo "package $THISRPM is not installed"
echo "Status: Skipped"
log_write $OF "package $THISRPM is not installed"
log_write $OF "Status: Skipped"
fi
echo
log_write $OF
}

RPMLIST=(rmt-server nginx mariadb)
Expand All @@ -40,51 +39,51 @@ LOG_UNITS=(rmt-server.service rmt-server-migration.service rmt-server-sync.servi

CONF_FILES=(/etc/rmt.conf /etc/nginx/vhosts.d/rmt-server-http.conf /etc/nginx/vhosts.d/rmt-server-https.conf)

section_header "Supportconfig Plugin for RMT, v${SVER}"
if ! rpm -q rmt-server &>/dev/null; then
echo -e "ERROR: RMT rpm package ('rmt-server') not installed\n"
exit 111
fi
log_entry $OF note "Supportconfig Plugin for RMT, v${SVER}"
rpm_verify $OF rmt-server || exit 111

log_entry $OF note 'Packages'

plugin_tag "Packages"
for pkg in "${RPMLIST[@]}"; do
validate_rpm_if_installed "$pkg"
done

plugin_tag "Configuration"
pconf_files "$CONF_FILES"
log_entry $OF note "Configuration"
conf_files $OF "$CONF_FILES"

plugin_tag "SSL Configuration"
plugin_command "ls -l /usr/share/rmt/ssl/"
log_entry $OF note "SSL Configuration"
log_cmd $OF "ls -l /usr/share/rmt/ssl/"

if systemctl --quiet is-active nginx; then
plugin_command "echo | openssl s_client -showcerts -servername localhost -connect localhost:443 2>/dev/null | openssl x509 -inform pem -noout -text"
log_cmd $OF "echo | openssl s_client -showcerts -servername localhost -connect localhost:443 2>/dev/null | openssl x509 -inform pem -noout -text"
else
for cert in /usr/share/rmt/ssl/rmt-ca.crt /usr/share/rmt/ssl/rmt-server.crt; do
plugin_command "openssl x509 -inform pem -noout -text -in $cert"
log_cmd $OF "openssl x509 -inform pem -noout -text -in $cert"
done
fi

plugin_tag "Service Status"
log_entry $OF note "Service Status"
for i in "${STATUS_UNITS[@]}"; do
plugin_command "systemctl status $i"
log_cmd $OF "systemctl status $i"
done

plugin_tag "Mirroring Status"
plugin_command "rmt-cli products list"
plugin_command "rmt-cli repos list"
log_entry $OF note "Mirroring Status"
log_cmd $OF "rmt-cli products list"
log_cmd $OF "rmt-cli repos list"

plugin_tag "Service Logs"
log_entry $OF note "Service Logs"
for service in "${LOG_UNITS[@]}"; do
plugin_command "journalctl -n1000 -u $service"
log_cmd $OF "journalctl -n1000 -u $service"
done

plugin_tag "Custom Repos"
plugin_command "rmt-cli repos custom list"
log_entry $OF note "Custom Repos"
log_cmd $OF "rmt-cli repos custom list"
custom_repos=$(rmt-cli repos custom list --csv 2>/dev/null | sed 1d | cut -d ',' -f 1)
if [ -n "$custom_repos" ]; then
for custom in $custom_repos; do
echo "Products bound to custom repo id: $custom"
plugin_command "rmt-cli repos custom products $custom"
log_write $OF "Products bound to custom repo id: $custom"
log_cmd $OF "rmt-cli repos custom products $custom"
done
fi
_sanitize_file $OF

0 comments on commit 29d042a

Please sign in to comment.