Gentoo Archives: gentoo-commits

From: William Hubbs <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/openrc:0.21.x commit in: init.d/
Date: Thu, 25 Aug 2016 22:03:13
Message-Id: 1472162326.b888f1a8e21008f45105ad2fdc84a5d579892eb5.williamh@OpenRC
1 commit: b888f1a8e21008f45105ad2fdc84a5d579892eb5
2 Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
3 AuthorDate: Tue Aug 23 22:48:39 2016 +0000
4 Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
5 CommitDate: Thu Aug 25 21:58:46 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=b888f1a8
7
8 Add modules-load.d support
9
10 init.d/Makefile | 4 +--
11 init.d/modules-load.in | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
12 init.d/modules.in | 1 +
13 3 files changed, 76 insertions(+), 2 deletions(-)
14
15 diff --git a/init.d/Makefile b/init.d/Makefile
16 index f256095..ad90f95 100644
17 --- a/init.d/Makefile
18 +++ b/init.d/Makefile
19 @@ -19,10 +19,10 @@ SRCS-FreeBSD= hostid.in moused.in newsyslog.in pf.in rarpd.in rc-enabled.in \
20 rpcbind.in savecore.in syslogd.in
21 # These are FreeBSD specific
22 SRCS-FreeBSD+= adjkerntz.in devd.in dumpon.in encswap.in ipfw.in \
23 - mixer.in nscd.in powerd.in syscons.in
24 + modules.in modules-load.in mixer.in nscd.in powerd.in syscons.in
25
26 SRCS-Linux= binfmt.in devfs.in dmesg.in hwclock.in consolefont.in keymaps.in \
27 - killprocs.in modules.in mount-ro.in mtab.in numlock.in \
28 + killprocs.in modules.in modules-load.in mount-ro.in mtab.in numlock.in \
29 procfs.in net-online.in sysfs.in termencoding.in tmpfiles.dev.in
30
31 # Generic BSD scripts
32
33 diff --git a/init.d/modules-load.in b/init.d/modules-load.in
34 new file mode 100644
35 index 0000000..8c19a36
36 --- /dev/null
37 +++ b/init.d/modules-load.in
38 @@ -0,0 +1,73 @@
39 +#!@SBINDIR@/openrc-run
40 +# Copyright (c) 2016 The OpenRC Authors.
41 +# See the Authors file at the top-level directory of this distribution and
42 +# https://github.com/OpenRC/openrc/blob/master/AUTHORS
43 +#
44 +# This file is part of OpenRC. It is subject to the license terms in
45 +# the LICENSE file found in the top-level directory of this
46 +# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
47 +# This file may not be copied, modified, propagated, or distributed
48 +# except according to the terms contained in the LICENSE file.
49 +
50 +description="Loads a list of modules from systemd-compatible locations."
51 +
52 +depend()
53 +{
54 + keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
55 +}
56 +
57 +modules_dirs="/usr/lib/modules-load.d /run/modules-load.d /etc/modules-load.d"
58 +
59 +find_modfiles()
60 +{
61 + local basenames files x y
62 + for x in $modules_dirs; do
63 + [ ! -d $x ] && continue
64 + for y in $x/*.conf; do
65 + [ -f $y ] && basenames="${basenames}\n${y##*/}"
66 + done
67 + done
68 + basenames=$(printf "$basenames" | sort -u)
69 + for x in $basenames; do
70 + for y in $modules_dirs; do
71 + [ -r $y/$x ] &&
72 + path=$y/$x
73 + done
74 + files="$files $path"
75 + done
76 + echo $files
77 +}
78 +
79 +load_modules()
80 +{
81 + local file m modules rc x
82 + file=$1
83 + [ -z "$file" ] && return 0
84 + while read m x; do
85 + case $m in
86 + \;) continue ;;
87 + \#) continue ;;
88 + *) modules="$modules $m"
89 + ;;
90 + esac
91 + done < $file
92 + for x in $modules; do
93 + ebegin "Loading module $x"
94 + case "$RC_UNAME" in
95 + FreeBSD) kldload "$x"; rc=$? ;;
96 + linux) modprobe -q "$x"; rc=$? ;;
97 + *) ;;
98 + esac
99 + eend $rc "Failed to load $x"
100 + done
101 +}
102 +
103 +start()
104 +{
105 + local x
106 + files=$(find_modfiles)
107 + for x in $files; do
108 + load_modules $x
109 + done
110 + return 0
111 +}
112
113 diff --git a/init.d/modules.in b/init.d/modules.in
114 index ff1dee4..ddb8c9b 100644
115 --- a/init.d/modules.in
116 +++ b/init.d/modules.in
117 @@ -14,6 +14,7 @@ description="Loads a user defined list of kernel modules."
118 depend()
119 {
120 use isapnp
121 + want modules-load
122 keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
123 }