Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 31 additions & 6 deletions ospackage/bin/saptune_check
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# ------------------------------------------------------------------------------
# Copyright (c) 2019 SUSE LLC
# Copyright (c) 2019-2025 SUSE LLC
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of version 3 of the GNU General Public License as published by the
Expand Down Expand Up @@ -39,8 +39,9 @@
# 31.10.2024 v0.4.1 added --force-color to support forced colored output by saptune
# 16.01.2025 v0.4.2 a failed sapconf.service causes just a warning an remediation is now correct
# 21.03.2025 v0.4.3 fix missing warning increment if saptune.service is inactive
# 04.06.2025 v0.5 adaption to SLE16 and the new config file location

declare -r VERSION="0.4.3"
declare -r VERSION="0.5"

# We use these global arrays through out the program:
#
Expand All @@ -54,6 +55,19 @@ declare -A package_version os_version system_status unit_state_active unit_state

color=1 # we like it colorful

function define_config_file() {
local VERSION_ID
eval $(grep ^VERSION_ID= /etc/os-release)
case ${VERSION_ID} in
12*|15*)
saptune_config=/etc/sysconfig/saptune
;;
16*)
saptune_config=/var/lib/saptune/config/saptune
;;
esac
}

function header() {
[ ${DO_JSON} -ne 0 ] && return
local len=${#1}
Expand Down Expand Up @@ -668,9 +682,9 @@ function get_tool_profiles() {
[ -e /etc/tuned/active_profile ] && active_profile=$(< /etc/tuned/active_profile)
tool_profile['tuned']="${active_profile:-missing}"

if [ -e /etc/sysconfig/saptune ] ; then
eval $(grep ^TUNE_FOR_NOTES= /etc/sysconfig/saptune)
eval $(grep ^TUNE_FOR_SOLUTIONS= /etc/sysconfig/saptune)
if [ -e ${saptune_config} ] ; then
eval $(grep ^TUNE_FOR_NOTES= ${saptune_config})
eval $(grep ^TUNE_FOR_SOLUTIONS= ${saptune_config})
if [ -z "${TUNE_FOR_NOTES}" -a -z "${TUNE_FOR_SOLUTIONS}" ] ; then
tool_profile['saptune']='missing'
else
Expand All @@ -694,7 +708,7 @@ function configured_saptune_version() {
# Requires: -

local SAPTUNE_VERSION
[ -e /etc/sysconfig/saptune ] && eval $(grep ^SAPTUNE_VERSION= /etc/sysconfig/saptune)
[ -e ${saptune_config} ] && eval $(grep ^SAPTUNE_VERSION= ${saptune_config})
configured_saptune_version="${SAPTUNE_VERSION:-missing}"
}

Expand Down Expand Up @@ -772,6 +786,14 @@ function file_check() {
;;
esac
;;
16*)
case ${tag} in
saptune-3)
mandatory_files=( '/var/lib/saptune/config/saptune' )
invalid_files=( '/etc/saptune/extra/SAP_ASE-SAP_Adaptive_Server_Enterprise.conf' '/etc/saptune/extra/SAP_BOBJ-SAP_Business_OBJects.conf' '/etc/sysconfig/saptune-note-1275776' '/etc/sysconfig/saptune-note-1557506' '/etc/sysconfig/saptune-note-SUSE-GUIDE-01' '/etc/sysconfig/saptune-note-SUSE-GUIDE-02' '/etc/tuned/saptune' '/etc/sysconfig/saptune' )
;;
esac
;;
esac

# Leftovers from a damaged sapconf update/removal, which do not pervent saptune from starting.
Expand Down Expand Up @@ -1118,6 +1140,9 @@ done
eval $(grep ^ID= /etc/os-release)
[ "${ID}" != "sles" ] && { echo "Only SLES is supported! Your OS ID is ${ID}! Exiting." ; exit 2 ; }

# Define main saptune configuration file
define_config_file

# Introduction.
intro

Expand Down
61 changes: 55 additions & 6 deletions ospackage/usr/share/saptune/scripts/upd_helper
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,47 @@ change_note_names() {
done
}

enabled_sol_to_be_deleted() {
esol=$(grep '^TUNE_FOR_SOLUTIONS[[:space:]]*=' $SAPTUNE_CONFIG | awk -F '"' '{ print $2 }')
if [ -n "$esol" ]; then
# enabled solution found
for delsol in $SOLS2DELETE; do
if [ "${esol}.sol" == "$delsol" ]; then
# enabled solution will be deleted
return 0
fi
done
fi
return 1
}

delete_sols() {
esol=$(grep '^TUNE_FOR_SOLUTIONS[[:space:]]*=' $SAPTUNE_CONFIG | awk -F '"' '{ print $2 }')
if enabled_sol_to_be_deleted; then
# enabled solution found, which will be deleted
echo "enabled Solution '$esol' will be deleted, adjust config"
# extract notes of enabled solution from the note definition
if [ -f ${OVERRIDEDIR}/"${esol}".sol ]; then
# file found in the override area
SOLNOTES=$(awk '/\[ArchX86\]/ {getline; print $0}' ${OVERRIDEDIR}/"${esol}".sol)
echo "WARNING: override file for enabled Solution '${esol}' detected. As this Solution will be no longer available, please remove your override file"
else
# file found in the working area
SOLNOTES=$(awk '/\[ArchX86\]/ {getline; print $0}' ${WORKINGAREA}/sols/"${esol}".sol)
fi
# for each note from the solution check, if note is in
# NOTE_APPLY_ORDER. If not, skip note (do nothing).
# Else add note to TUNE_FOR_NOTES, if not yet available
add_TUNE_FOR_NOTES "$SOLNOTES" "$esol" "from deleted"
# delete solution from TUNE_FOR_SOLUTIONS
echo "### removing solution '$esol' from TUNE_FOR_SOLUTIONS"
sed -i "s/$esol//g" $SAPTUNE_CONFIG
fi
# do nothing for not enabled solution (no need to adjust the config)
# remove of solution definition files will be done later in
# adjust_workingarea
}

delete_notes() {
for delnote in $NOTES2DELETE; do
if [ ! -f ${NOTEDIR}/"${delnote}" ]; then
Expand Down Expand Up @@ -304,10 +345,15 @@ adjust_enabled_solution() {
# need to run before the working area is touched in the postinstall
# only needed, if staging is NOT active and a solution is enabled and no
# override file exists.
# no need to run, if the solution will be deleted
# The staging is checked in the postinstall, so no need to do it again.
# If an override file for the enabled solution exists, we will NOT change
# anything. It is up to the customer to check and adjust after the update
esol=$(grep '^TUNE_FOR_SOLUTIONS[[:space:]]*=' $SAPTUNE_CONFIG | awk -F '"' '{ print $2 }')
if enabled_sol_to_be_deleted; then
echo "enabled Solution '$esol' detected, which will be deleted later. No need to adjust"
return 0
fi
if [ -n "$esol" ] && [ ! -f ${OVERRIDEDIR}/"${esol}".sol ]; then
# enabled solution found, override does not exist
# extract notes of enabled solution from the solution definition file
Expand Down Expand Up @@ -375,7 +421,7 @@ adjust_enabled_solution() {
fi
done
add_NOTE_APPLY_ORDER "$NOTES2ADD" "$esol"
delete_NOTE_APPLY_ORDER "$NOTES2REM" "$esol"
add_TUNE_FOR_NOTES "$NOTES2REM" "$esol" "deleted from"
fi
if [ -n "$esol" ] && [ -f ${OVERRIDEDIR}/"${esol}".sol ]; then
echo "WARNING: override file for enabled Solution '${esol}' detected. As the content of this Solution changed, please check and adapt your override file"
Expand Down Expand Up @@ -409,9 +455,10 @@ add_NOTE_APPLY_ORDER() {
done
}

delete_NOTE_APPLY_ORDER() {
add_TUNE_FOR_NOTES() {
del_notes="$1"
sol="$2"
txt="$3"
apply_list=$(grep '^NOTE_APPLY_ORDER[[:space:]]*=' $SAPTUNE_CONFIG | awk -F '"' '{ print $2 }')

for fnote in $del_notes; do
Expand All @@ -423,16 +470,17 @@ delete_NOTE_APPLY_ORDER() {
if [ "$dnote" == "$fnote" ]; then
# don't touch NOTE_APPLY_ORDER, but
# append Note to TUNE_FOR_NOTES, if not yet available
add_TUNE_FOR_NOTES "$fnote" "$sol"
append_TUNE_FOR_NOTES "$fnote" "$sol" "$txt"
fi
done
done
}

add_TUNE_FOR_NOTES() {
append_TUNE_FOR_NOTES() {
# append Note to TUNE_FOR_NOTES, if not yet available.
notes="$1"
sol="$2"
txt="$3"
notes_list=$(grep '^TUNE_FOR_NOTES[[:space:]]*=' $SAPTUNE_CONFIG | awk -F '"' '{ print $2 }')

for fnote in $notes; do
Expand All @@ -445,7 +493,7 @@ add_TUNE_FOR_NOTES() {
done
if [ "$found" == "false" ]; then
if [ -n "$sol" ]; then
echo "### appending the Note '$fnote' deleted from Solution '$sol' to 'TUNE_FOR_NOTES' in '$SAPTUNE_CONFIG'"
echo "### appending the Note '$fnote' $txt Solution '$sol' to 'TUNE_FOR_NOTES' in '$SAPTUNE_CONFIG'"
sed -i "/^TUNE_FOR_NOTES[[:space:]]*=.*/s/\"$/ $fnote\"/" $SAPTUNE_CONFIG
#else # for future use
fi
Expand Down Expand Up @@ -686,6 +734,7 @@ sleto16pt)
# important for note delete, sol delete and note changes in sols
# needs to run always
change_note_names
delete_sols
delete_notes
staging=$(grep ^STAGING= $SAPTUNE_CONFIG | awk -F '"' '{ print $2 }')
if [ "$staging" == "false" ]; then
Expand All @@ -708,7 +757,7 @@ cleanup)
cleanup_savestates
;;
staging)
# called from the postinstall script of saptune to handle the staging area
# called from the posttrans script of saptune to handle the staging area
copy_packednotes2staging
;;
enabledSol)
Expand Down
4 changes: 2 additions & 2 deletions ospackage/usr/share/saptune/sols_16/HANA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DESCRIPTION=Definition of HANA solution for SLE16
REFERENCES=

[ArchX86]
941735 3565382 1868829 3577842 2382421 2534844 2993054 1656250
941735 3565382 1868829 1980196 3577842 2382421 2534844 2993054 1656250

[ArchPPC64LE]
941735 3565382 1868829 3577842 2382421 2534844 2993054 1656250
941735 3565382 1868829 1980196 3577842 2382421 2534844 2993054 1656250
4 changes: 2 additions & 2 deletions ospackage/usr/share/saptune/sols_16/NETWEAVER+HANA.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DESCRIPTION=Definition of NETWEAVER+HANA solution for SLE16
REFERENCES=

[ArchX86]
941735 3565382 1868829 3577842 2382421 2534844 2993054 1656250
941735 3565382 1868829 1980196 3577842 2382421 2534844 2993054 1656250

[ArchPPC64LE]
941735 3565382 1868829 3577842 2382421 2534844 2993054 1656250
941735 3565382 1868829 1980196 3577842 2382421 2534844 2993054 1656250
4 changes: 2 additions & 2 deletions ospackage/usr/share/saptune/sols_16/S4HANA-APP+DB.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DESCRIPTION=Definition of S4HANA-APP+DB solution for SLE16
REFERENCES=

[ArchX86]
941735 3565382 1868829 3577842 2382421 2534844 2993054 1656250
941735 3565382 1868829 1980196 3577842 2382421 2534844 2993054 1656250

[ArchPPC64LE]
941735 3565382 1868829 3577842 2382421 2534844 2993054 1656250
941735 3565382 1868829 1980196 3577842 2382421 2534844 2993054 1656250
4 changes: 2 additions & 2 deletions ospackage/usr/share/saptune/sols_16/S4HANA-DBSERVER.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DESCRIPTION=Definition of S4HANA-DBSERVER solution for SLE16
REFERENCES=

[ArchX86]
941735 3565382 1868829 3577842 2382421 2534844 2993054 1656250
941735 3565382 1868829 1980196 3577842 2382421 2534844 2993054 1656250

[ArchPPC64LE]
941735 3565382 1868829 3577842 2382421 2534844 2993054 1656250
941735 3565382 1868829 1980196 3577842 2382421 2534844 2993054 1656250
Loading