change "while read x" to cope with EOF without newline
[dracut.git] / modules.d / 00systemd / module-setup.sh
blob3403b4b73744890a592655d2a1a54b6b16d948b8
1 #!/bin/bash
3 # called by dracut
4 check() {
5 [[ $mount_needs ]] && return 1
6 if require_binaries $systemdutildir/systemd; then
7 SYSTEMD_VERSION=$($systemdutildir/systemd --version | { read a b a; echo $b; })
8 (( $SYSTEMD_VERSION >= 198 )) && return 0
9 return 255
12 return 1
15 # called by dracut
16 depends() {
17 return 0
20 installkernel() {
21 hostonly='' instmods autofs4 ipv6
22 instmods -s efivarfs
25 # called by dracut
26 install() {
27 local _mods
29 if [[ "$prefix" == /run/* ]]; then
30 dfatal "systemd does not work with a prefix, which contains \"/run\"!!"
31 exit 1
34 inst_multiple -o \
35 $systemdutildir/systemd \
36 $systemdutildir/systemd-cgroups-agent \
37 $systemdutildir/systemd-shutdown \
38 $systemdutildir/systemd-reply-password \
39 $systemdutildir/systemd-fsck \
40 $systemdutildir/systemd-udevd \
41 $systemdutildir/systemd-journald \
42 $systemdutildir/systemd-sysctl \
43 $systemdutildir/systemd-modules-load \
44 $systemdutildir/systemd-vconsole-setup \
45 $systemdutildir/system-generators/systemd-fstab-generator \
46 $systemdutildir/system-generators/systemd-gpt-auto-generator \
48 $systemdsystemunitdir/cryptsetup.target \
49 $systemdsystemunitdir/emergency.target \
50 $systemdsystemunitdir/sysinit.target \
51 $systemdsystemunitdir/basic.target \
52 $systemdsystemunitdir/halt.target \
53 $systemdsystemunitdir/kexec.target \
54 $systemdsystemunitdir/local-fs.target \
55 $systemdsystemunitdir/local-fs-pre.target \
56 $systemdsystemunitdir/remote-fs.target \
57 $systemdsystemunitdir/remote-fs-pre.target \
58 $systemdsystemunitdir/multi-user.target \
59 $systemdsystemunitdir/network.target \
60 $systemdsystemunitdir/network-pre.target \
61 $systemdsystemunitdir/network-online.target \
62 $systemdsystemunitdir/nss-lookup.target \
63 $systemdsystemunitdir/nss-user-lookup.target \
64 $systemdsystemunitdir/poweroff.target \
65 $systemdsystemunitdir/reboot.target \
66 $systemdsystemunitdir/rescue.target \
67 $systemdsystemunitdir/rpcbind.target \
68 $systemdsystemunitdir/shutdown.target \
69 $systemdsystemunitdir/final.target \
70 $systemdsystemunitdir/sigpwr.target \
71 $systemdsystemunitdir/sockets.target \
72 $systemdsystemunitdir/swap.target \
73 $systemdsystemunitdir/timers.target \
74 $systemdsystemunitdir/paths.target \
75 $systemdsystemunitdir/umount.target \
77 $systemdsystemunitdir/sys-kernel-config.mount \
79 $systemdsystemunitdir/kmod-static-nodes.service \
80 $systemdsystemunitdir/systemd-tmpfiles-setup-dev.service \
81 $systemdsystemunitdir/systemd-ask-password-console.path \
82 $systemdsystemunitdir/systemd-udevd-control.socket \
83 $systemdsystemunitdir/systemd-udevd-kernel.socket \
84 $systemdsystemunitdir/systemd-ask-password-plymouth.path \
85 $systemdsystemunitdir/systemd-journald.socket \
86 $systemdsystemunitdir/systemd-journald-audit.socket \
87 $systemdsystemunitdir/systemd-ask-password-console.service \
88 $systemdsystemunitdir/systemd-modules-load.service \
89 $systemdsystemunitdir/systemd-halt.service \
90 $systemdsystemunitdir/systemd-poweroff.service \
91 $systemdsystemunitdir/systemd-reboot.service \
92 $systemdsystemunitdir/systemd-kexec.service \
93 $systemdsystemunitdir/systemd-fsck@.service \
94 $systemdsystemunitdir/systemd-udevd.service \
95 $systemdsystemunitdir/systemd-udev-trigger.service \
96 $systemdsystemunitdir/systemd-udev-settle.service \
97 $systemdsystemunitdir/systemd-ask-password-plymouth.service \
98 $systemdsystemunitdir/systemd-journald.service \
99 $systemdsystemunitdir/systemd-vconsole-setup.service \
100 $systemdsystemunitdir/systemd-random-seed-load.service \
101 $systemdsystemunitdir/systemd-sysctl.service \
103 $systemdsystemunitdir/sysinit.target.wants/systemd-modules-load.service \
104 $systemdsystemunitdir/sysinit.target.wants/systemd-ask-password-console.path \
105 $systemdsystemunitdir/sysinit.target.wants/systemd-journald.service \
106 $systemdsystemunitdir/sockets.target.wants/systemd-udevd-control.socket \
107 $systemdsystemunitdir/sockets.target.wants/systemd-udevd-kernel.socket \
108 $systemdsystemunitdir/sockets.target.wants/systemd-journald.socket \
109 $systemdsystemunitdir/sockets.target.wants/systemd-journald-audit.socket \
110 $systemdsystemunitdir/sockets.target.wants/systemd-journald-dev-log.socket \
111 $systemdsystemunitdir/sysinit.target.wants/systemd-udevd.service \
112 $systemdsystemunitdir/sysinit.target.wants/systemd-udev-trigger.service \
113 $systemdsystemunitdir/sysinit.target.wants/kmod-static-nodes.service \
114 $systemdsystemunitdir/sysinit.target.wants/systemd-tmpfiles-setup-dev.service \
115 $systemdsystemunitdir/sysinit.target.wants/systemd-sysctl.service \
117 $systemdsystemunitdir/ctrl-alt-del.target \
118 $systemdsystemunitdir/reboot.target \
119 $systemdsystemunitdir/systemd-reboot.service \
120 $systemdsystemunitdir/syslog.socket \
122 $systemdsystemunitdir/slices.target \
123 $systemdsystemunitdir/system.slice \
125 $tmpfilesdir/systemd.conf \
127 journalctl systemctl \
128 echo swapoff \
129 kmod insmod rmmod modprobe modinfo depmod lsmod \
130 mount umount reboot poweroff \
131 systemd-cgls systemd-tmpfiles
133 inst_multiple -o \
134 /usr/lib/modules-load.d/*.conf \
135 /usr/lib/sysctl.d/*.conf
137 modules_load_get() {
138 local _line i
139 for i in "$1"/*.conf; do
140 [[ -f $i ]] || continue
141 while read _line || [ -n "$_line" ]; do
142 case $_line in
143 \#*)
145 \;*)
148 echo $_line
149 esac
150 done < "$i"
151 done
154 _mods=$(modules_load_get /usr/lib/modules-load.d)
155 [[ $_mods ]] && instmods $_mods
157 if [[ $hostonly ]]; then
158 inst_multiple -H -o \
159 /etc/systemd/journald.conf \
160 /etc/systemd/system.conf \
161 /etc/hostname \
162 /etc/machine-id \
163 /etc/vconsole.conf \
164 /etc/locale.conf \
165 /etc/modules-load.d/*.conf \
166 /etc/sysctl.d/*.conf \
167 /etc/sysctl.conf
169 _mods=$(modules_load_get /etc/modules-load.d)
170 [[ $_mods ]] && instmods $_mods
173 if ! [[ -e "$initdir/etc/machine-id" ]]; then
174 > "$initdir/etc/machine-id"
177 # install adm user/group for journald
178 inst_multiple nologin
179 egrep '^systemd-journal:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
180 egrep '^adm:' /etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
181 egrep '^systemd-journal:' /etc/group >> "$initdir/etc/group"
182 egrep '^wheel:' /etc/group >> "$initdir/etc/group"
183 egrep '^adm:' /etc/group >> "$initdir/etc/group"
185 ln_r $systemdutildir/systemd "/init"
186 ln_r $systemdutildir/systemd "/sbin/init"
188 inst_binary true
189 ln_r $(type -P true) "/usr/bin/loginctl"
190 ln_r $(type -P true) "/bin/loginctl"
191 inst_rules \
192 70-uaccess.rules \
193 71-seat.rules \
194 73-seat-late.rules \
195 90-vconsole.rules \
196 99-systemd.rules
198 for i in \
199 emergency.target \
200 rescue.target \
201 systemd-ask-password-console.service \
202 systemd-ask-password-plymouth.service \
203 ; do
204 mkdir -p "${initdir}${systemdsystemunitdir}/${i}.wants"
205 ln_r "${systemdsystemunitdir}/systemd-vconsole-setup.service" \
206 "${systemdsystemunitdir}/${i}.wants/systemd-vconsole-setup.service"
207 done
209 mkdir -p "$initdir/etc/systemd"
210 # turn off RateLimit for journal
212 echo "[Journal]"
213 echo "RateLimitInterval=0"
214 echo "RateLimitBurst=0"
215 } >> "$initdir/etc/systemd/journald.conf"
217 ln_r "${systemdsystemunitdir}/multi-user.target" "${systemdsystemunitdir}/default.target"