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