59 lines
2.3 KiB
Diff
59 lines
2.3 KiB
Diff
|
From 0fab85013ef072414d780daf5b08af761ccf6db2 Mon Sep 17 00:00:00 2001
|
||
|
From: Jan Grulich <jgrulich@redhat.com>
|
||
|
Date: Tue, 7 Apr 2015 12:56:27 +0200
|
||
|
Subject: [PATCH 5/6] Check whether 99-sap-limits.conf file exists to prevent
|
||
|
an error while trying to update it Also check whether required configuration
|
||
|
is already configured in limits.conf file
|
||
|
|
||
|
BUG:1205229
|
||
|
---
|
||
|
sapconf | 22 ++++++++++++++++++----
|
||
|
1 file changed, 18 insertions(+), 4 deletions(-)
|
||
|
mode change 100644 => 100755 sapconf
|
||
|
|
||
|
diff --git a/sapconf b/sapconf
|
||
|
old mode 100644
|
||
|
new mode 100755
|
||
|
index 5bd8dcd..58096fe
|
||
|
--- a/sapconf
|
||
|
+++ b/sapconf
|
||
|
@@ -383,17 +383,31 @@ fi #[ $ec -eq 0 ]
|
||
|
function update_limits_conf() {
|
||
|
local date olds oldval news newval LIMITS
|
||
|
LIMITS=/etc/security/limits.d/99-sap-limits.conf
|
||
|
+ LIMITS_CONF=/etc/security/limits.conf
|
||
|
date=`date -u +"%Y-%m-%d %H:%M:%S %Z"`
|
||
|
newval=($1 $2 $3 $4)
|
||
|
news=${newval[*]}
|
||
|
- olds=`tac "$LIMITS" | grep -E "^[^#]*$1" | grep "$2" | grep -m1 "$3"`
|
||
|
+
|
||
|
+ olds=`tac "$LIMITS_CONF" | grep -E "^[^#]*$1" | grep "$2" | grep -m1 "$3"`
|
||
|
if [ $? -eq 0 ]; then # entry there, update
|
||
|
oldval=($olds);
|
||
|
if [ "${oldval[3]}" != "${newval[3]}" ]; then
|
||
|
- sed -i "s@$olds@# Changed by sapconf on $date\n#&\n$news@" "$LIMITS"
|
||
|
+ sed -i "s/$olds/# Changed by sapconf on $date\n#\ &\n$news/" "$LIMITS_CONF"
|
||
|
+ fi
|
||
|
+ else
|
||
|
+ if [ -e "$LIMITS" ]; then
|
||
|
+ olds=`tac "$LIMITS" | grep -E "^[^#]*$1" | grep "$2" | grep -m1 "$3"`
|
||
|
+ if [ $? -eq 0 ]; then # entry there, update
|
||
|
+ oldval=($olds);
|
||
|
+ if [ "${oldval[3]}" != "${newval[3]}" ]; then
|
||
|
+ sed -i "s/$olds/# Changed by sapconf on $date\n#\ &\n$news/" "$LIMITS"
|
||
|
+ fi
|
||
|
+ else # no entry, make one
|
||
|
+ echo -e "# Added by sapconf on $date\n$news" >> "$LIMITS"
|
||
|
+ fi
|
||
|
+ else
|
||
|
+ echo -e "# Added by sapconf on $date\n$news" >> "$LIMITS"
|
||
|
fi
|
||
|
- else # no entry, make one
|
||
|
- echo -e "# Added by sapconf on $date\n$news" >> "$LIMITS"
|
||
|
fi
|
||
|
}
|
||
|
|
||
|
--
|
||
|
2.1.0
|
||
|
|