[arch-projects] [INITSCRIPTS][PATCH] Load sysctl config files from sysctl.d
This patch implement loading of sysctl config files as described in http://0pointer.de/public/systemd-man/sysctl.d.html This is a very conveniant way of configuring sysctl option for sysadmin which can drop sysctl config files inside this directory to enable some feature. Dropping a file like disableipv6.conf inside this directory will disable ipv6 $ cat disableipv6.conf net.ipv6.conf.all.disable_ipv6 = 1 There is atm no package which use this functionnality Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- Makefile | 4 +++- arch-sysctl | 29 +++++++++++++++++++++++++++++ rc.multi | 4 ++-- tmpfiles.conf | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100755 arch-sysctl diff --git a/Makefile b/Makefile index 4916387..a6262e2 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ DIRS := \ /usr/sbin \ /etc/tmpfiles.d \ /usr/lib/tmpfiles.d \ + /etc/sysctl.d \ + /usr/lib/sysctl.d \ /usr/lib/initscripts \ /etc/bash_completion.d \ /usr/share/zsh/site-functions @@ -25,7 +27,7 @@ install: minilogd installdirs install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/etc/profile.d locale.sh install -m755 -t $(DESTDIR)/usr/sbin minilogd rc.d - install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles + install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d diff --git a/arch-sysctl b/arch-sysctl new file mode 100755 index 0000000..4856df6 --- /dev/null +++ b/arch-sysctl @@ -0,0 +1,29 @@ +#!/bin/bash +# +# /usr/lib/initscripts/arch-sysctl +# +# Load sysctl configuration files following +# http://0pointer.de/public/systemd-man/sysctl.d.html +# + +shopt -s nullglob + +declare -a sysctl_d=( + /usr/lib/sysctl.d/*.conf + /etc/sysctl.d/*.conf + /run/sysctl.d/*.conf + /etc/sysctl.conf +) +declare -A fragments + +# files declared later in the sysctl_d array will override earlier +# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. +for path in "${sysctl_d[@]}"; do + [[ -f $path ]] && fragments[${path##*/}]=$path +done + +for path in "${fragments[@]}"; do + sysctl -q -p "$path" +done + +# vim: set ts=2 sw=2 noet: diff --git a/rc.multi b/rc.multi index 16fa83a..295efc6 100755 --- a/rc.multi +++ b/rc.multi @@ -8,8 +8,8 @@ run_hook multi_start -# Load sysctl variables if sysctl.conf is present -[[ -r /etc/sysctl.conf ]] && sysctl -q -p &>/dev/null +# Load sysctl config files +[[ -x /usr/lib/initscripts/arch-tmpfiles ]] && /usr/lib/initscripts/arch-tmpfiles # Start daemons for daemon in "${DAEMONS[@]}"; do diff --git a/tmpfiles.conf b/tmpfiles.conf index 7dd1358..93fe532 100644 --- a/tmpfiles.conf +++ b/tmpfiles.conf @@ -4,6 +4,7 @@ D /tmp 1777 root root D /run/daemons 0755 root root +d /run/sysctl.d 0755 root root d /tmp/.X11-unix 1777 root root d /tmp/.ICE-unix 1777 root root -- Sebastien "Seblu" Luttringer
On Wed, Aug 31, 2011 at 5:33 PM, Sebastien Luttringer <seblu@seblu.net> wrote:
This patch implement loading of sysctl config files as described in http://0pointer.de/public/systemd-man/sysctl.d.html
This is a very conveniant way of configuring sysctl option for sysadmin which can drop sysctl config files inside this directory to enable some feature.
Dropping a file like disableipv6.conf inside this directory will disable ipv6 $ cat disableipv6.conf net.ipv6.conf.all.disable_ipv6 = 1
There is atm no package which use this functionnality
Signed-off-by: Sebastien Luttringer <seblu@seblu.net> --- Makefile | 4 +++- arch-sysctl | 29 +++++++++++++++++++++++++++++ rc.multi | 4 ++-- tmpfiles.conf | 1 + 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100755 arch-sysctl
diff --git a/Makefile b/Makefile index 4916387..a6262e2 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ DIRS := \ /usr/sbin \ /etc/tmpfiles.d \ /usr/lib/tmpfiles.d \ + /etc/sysctl.d \ + /usr/lib/sysctl.d \ /usr/lib/initscripts \ /etc/bash_completion.d \ /usr/share/zsh/site-functions @@ -25,7 +27,7 @@ install: minilogd installdirs install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs install -m755 -t $(DESTDIR)/etc/profile.d locale.sh install -m755 -t $(DESTDIR)/usr/sbin minilogd rc.d - install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles + install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf install -m644 -T bash-completion $(DESTDIR)/etc/bash_completion.d/rc.d install -m644 -T zsh-completion $(DESTDIR)/usr/share/zsh/site-functions/_rc.d diff --git a/arch-sysctl b/arch-sysctl new file mode 100755 index 0000000..4856df6 --- /dev/null +++ b/arch-sysctl @@ -0,0 +1,29 @@ +#!/bin/bash +# +# /usr/lib/initscripts/arch-sysctl +# +# Load sysctl configuration files following +# http://0pointer.de/public/systemd-man/sysctl.d.html +# + +shopt -s nullglob + +declare -a sysctl_d=( + /usr/lib/sysctl.d/*.conf + /etc/sysctl.d/*.conf + /run/sysctl.d/*.conf + /etc/sysctl.conf +) +declare -A fragments + +# files declared later in the sysctl_d array will override earlier +# Example: `/etc/sysctl.d/foo.conf' supersedes `/usr/lib/sysctl.d/foo.conf'. +for path in "${sysctl_d[@]}"; do + [[ -f $path ]] && fragments[${path##*/}]=$path +done + +for path in "${fragments[@]}"; do + sysctl -q -p "$path" +done + +# vim: set ts=2 sw=2 noet: diff --git a/rc.multi b/rc.multi index 16fa83a..295efc6 100755 --- a/rc.multi +++ b/rc.multi @@ -8,8 +8,8 @@
run_hook multi_start
-# Load sysctl variables if sysctl.conf is present -[[ -r /etc/sysctl.conf ]] && sysctl -q -p &>/dev/null +# Load sysctl config files +[[ -x /usr/lib/initscripts/arch-tmpfiles ]] && /usr/lib/initscripts/arch-tmpfiles falure!
# Start daemons for daemon in "${DAEMONS[@]}"; do diff --git a/tmpfiles.conf b/tmpfiles.conf index 7dd1358..93fe532 100644 --- a/tmpfiles.conf +++ b/tmpfiles.conf @@ -4,6 +4,7 @@
D /tmp 1777 root root D /run/daemons 0755 root root +d /run/sysctl.d 0755 root root
d /tmp/.X11-unix 1777 root root d /tmp/.ICE-unix 1777 root root -- Sebastien "Seblu" Luttringer
-- Sébastien Luttringer www.seblu.net
On Wed, Aug 31, 2011 at 05:35:38PM +0200, Seblu wrote:
-# Load sysctl variables if sysctl.conf is present -[[ -r /etc/sysctl.conf ]] && sysctl -q -p &>/dev/null +# Load sysctl config files +[[ -x /usr/lib/initscripts/arch-tmpfiles ]] && /usr/lib/initscripts/arch-tmpfiles falure!
Not to mention you still haven't removed the tmpfiles.conf line that we don't want.
# Start daemons for daemon in "${DAEMONS[@]}"; do diff --git a/tmpfiles.conf b/tmpfiles.conf index 7dd1358..93fe532 100644 --- a/tmpfiles.conf +++ b/tmpfiles.conf @@ -4,6 +4,7 @@
D /tmp 1777 root root D /run/daemons 0755 root root +d /run/sysctl.d 0755 root root
d /tmp/.X11-unix 1777 root root d /tmp/.ICE-unix 1777 root root -- Sebastien "Seblu" Luttringer
-- Sébastien Luttringer www.seblu.net
participants (3)
-
Dave Reisner
-
Sebastien Luttringer
-
Seblu