Skip to content

Commit d473332

Browse files
committed
sysctl kernel-uname_r.conf: separate service units, kernel usr merge
We used to pull in the kernel-specific sysctl settings via an ExecStartPre directive in systemd-sysctl.service. Create a separate service instead, which is pulled in by systemd-sysctl. This is more transparent, and allows more fine-grained control. In preparation of the kernel /usr merge (bsc#1184804), create two separate services boot-sysctl. service and kernel-sysctl.service which work with kernel packages pre- and post- usrmerge, respectively. Only one of them will be actually started because of a Condition directive. "boot-sysctl.service" can be dropped when we may assume that no users keep old kernel packages around that install their sysctl settings under /boot.
1 parent 3a2abbe commit d473332

4 files changed

+50
-7
lines changed

50-kernel-uname_r.conf

-5
This file was deleted.

boot-sysctl.service

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Unit]
2+
Description=Apply Kernel Variables for %v from /boot
3+
DefaultDependencies=no
4+
Conflicts=shutdown.target
5+
Before=systemd-sysctl.service
6+
After=systemd-modules-load.service
7+
ConditionPathExists=!/usr/lib/modules/%v/sysctl.conf
8+
RequiresMountsFor=/boot
9+
10+
[Service]
11+
Type=oneshot
12+
ExecStart=/usr/lib/systemd/systemd-sysctl /boot/sysctl.conf-%v
13+
RemainAfterExit=yes
14+
15+
[Install]
16+
WantedBy=systemd-sysctl.service

kernel-sysctl.service

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[Unit]
2+
Description=Apply Kernel Variables for %v
3+
DefaultDependencies=no
4+
Conflicts=shutdown.target
5+
Before=systemd-sysctl.service
6+
After=systemd-modules-load.service
7+
ConditionPathExists=/usr/lib/modules/%v/sysctl.conf
8+
RequiresMountsFor=/boot
9+
10+
[Service]
11+
Type=oneshot
12+
ExecStart=/usr/lib/systemd/systemd-sysctl /usr/lib/modules/%v/sysctl.conf
13+
RemainAfterExit=yes
14+
15+
[Install]
16+
WantedBy=systemd-sysctl.service

suse-module-tools.spec

+18-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@
2424
%if 0%{?suse_version} >= 1550
2525
%global modprobe_dir /usr/lib/modprobe.d
2626
%global depmod_dir /usr/lib/depmod.d
27+
%global with_kernel_sysctl 1
28+
# boot_sysctl may be dropped on TW when we can assume that nobody keeps
29+
# kernel packages around that store sysctl files under /boot
30+
%bcond_without boot_sysctl
2731
%else
2832
%global modprobe_dir /lib/modprobe.d
2933
%global depmod_dir /lib/depmod.d
34+
%global with_kernel_sysctl 0
35+
%global with_boot_sysctl 1
3036
%endif
37+
%global sysctl_dropin %{_unitdir}/systemd-sysctl.service.d/50-kernel-uname_r.conf
3138

3239
# List of legacy file systems to be blacklisted by default
3340
%global fs_blacklist adfs affs bfs befs cramfs efs erofs exofs freevxfs hfs hpfs jfs minix nilfs2 ntfs omfs qnx4 qnx6 sysv ufs
@@ -132,9 +139,17 @@ install -pm 755 "regenerate-initrd-posttrans" "%{buildroot}/usr/lib/module-init-
132139
install -d -m 755 "%{buildroot}%{_prefix}/bin"
133140
install -pm 755 kmp-install "%{buildroot}%{_bindir}/"
134141

135-
# systemd service to load /boot/sysctl.conf-`uname -r`
142+
# systemd service(s) to load kernel-specific sysctl settings
136143
install -d -m 755 "%{buildroot}%{_unitdir}/systemd-sysctl.service.d"
137-
install -pm 644 50-kernel-uname_r.conf "%{buildroot}%{_unitdir}/systemd-sysctl.service.d"
144+
echo '[Unit]' >"%{buildroot}%{sysctl_dropin}"
145+
%if 0%{?with_kernel_sysctl}
146+
install -m 644 kernel-sysctl.service "%{buildroot}%{_unitdir}"
147+
echo 'Wants=kernel-sysctl.service' >>"%{buildroot}%{sysctl_dropin}"
148+
%endif
149+
%if 0%{?with_boot_sysctl}
150+
install -m 644 boot-sysctl.service "%{buildroot}%{_unitdir}"
151+
echo 'Wants=boot-sysctl.service' >>"%{buildroot}%{sysctl_dropin}"
152+
%endif
138153

139154
# Ensure that the sg driver is loaded early (bsc#1036463)
140155
# Not needed in SLE11, where sg is loaded via udev rule.
@@ -208,6 +223,7 @@ exit 0
208223
%{_bindir}/kmp-install
209224
/usr/lib/module-init-tools
210225
%exclude /usr/lib/module-init-tools/weak-modules
226+
%{_unitdir}/*.service
211227
%{_unitdir}/systemd-sysctl.service.d
212228
%{_modulesloaddir}
213229
%ifarch ppc64 ppc64le

0 commit comments

Comments
 (0)