!238 修改了OM中RemoveIPC设置为no未生效的问题,支持修改麒麟系统RemoveIPC

Merge pull request !238 from 陈栋/master
This commit is contained in:
opengauss-bot
2020-09-19 20:16:45 +08:00
committed by Gitee
2 changed files with 13 additions and 36 deletions

View File

@ -426,7 +426,6 @@ def doCheckOS(itemNumber):
"""
if (itemNumber == 'A1'):
checkOSVersion()
checkOSConfig()
elif (itemNumber == 'A2'):
checkKernelVersion()
elif (itemNumber == 'A3'):
@ -1408,27 +1407,6 @@ def getTmpFile():
else:
return tmpFile
def checkOSConfig():
'''
function : Check the parameters in logind.conf
'''
g_logger.debug("Checking OS configuration.")
try:
cmd = "cat /etc/systemd/logind.conf | " + \
"grep RemoveIPC | grep -o -E '(yes|no)' | tail -1"
(status, output, outputMap) = getCmdOutput(cmd)
for hostName in outputMap:
result = outputMap[hostName]
if (result.strip() == "yes"):
g_logger.logExit("[%s]: \n" % hostName +
ErrorCode.GAUSS_516["GAUSS_51632"] % cmd +
" Error: \n You should set RemoveIPC=no " + \
"in /etc/systemd/logind.conf, "+ \
"and restart the server")
except Exception as e:
g_logger.debug(str(e))
g_logger.debug("Successfully checked OS config.")
def main():
"""
main function

View File

@ -798,27 +798,26 @@ def disRemoveIPC():
"""
g_logger.debug("disbale RemoveIPC.")
distName = g_Platform.getCurrentPlatForm()[0]
if distName.upper() == "OPENEULER":
if distName.upper() in ("OPENEULER", "KYLIN"):
cmd = "setenforce 0"
subprocess.getstatusoutput(cmd)
initFile = "/usr/lib/systemd/system/systemd-logind.service"
if os.path.exists(initFile):
# 1.close thp
close_cmd = """(if [ `systemctl show systemd-logind |
grep RemoveIPC` != "RemoveIPC=no" ];
then echo 'RemoveIPC=no' >> /usr/lib/systemd
/system/systemd-logind.service;
sed -i '/RemoveIPC=yes/'d
/usr/lib/systemd/system/systemd-logind.service;fi;)"""
close_cmd = "if [ `systemctl show systemd-logind | " \
"grep RemoveIPC` != \"RemoveIPC=no\" ]; " \
"then echo 'RemoveIPC=no' >> " \
"/usr/lib/systemd/system/systemd-logind.service; " \
"sed -i '/RemoveIPC=yes/'d " \
"/usr/lib/systemd/system/systemd-logind.service; fi;"
disableRemoveIPCLog(close_cmd)
initFile = "/etc/systemd/logind.conf"
if os.path.exists(initFile):
close_cmd = """(if [ `loginctl show-session | grep RemoveIPC`
!= "RemoveIPC=no" ];
then
echo 'RemoveIPC=no' >> /etc/systemd/logind.conf;
sed -i '/RemoveIPC=yes/'d /etc/systemd/logind.conf;
fi;)"""
close_cmd = "if [ `loginctl show-session | " \
"grep RemoveIPC` != \"RemoveIPC=no\" ]; " \
"then echo 'RemoveIPC=no' >> " \
"/etc/systemd/logind.conf; " \
"sed -i '/RemoveIPC=yes/'d " \
"/etc/systemd/logind.conf; fi;"
disableRemoveIPCLog(close_cmd)
cmd = "systemctl daemon-reload"
disableRemoveIPCLog(cmd)