]> Raphaƫl G. Git Repositories - ihttpd/blob - SOURCES/ihttpd.module-setup
Upgrade to 2.4.38
[ihttpd] / SOURCES / ihttpd.module-setup
1 #!/bin/bash
2
3 # called by dracut
4 check() {
5 local fs
6
7 # Fix tmpfiledir
8 #XXX: fix installation of /usr/lib/tmpfileS.d/{dracut-tmpfiles,systemd}.conf
9 #XXX: should be removed when bug 18642 (mageia) or 1343230 (fedora) will be fixed in /usr/bin/dracut +1262-1282
10 [ -z "$tmpfilesdir" -o ! -d "$tmpfilesdir" -a -d /usr/lib/tmpfiles.d ] && tmpfilesdir=/usr/lib/tmpfiles.d
11 [ -z "$tmpfilesdir" -o ! -d "$tmpfilesdir" -a -d /etc/tmpfiles.d ] && tmpfilesdir=/etc/tmpfiles.d
12 [ -z "$tmpfilesdir" -o ! -d "$tmpfilesdir" -a -d /lib/tmpfiles.d ] && tmpfilesdir=/lib/tmpfiles.d
13
14 # if cryptsetup is not installed, then we cannot support encrypted devices.
15 require_binaries cryptsetup || return 1
16
17 # if hostonly or mount_needs include if required by other module
18 # if one of fs types is crypto_LUKS include it
19 [[ $hostonly ]] || [[ $mount_needs ]] && {
20 for fs in "${host_fs_types[@]}"; do
21 [[ $fs = "crypto_LUKS" ]] && return 0
22 done
23 return 255
24 }
25
26 return 0
27 }
28
29 # called by dracut
30 depends() {
31 # depend on crypt for /etc/crypttab
32 # depend on systemd-networkd for rd.neednet=1
33 # depend on dracut-systemd for appending to $tmpfilesdir/dracut-tmpfiles.conf
34 echo crypt systemd-networkd dracut-systemd
35 return 0
36 }
37
38 # called by dracut
39 cmdline() {
40 local fs
41 for fs in "${host_fs_types[@]}"; do
42 if [[ "$fs" == "crypto_LUKS" ]]; then
43 #XXX we used to include ip=dhcp as well (replaced by systemd-networkd configuration)
44 printf "%s" " rd.neednet=1"
45 break
46 fi
47 done
48 }
49
50 # called by dracut
51 install() {
52 local _ihttpdconf=$(cmdline)
53 local fs
54 #XXX: rd.neednet=1 is mandatory to have active network in initrd
55 [[ $_ihttpdconf ]] && printf "%s\n" "$_ihttpdconf" >> "${initdir}/etc/cmdline.d/99ihttpd.conf"
56
57 # Install cert dirs
58 inst_dir \
59 /etc/pki/tls/certs \
60 /etc/pki/tls/private \
61 /etc/systemd/network \
62 $systemdsystemunitdir/ihttpd.service.wants \
63 /var/www/html
64
65 # Install all files
66 #XXX: force cryptsetup install until systemd-cryptsetup implement a method that don't rely on password ending with \0
67 inst_multiple \
68 /etc/hosts \
69 /etc/localtime \
70 /etc/mime.types \
71 /etc/nsswitch.conf \
72 /etc/pki/tls/certs/ihttpd.pem \
73 /etc/pki/tls/private/ihttpd.pem \
74 /etc/systemd/resolved.conf \
75 $systemdsystemunitdir/systemd-networkd.service \
76 $systemdsystemunitdir/systemd-resolved.service \
77 $systemdsystemunitdir/systemd-tmpfiles-setup.service \
78 $systemdutildir/systemd-resolved \
79 $tmpfilesdir/ihttpd.conf \
80 '/sbin/cryptsetup' \
81 '/usr/bin/false' \
82 '/usr/bin/reboot' \
83 '/usr/sbin/ihttpd'
84
85 # Install favicon
86 inst_simple -o /var/www/html/favicon.ico
87
88 # Include all ihttpd deps
89 inst_libdir_file \
90 "ld-linux-*.so.*" \
91 "libapr-1.so.*" \
92 "libaprutil-1.so.*" \
93 "libcrypto.so.*" \
94 "libcrypt.so.*" \
95 "libc.so.*" \
96 "libdb-*.so" \
97 "libdl.so.*" \
98 "libexpat.so.*" \
99 "libnsl.so.*" \
100 "libpcre.so.*" \
101 "libpthread.so.*" \
102 "libresolv.so.*" \
103 "librt.so.*" \
104 "libuuid.so.*" \
105 "libz.so.*" \
106 "libnss_files.so.*" \
107 "libnss_dns.so.*" \
108 "libnss_myhostname.so.*" \
109 {"tls/$_arch/",tls/,"$_arch/",}"libssl.so.*"
110
111 # Install ihttpd.conf index.bin reboot.bin ihttpd.service
112 for nc in /etc/ihttpd.conf /var/www/html/index.bin /var/www/html/reboot.bin $systemdsystemunitdir/ihttpd.service; do
113 inst_simple /usr/lib/ihttpd/${nc##*/} $nc
114 done
115
116 # Force load of ihttpd.service
117 ln -fs ../ihttpd.service $initdir$systemdsystemunitdir/sysinit.target.wants/
118
119 # Copy systemd-networkd config
120 for nc in `ls /etc/systemd/network/`; do
121 inst_simple /etc/systemd/network/$nc
122 done
123
124 # Install resolv.conf as symlink
125 ln -fs '/run/systemd/resolve/resolv.conf' $initdir/etc/resolv.conf
126
127 # Install in ihttpd.service.wants
128 ln -fs \
129 ../systemd-resolved.service \
130 ../systemd-networkd.service \
131 ../systemd-tmpfiles-setup.service \
132 $initdir$systemdsystemunitdir/ihttpd.service.wants/
133
134 # Cleanup resolved.conf
135 perl -pne 'undef $_ if /^(?:#.*|Domains=|FallbackDNS=|DNS=(?:127.0.0.1|::1)$|$)/;/^DNS=/ && $_ =~ s/(?:127.0.0.1|::1)[ \t]*//g' \
136 -i "$initdir/etc/systemd/resolved.conf"
137
138 # Cleanup nsswitch.conf
139 perl -pne 'undef $_ if /^(?:#|$)/;s/compat/files/;s/ ?(?:nis|wins|mdns4_minimal |mdns4)( )?/\1/g' \
140 -i "$initdir/etc/nsswitch.conf"
141
142 # Require systemd-resolve user and group for our ihttpd process
143 `egrep -q '^systemd-resolve:' $initdir/etc/group` || egrep '^systemd-resolve:' /etc/group >> "$initdir/etc/group"
144 `egrep -q '^systemd-resolve:' $initdir/etc/passwd` || egrep '^systemd-resolve:' /etc/passwd >> "$initdir/etc/passwd"
145 #XXX: bug: fix /usr/lib/tmpfiles.d/{systemd,dracut-tmpfiles}.conf missing user and group
146 `egrep -q '^utmp:' $initdir/etc/group` || egrep '^utmp:' /etc/group >> "$initdir/etc/group"
147 # Require root user and group for our ihttpd process
148 `egrep -q '^root:' $initdir/etc/group` || egrep '^root:' /etc/group >> "$initdir/etc/group"
149 `egrep -q '^root:' $initdir/etc/passwd` || egrep '^root:' /etc/passwd >> "$initdir/etc/passwd"
150
151 # For debug only
152 if false; then
153 # Install ihttpd log
154 ln -fs ../../../run/ihttpd/log/{http,https,child.{askpassword,ihttpd},error}.log $initdir/var/www/html/
155
156 # Install sshd dirs
157 inst_dir \
158 /etc/pam.d \
159 /etc/profile.d \
160 /etc/security \
161 /etc/ssh \
162 /etc/sysconfig \
163 $systemdsystemunitdir/basic.target.wants \
164 $systemdsystemunitdir/emergency.target.wants \
165 $systemdsystemunitdir/rescue.target.wants \
166 $systemdsystemunitdir/sysinit.target.wants \
167 /usr/lib64/security \
168 /usr/share/terminfo/x \
169 /var/empty
170
171 # Install sshd files
172 inst_multiple \
173 /etc/bashrc \
174 /etc/environment \
175 /etc/gshadow \
176 /etc/pam.d/sshd \
177 /etc/pam.d/system-auth \
178 /etc/profile.d/*.sh \
179 /etc/security/limits.conf \
180 /etc/security/pam_env.conf \
181 /etc/shadow \
182 /etc/ssh/denyusers \
183 /etc/ssh/moduli \
184 /etc/ssh/ssh_config \
185 /etc/ssh/sshd_config \
186 /etc/ssh/ssh_host_* \
187 /root/.bash_profile \
188 /root/.bashrc \
189 /usr/bin/cat \
190 /usr/bin/id \
191 '/usr/bin/kill' \
192 /usr/bin/ps \
193 /usr/lib64/security/pam_cracklib.so \
194 /usr/lib64/security/pam_deny.so \
195 /usr/lib64/security/pam_env.so \
196 /usr/lib64/security/pam_keyinit.so \
197 /usr/lib64/security/pam_limits.so \
198 /usr/lib64/security/pam_listfile.so \
199 /usr/lib64/security/pam_nologin.so \
200 /usr/lib64/security/pam_succeed_if.so \
201 /usr/lib64/security/pam_systemd.so \
202 /usr/lib64/security/pam_tcb.so \
203 /usr/sbin/sshd \
204 /usr/share/terminfo/x/*
205
206 # Disable pam
207 #perl -pne 's%^UsePAM yes$%UsePAM no%;s%^PermitRootLogin .*$%PermitRootLogin yes%' -i "$initdir/etc/ssh/sshd_config"
208 perl -pne 's%^PermitRootLogin .*$%PermitRootLogin yes%' -i "$initdir/etc/ssh/sshd_config"
209
210 # Install debug sshd service
211 inst_simple /usr/lib/ihttpd/debug-sshd.service $initdir$systemdsystemunitdir/debug-sshd.service
212
213 # Install in sysinit.target.wants
214 ln -fs ../debug-sshd.service $initdir$systemdsystemunitdir/sysinit.target.wants/
215
216 # Install sshd user and group
217 `grep -Eq '^sshd:' $initdir/etc/passwd` || grep -E '^sshd:' /etc/passwd >> "$initdir/etc/passwd"
218 `grep -Eq '^sshd:' $initdir/etc/group` || grep -E '^sshd:' /etc/group >> "$initdir/etc/group"
219 fi
220 }