commit f9de6a3d6e119542b1ef60a0c0884bbe069ab29e Author: Mikhail Novosyolov Date: Tue Nov 22 10:33:34 2022 +0300 init diff --git a/limits.spec b/limits.spec new file mode 100644 index 0000000..f500a7c --- /dev/null +++ b/limits.spec @@ -0,0 +1,69 @@ +%define _systemd_confdir /usr/lib/systemd/system.conf.d + +Summary: Set kernel limits +Name: limits +Version: 1 +Release: 1 +License: BSD +Group: System/Configuration/Boot and Init +Url: https://abf.io/import/limits +BuildArch: noarch + +%description +Set kernel limits + +#------------------------------------------------------------------ + +%package big +Summary: Set big enough kernel limits + +%description big +Set big enough kernel limits + +%files big +%config(noreplace) %{_sysconfdir}/security/limits.d/95-%{name}-big.conf +# no %%config(noreplace), it can be overriden in /etc/systemd/system.conf.d/ +%{_systemd_confdir}/10-%{name}-big.conf + +#------------------------------------------------------------------ + +%prep + +%install +set -e +set -u + +mkdir -p %{buildroot} +mkdir -p %{buildroot}%{_sysconfdir}/security/limits.d +mkdir -p %{buildroot}%{_systemd_confdir} + +# took some ideas from https://packages.altlinux.org/ru/sisyphus/srpms/pam-limits-desktop/ + +# the same as default config in the "pam" package +NPROC_SOFT=4096 +# 2^16 +NOFILE_SOFT=65536 +# 512*1024, as default @HIGH_RLIMIT_NOFILE@ in systemd +NOFILE_HARD=524288 + +cat > %{buildroot}%{_sysconfdir}/security/limits.d/95-%{name}-big.conf << EOF +# limits.conf(5) +* soft nproc $NPROC_SOFT +* hard nproc unlimited +* soft nofile $NOFILE_SOFT +* hard nofile $NOFILE_HARD +EOF + +# https://github.com/systemd/systemd/issues/25478 +cat > %{buildroot}%{_systemd_confdir}/10-%{name}-big.conf << EOF +# system.conf.d(5), systemd.exec(5) +# Example commands to read current values: +# systemd-analyze cat-config systemd/system.conf +# systemctl show -p DefaultLimitNOFILESoft +# cat /proc/PID/limits +[Manager] +DefaultLimitNPROC=$NPROC_SOFT:infinity +DefaultLimitNOFILE=$NOFILE_SOFT:$NOFILE_HARD +EOF + +set +u