Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-15-SP7:GA
sapconf
sapconf.spec
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File sapconf.spec of Package sapconf
# # spec file for package sapconf # # Copyright (c) 2019-2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed # upon. The license for this file, and modifications and additions to the # file, is the same license as for the pristine package itself (unless the # license for the pristine package is not an Open Source License, in which # case the license is the MIT License). An "Open Source License" is a # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. # Please submit bugfixes or comments via https://bugs.opensuse.org/ # %if ! %{defined _fillupdir} %define _fillupdir /var/adm/fillup-templates %endif Name: sapconf Version: 5.0.7 Release: 0 Summary: Kernel Parameter Initializiation for SAP Systems License: LGPL-2.1-or-later Group: Productivity/Other Url: https://www.suse.com/partners/alliance/sap/ PreReq: %fillup_prereq Source0: %name-%version.tar.gz BuildArch: noarch Requires: bc Requires: systemd >= 234-24.42 Requires: sysstat Requires: uuidd Requires: logrotate Requires: /usr/bin/cpupower %if 0%{?sle_version} >= 150400 Requires: sysctl-logger %endif Suggests: cron %{?systemd_requires} %description The utility adjusts operating system parameters, such as kernel tuning settings and resource limits, to allow running various SAP solutions at satisfactory performance. Authors: -------- Angela Briel, Howard Guo %prep %setup -q %build %install mkdir -p %{buildroot}%{_libexecdir}/%{name}/ install -m 0755 lib/%{name} %{buildroot}%{_libexecdir}/%{name}/ install -m 0644 lib/common.sh %{buildroot}%{_libexecdir}/%{name}/ install -m 0644 lib/util.sh %{buildroot}%{_libexecdir}/%{name}/ install -m 0755 lib/sccu.sh %{buildroot}%{_libexecdir}/%{name}/ install -m 0755 lib/mv_tuned_conf.sh %{buildroot}%{_libexecdir}/%{name}/ install -m 0755 lib/adapt2newSNvalues.sh %{buildroot}%{_libexecdir}/%{name}/ install -m 0755 lib/sc_hooks.sh %{buildroot}%{_libexecdir}/%{name}/ install -D -m 755 lib/supportconfig-sapconf %{buildroot}%{_libexecdir}/supportconfig/plugins/%{name} mkdir -p %{buildroot}%{_localstatedir}/lib/%{name}/saved_configs mkdir -p %{buildroot}%{_unitdir}/systemd/system/ %{buildroot}%{_sbindir}/ install -m 0644 sapconf.service %{buildroot}%{_unitdir}/ install -m 0755 bin/* %{buildroot}%{_sbindir}/ ln -s /usr/sbin/service %{buildroot}%{_sbindir}/rcsapconf mkdir -p %{buildroot}%{_mandir}/{man5,man7}/ install -m 0644 man/*.5 %{buildroot}%{_mandir}/man5/ install -m 0644 man/*.7 %{buildroot}%{_mandir}/man7/ mkdir -p %{buildroot}/%{_sysconfdir}/logrotate.d install -m 0644 logrotate/%{name} %{buildroot}/%{_sysconfdir}/logrotate.d/ mkdir -p %{buildroot}/%{_fillupdir}/ pushd sysconfig for file in *; do cp "$file" "%{buildroot}/%{_fillupdir}/sysconfig.$file" done popd %pre %service_add_pre sapconf.service if [ $1 -eq 1 ]; then # package initial install # check, if old config files from a former installation still exist SC=/etc/sysconfig/ for f in sapconf sapnote-1557506 sapnote-1680803; do if [ -f "${SC}${f}" ]; then mv "${SC}${f}" "${SC}${f}".rpmold || : fi done else # package update # to prevent sapconf related tuned error messages anytime after this # sapconf package installation switch off tuned to remove the 'active' # sapconf profile # 'tuned-adm off' is sadly the only possibility to remove an 'active' # sapconf profile # # check for active tuned systemctl -q is-active tuned && [[ $(cat /etc/tuned/active_profile 2>/dev/null) == sap-* || $(cat /etc/tuned/active_profile 2>/dev/null) == sapconf ]] && (echo "found active tuned with a sap related profile"; touch /run/sapconf_tuned_removal_started; mkdir -p /run/sapconf; touch /run/sapconf/active; tuned-adm off; > /etc/tuned/active_profile 2>/dev/null) || : # if the tuned profile is a sap related profile, try to switch off tuned # if 'tuned-adm off' before had worked, the profile is empty # if not try again [[ $(cat /etc/tuned/active_profile 2>/dev/null) == sap-* || $(cat /etc/tuned/active_profile 2>/dev/null) == sapconf ]] && (echo "found a sap related tuned profile, try to switch off tuned"; tuned-adm off || systemctl stop tuned.service) || : # check for enabled and/or active sapconf.service sc_active=$(systemctl is-active sapconf.service 2>/dev/null) || : ([[ "$sc_active" == "activating" ]] || [[ "$sc_active" == "deactivating" ]] || [[ "$sc_active" == "active" ]]) && (echo "found active sapconf.service ($sc_active)"; touch /run/sapconf_pre_actss_found) || : systemctl -q is-enabled sapconf.service 2>/dev/null && (echo "found enabled sapconf.service"; touch /run/sapconf_pre_enblss_found) || : ([ ! -f /run/sapconf_tuned_removal_started ] && ([ -f /usr/lib/tuned/sapconf/script.sh ] || [ -f /usr/lib/tuned/sap-hana/script.sh ])) && touch /run/sapconf_tuned_removal_started || : if ([ -f /etc/sysconfig/sapnote-1557506 ] || ([ -f /etc/sysconfig/sapnote-1680803 ] && [ ! -f /etc/sysconfig/sapnote-bobj ]) || [ -f /usr/lib/tuned/sapconf/script.sh ]); then touch /tmp/sapconf_remove_nofile || : fi /usr/bin/md5sum /etc/sysconfig/sapconf > /tmp/sapconf_sys_md5_pre || : touch /run/sapconf_during_pkg_inst || : fi %post if [ $1 -eq 1 ]; then # package initial install %fillup_only -n sapconf touch /tmp/initial_sapconf_inst || : else # package update hook=$(%{_libexecdir}/%{name}/sc_hooks.sh del) if [ -f /etc/sysconfig/sapnote-1557506 ]; then # covers updates from SLE12 sapconf versions < 4.1.12 echo "covers updates from SLE12 sapconf versions < 4.1.12" mv /etc/sysconfig/sapconf /etc/sysconfig/sapconf.rpmsave || : %fillup_only -n sapconf # remove no longer needed 'pagecache' sysconfig file rm -f /etc/sysconfig/sapnote-1557506 && echo "Removing obsolete /etc/sysconfig/sapnote-1557506..." || : # remove no longer needed 'ase' sysconfig file rm -f /etc/sysconfig/sapnote-1680803 && echo "Removing obsolete /etc/sysconfig/sapnote-1680803..." || : elif [ -f /etc/sysconfig/sapnote-1680803 ]; then # covers updates from SLE12 sapconf versions >= 4.1.12 echo "covers updates from SLE12 sapconf versions >= 4.1.12" # remove pagecache section from sapconf sysconfig file # no longer supported in SLE15 sed -i '/## Path: SAP\/Note\/1557506 - Linux paging improvements/,/.*PAGECACHE_LIMIT_IGNORE_DIRTY[[:blank:]]*=.*/d' /etc/sysconfig/sapconf sed -i '/.*PAGECACHE_LIMIT_IGNORE_DIRTY[[:blank:]]*=.*/d' /etc/sysconfig/sapconf # bsc#1096496/bsc#1096498 # to update the comment sections in /etc/sysconfig/sapconf # does not work with /bin/fillup, but is mandatory for SAP %{_libexecdir}/%{name}/sccu.sh || : echo "Updating /etc/sysconfig/sapconf ..." /bin/fillup -q -t /etc/sysconfig/sapconf %{_fillupdir}/sysconfig.sapconf # remove no longer needed 'ase' sysconfig file rm -f /etc/sysconfig/sapnote-1680803 && echo "Removing obsolete /etc/sysconfig/sapnote-1680803..." || : # remove no longer needed 'bobj' sysconfig file rm -f /etc/sysconfig/sapnote-bobj && echo "Removing obsolete /etc/sysconfig/sapnote-bobj..." || : else # covers updates from SLE15 echo "covers updates from SLE15" # bsc#1096496/bsc#1096498 # to update the comment sections in /etc/sysconfig/sapconf # does not work with /bin/fillup, but is mandatory for SAP %{_libexecdir}/%{name}/sccu.sh || : echo "Updating /etc/sysconfig/sapconf ..." /bin/fillup -q -t /etc/sysconfig/sapconf %{_fillupdir}/sysconfig.sapconf fi %{remove_and_set -n sapconf SEMMSL SEMMNS SEMOPM SEMMNI} # adapt new SAP note values to the configuration %{_libexecdir}/%{name}/adapt2newSNvalues.sh || : %{_libexecdir}/%{name}/sc_hooks.sh $hook || : # move custom specific sapconf related tuned profiles from /etc/tuned/ # to /var/lib/sapconf/saved_configs %{_libexecdir}/%{name}/mv_tuned_conf.sh || : # remove nofile related limits.conf entries for @sapsys @sdba @dba if [ -f /tmp/sapconf_remove_nofile ]; then lim_chg=false for ulimit_group in @sapsys @sdba @dba; do for ulimit_type in soft hard; do limits_line=$(grep -E "^${ulimit_group}[[:space:]]+${ulimit_type}[[:space:]]+nofile.+" /etc/security/limits.conf) if [ -n "$limits_line" ]; then sed -i "/$limits_line/d" /etc/security/limits.conf || : lim_chg=true fi done done [[ $lim_chg ]] && echo "Updating /etc/security/limits.conf..." || : rm -f /tmp/sapconf_remove_nofile || : fi fi sed -i '/^[^#].*[[:blank:]][[:blank:]]*=[[:blank:]][[:blank:]]*.*/s;[[:blank:]];;g' /etc/sysconfig/sapconf >/dev/null 2>&1 || : %service_add_post sapconf.service # cleanup leftover - old SLE12 profile file rm -f /var/lib/sapconf/act_profile || : # Amend logind's behaviour (bsc#1031355, bsc#1039309, bsc#1043844), there is no rollback. # Not needed any longer as the limit is removed from logind (jsc#SLE-10123) SAP_LOGIN_FILE=/etc/systemd/logind.conf.d/sap.conf if [ -f $SAP_LOGIN_FILE ]; then echo "removing no longer needed file '$SAP_LOGIN_FILE'" rm -rf $SAP_LOGIN_FILE || : fi %preun %service_del_preun sapconf.service test -n "$FIRST_ARG" || FIRST_ARG=$1 if [ $FIRST_ARG -eq 0 ]; then # Package removal, not upgrade # revert settings - not needed, done by service_del_preun # clean up custom specific sapconf tuned configuration # move custom specific sapconf related tuned profiles from /etc/tuned/ # to /var/lib/sapconf/saved_configs [ ! -d /var/lib/sapconf/saved_configs ] && mkdir -p /var/lib/sapconf/saved_configs || : for prof in sapconf sap-hana sap-netweaver sap-ase sap-bobj; do if [ -f /etc/tuned/"$prof"/tuned.conf ]; then echo "moving custom profile /etc/tuned/$prof to /var/lib/sapconf/saved_configs" mv /etc/tuned/"$prof" /var/lib/sapconf/saved_configs || : fi done fi %postun test -n "$FIRST_ARG" || FIRST_ARG=$1 if [ $FIRST_ARG -eq 0 ]; then %service_del_postun sapconf.service # Package removal, not upgrade - cleanup # remove drop-in file for ulimit settings if [ -f /etc/security/limits.d/sapconf-nofile.conf ]; then echo "removing no longer needed file '/etc/security/limits.d/sapconf-nofile.conf'" rm -f /etc/security/limits.d/sapconf-nofile.conf fi rm -f /run/sapconf/active /var/lib/sapconf/*profile rm -rf /var/lib/sapconf/saved_state fi # remove no longer needed UserTasksMax setting, if still available SAP_LOGIN_FILE=/etc/systemd/logind.conf.d/sap.conf if [ -f $SAP_LOGIN_FILE ]; then echo "removing no longer needed file '$SAP_LOGIN_FILE'" rm -rf $SAP_LOGIN_FILE fi %posttrans -p /bin/bash # Use a real bash script with an explicit "exit 0" at the end to be by default fail safe # an explicit "exit 1" must be use to enforce package install/upgrade/erase failure where needed # see the "Shared_libraries" section in http://en.opensuse.org/openSUSE:Packaging_scriptlet_snippets # Begin refresh systemd units and clean up possibly obsolete systemd units # The following is a generic way how to refresh and/or clean up systemd units. # A systemd unit may need a refresh after updating a package when the new package # had installed a changed systemd unit file for an enabled systemd unit. # A systemd unit may become obsolete by updating a package (see bnc#904215). # A systemd unit is considered to have become obsolete when the systemd # symlink /etc/systemd/system/.../unit_name -> /path/to/unit_file is broken. # When during package update the new package does no longer provide a unit file # then the systemd symlink becomes broken after the files of the old package # had been actually removed by RPM. # According to /usr/share/doc/packages/rpm/manual/triggers and according # to https://en.opensuse.org/openSUSE:Packaging_scriptlet_snippets#Scriptlet_Ordering # and http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Scriptlet_Ordering # from the new package only "posttrans of new package" is run after "removal of old package" # so that the new package must do the clean up as RPM posttrans scriptlet. if systemctl --quiet is-enabled sapconf.service 2>/dev/null; then # Refresh still valid enabled systemd units and clean up possibly obsoleted systemd units: # Enforce systemd to use the current unit file which is usually the unit file of the new package # but also in case of custom units (that use other unit files) a "reenable" won't hurt because # "reenable" does not implicitly stop a running service which is "the right thing" because # a RPM package installation must not automatically disrupt (restart) a running service. # Using "--force reenable" is essential to clean up possibly conflicting/broken symlinks. # (without "|| :" build fails with "Failed to get D-Bus connection: No connection to service manager. posttrans script ... failed"): systemctl --quiet --force reenable sapconf.service 2>/dev/null || : else # Refresh still valid disabled systemd units and clean up possibly obsoleted systemd units: # First using "--force reenable" is essential to clean up possibly conflicting/broken symlinks # because there is no "--force disable" that would clean up possibly conflicting/broken symlinks # see https://bugzilla.opensuse.org/show_bug.cgi?id=904215#c34 # so that first the unit has a clean state and then it is set back to disabled (as it was before). # If a disabled systemd unit has become obsoleted, "systemctl --force reenable" will clean it up # which means the unit gets removed and the subsequent "systemctl disable" will do nothing. # (without "|| :" build fails with "Failed to get D-Bus connection: No connection to service manager. posttrans script ... failed"): systemctl --quiet --force reenable sapconf.service 2>/dev/null || : systemctl --quiet disable sapconf.service 2>/dev/null || : fi rm -f /run/sapconf_during_pkg_inst if [ -f /tmp/initial_sapconf_inst ]; then # package initial install rm -f /tmp/initial_sapconf_inst || : # if saptune is active - stop and disable sapconf service # (jsc#SLE-10987 decision) saptune_active=no if systemd-detect-virt -q -r; then # running in chroot - systemctl is-active/start/stop does not work as # expected - acts as 'NOPs' and returns '0', but enabel/disable does work if [[ $(ls /etc/systemd/system/multi-user.target.wants/saptune.service 2>/dev/null) || $(cat /etc/tuned/active_profile 2>/dev/null) == "saptune" || $(ls -A /var/lib/saptune/saved_state 2>/dev/null) || $(ls -A /run/saptune/saved_state 2>/dev/null) ]]; then echo "Running in chroot, but detected that saptune is enabled or active. Disable sapconf service" systemctl disable sapconf.service || : saptune_active=yes #else - do not change system preset fi else if (systemctl -q is-active saptune) || (systemctl -q is-enabled saptune 2>/dev/null) || [[ $(cat /etc/tuned/active_profile 2>/dev/null) == "saptune" || $(ls -A /var/lib/saptune/saved_state 2>/dev/null) || $(ls -A /run/saptune/saved_state 2>/dev/null) ]]; then echo "saptune is enabled or active, stop and disable sapconf service" systemctl stop sapconf.service || : systemctl disable sapconf.service || : saptune_active=yes fi fi if [ "$saptune_active" == "no" ]; then td_profile=$(cat /etc/tuned/active_profile 2>/dev/null) || : if [ "$td_profile" != "" ]; then echo "found non empty active tuned profile ($td_profile), not starting sapconf service" elif [ -f /run/sapconf/active ]; then echo "found '/run/sapconf/active' file, seems sapconf already runing. So doing nothing." else echo "starting sapconf service" systemctl start sapconf.service || : fi fi else # package update # check sapconf service state before update sapconfServEnable=false sapconfServActive=false if [ -f /run/sapconf_pre_enblss_found ] && [ -f /run/sapconf_pre_actss_found ]; then echo "sapconf service was active and enabled before, stay with it" rm -f /run/sapconf_pre_enblss_found /run/sapconf_pre_actss_found || : sapconfServEnable=true sapconfServActive=true fi if [ -f /run/sapconf_pre_enblss_found ]; then echo "sapconf service was enabled before, stay with it" rm -f /run/sapconf_pre_enblss_found || : sapconfServEnable=true fi if [ -f /run/sapconf_pre_actss_found ]; then echo "sapconf service was active before, stay with it" rm -f /run/sapconf_pre_actss_found || : sapconfServActive=true fi # if sapconf with tuned support was not used - stop and disable sapconf service # (jsc#SLE-10987 decision) if [ ! -f /run/sapconf/active ] && [ -f /run/sapconf_tuned_removal_started ]; then echo "sapconf with tuned support was not used" if [ "$sapconfServEnable" == "true" ]; then echo "but sapconf.service was enabled, so skip disable sapconf service" else echo "disable sapconf service" systemctl disable sapconf.service || : fi if [ "$sapconfServActive" == "true" ]; then echo "but sapconf.service was active, so skip stopping sapconf service" else echo "stop sapconf service" systemctl stop sapconf.service || : fi fi # if sapconf with tuned support was used - stop and disable tuned service # (jsc#SLE-10987 decision) # and enable and start sapconf service (bsc#1176061) if [ -f /run/sapconf/active ] && [ -f /run/sapconf_tuned_removal_started ]; then (echo "sapconf with tuned support was used, stop and disable tuned service, enable and start sapconf service"; systemctl stop tuned.service; systemctl disable tuned.service; systemctl enable sapconf.service; systemctl restart sapconf.service) || : fi # if saptune is active - stop and disable sapconf service # (jsc#SLE-10987 decision) systemctl -q is-active saptune || systemctl -q is-enabled saptune 2>/dev/null || [[ $(cat /etc/tuned/active_profile 2>/dev/null) == "saptune" || $(ls -A /var/lib/saptune/saved_state 2>/dev/null) || $(ls -A /run/saptune/saved_state 2>/dev/null) ]] && (echo "saptune is enabled or active, stop and disable sapconf service"; systemctl stop sapconf.service; systemctl disable sapconf.service) || : # if sapconf is/was active - reload new configuration if systemctl -q is-active sapconf; then /usr/bin/md5sum /etc/sysconfig/sapconf > /tmp/sapconf_sys_md5_post || : if ! (diff /tmp/sapconf_sys_md5_pre /tmp/sapconf_sys_md5_post >/dev/null 2>&1); then # the config in /etc/sysconfig/sapconf was changed, # if not already reloaded by tuned transfer - reload config if [ ! -f /run/sapconf_tuned_removal_started ]; then echo "sapconf service is active, reload config" systemctl reload sapconf.service || : fi else echo "config in /etc/sysconfig/sapconf not changed, no need to reload config" fi # saftety net - check if really tuned. if [[ ! -f /run/sapconf/active || ! $(ls -A /var/lib/sapconf/saved_state 2>/dev/null) ]]; then echo "sapconf.service is active, but the tunings seems to be not in place, restarting..." systemctl restart sapconf.service || : fi fi # cleanup 'sapconf with tuned support' indicator rm -f /run/sapconf_tuned_removal_started || : # remove active indicator, so that a restart of sapconf after the package # installation will work correctly, side effect found by bsc#1176061 ! (systemctl -q is-active sapconf) && rm -f /run/sapconf/active || : fi exit 0 %files %defattr(-,root,root) %{_sbindir}/sapconf_check %{_sbindir}/rcsapconf %{_unitdir}/sapconf.service %dir %{_libexecdir}/%{name} %{_libexecdir}/%{name}/* %{_mandir}/man*/* %{_fillupdir}/* %dir %{_localstatedir}/lib/%{name} %dir %{_localstatedir}/lib/%{name}/saved_configs %dir %{_libexecdir}/supportconfig %dir %{_libexecdir}/supportconfig/plugins %{_libexecdir}/supportconfig/plugins/%{name} #noreplace - to get sapconf.rpmnew, if file on disk has changed %config(noreplace) %{_sysconfdir}/logrotate.d/%{name} # Created at run-time by sapconf %attr(0755,root,root) %ghost %dir %{_localstatedir}/lib/%{name}/saved_state %changelog
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor