From cb9788a273f6b60fbe2b7178cbdaec0d2543e544 Mon Sep 17 00:00:00 2001 From: spiritlhl <103393591+spiritLHLS@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:39:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E9=99=A4=E8=BF=9B=E7=A8=8B=E9=99=90?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- repair_scripts/unlimit.sh | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 repair_scripts/unlimit.sh diff --git a/repair_scripts/unlimit.sh b/repair_scripts/unlimit.sh new file mode 100644 index 0000000..a5c6959 --- /dev/null +++ b/repair_scripts/unlimit.sh @@ -0,0 +1,42 @@ +#!/bin/bash +#by spiritlhl +#from https://github.com/spiritLHLS/one-click-installation-script +#version: 2024.06.20 + +# 更新 /etc/security/limits.conf 文件 +echo "更新 /etc/security/limits.conf 文件..." +sed -i '/^root soft nofile /d' /etc/security/limits.conf +sed -i '/^root hard nofile /d' /etc/security/limits.conf +sed -i '/^\* soft nofile /d' /etc/security/limits.conf +sed -i '/^\* hard nofile /d' /etc/security/limits.conf +echo "root soft nofile 1000000" >> /etc/security/limits.conf +echo "root hard nofile 1000000" >> /etc/security/limits.conf +echo "* soft nofile 1000000" >> /etc/security/limits.conf +echo "* hard nofile 1000000" >> /etc/security/limits.conf + +# 更新 /etc/pam.d/common-session 文件 +echo "更新 /etc/pam.d/common-session 文件..." +if ! grep -q "session required pam_limits.so" /etc/pam.d/common-session; then + echo "session required pam_limits.so" >> /etc/pam.d/common-session +fi + +# 更新 /etc/pam.d/common-session-noninteractive 文件 +echo "更新 /etc/pam.d/common-session-noninteractive 文件..." +if ! grep -q "session required pam_limits.so" /etc/pam.d/common-session-noninteractive; then + echo "session required pam_limits.so" >> /etc/pam.d/common-session-noninteractive +fi + +# 更新 /etc/systemd/system.conf 文件 +echo "更新 /etc/systemd/system.conf 文件..." +sed -i '/^DefaultLimitNOFILE=/d' /etc/systemd/system.conf +echo "DefaultLimitNOFILE=1000000" >> /etc/systemd/system.conf + +# 更新 /etc/systemd/user.conf 文件 +echo "更新 /etc/systemd/user.conf 文件..." +sed -i '/^DefaultLimitNOFILE=/d' /etc/systemd/user.conf +echo "DefaultLimitNOFILE=1000000" >> /etc/systemd/user.conf + +sleep 1 + +systemctl daemon-reload +echo "请重启服务器使得修改生效"