Lines of
init.mk
from check-in 8bc8c738d5
that are changed by the sequence of edits moving toward
check-in 625f7382df:
1: # Meta targets
2:
3: TARGETS:=adjkerntz bootfs cleanvar cleartmp cloned devfs dmesg dumpon fsck \
4: hostname kld ldconfig microcode mixer mount mountlate msgs netif \
5: newsyslog nextboot nfsclient pf pwcheck random root runshm savecore swap \
6: sysctl sysdb wlans zfs mounttmpfs utmpx
7:
8: OTHER_TARGETS+=mixer_exit nfsclient_exit random_exit
9:
10: DAEMON: pwcheck sysctl sysdb NETWORK SERVERS ldconfig nfsclient cleartmp pflogd
11:
12: LOGIN: DAEMON dntpd msgs powerd pflogd
13:
14: NETWORK: netif devd hostname
15:
16: SERVERS: swap mountlate syslogd newsyslog
17:
18: SERVICE: netif mount random hostname cleanvar
19:
20: # regular targets
21:
22: adjkerntz: random mount
23: echo "MRC:$@> Adjust kernel timezone."
24: adjkerntz -i
25:
26: bootfs: fsck
27: echo "MRC:$@> Checking whether we need /boot mounted."
28: mount -vadr | grep -q ' /boot$$' && mount -r /boot || true
29:
30: cleanvar: mount
31: echo "MRC:$@> Cleaning '/var's."
32: .for dir in ${CLEANVAR_DIRS}
33: if [ -d ${dir} ]; then \
34: /rescue/find ${dir} -mindepth 1 -delete ;\
35: fi
36: .endfor
37:
38: cleartmp: mountlate
39: echo "MRC:$@> Clearing tmp."
40: find -x /tmp -mindepth 1 ! -name lost+found ! -name snapshots \
41: ! -path "./snapshots/*" ! -name quota.user ! -name quota.group \
42: -delete -type d -prune
43: rm -fr /tmp/.X11-unix /tmp/.X*-lock
44: mkdir -m 1777 /tmp/.X11-unix
45:
46: cloned: kld
47: .if !empty(CLONED_INTERFACES)
48: echo "MRC:$@> Cloning interfaces: ${CLONED_INTERFACES}"
49: . for iface in ${CLONED_INTERFACES}
50: ifconfig ${iface} create
51: . endfor
52: .endif
53:
54: devfs:
55: echo "MRC:$@> Applying rules: ${DEVFS_CONFIG_FILES}"
56: .for file in ${DEVFS_CONFIG_FILES}
57: . if exists(${file})
58: devfsctl -a -f ${file}
59: . endif
60: .endfor
61:
62: dmesg: mountlate
63: .if !empty(DMESG_FILE)
64: echo "MRC:$@> Writing dmesg."
65: ( umask 022 ; dmesg -a > ${DMESG_FILE} ;)
66: .endif
67:
68: dumpon: random
69: .if !empty(DUMPDEV)
70: if [ -e ${DUMPDEV} ]; then \
71: echo "MRC:$@> Setting dumpon device to ${DUMPDEV}" ;\
72: dumpon -v ${DUMPDEV} ;\
73: fi
74: .endif
75:
76: fsck:
77: echo "MRC:$@> Checking disks." ;\
78: fsck -p ;\
79: case $$? in \
80: 0) ;; \
81: 2) exit 1 \
82: ;; \
83: 4) echo "Rebooting..." ;\
84: reboot ;\
85: echo "Reboot failed; help!" ;\
86: exit 1 \
87: ;; \
88: 8) if [ -n "$${FSCK_Y_ENABLE}" ]; then \
89: echo "File system preen failed, trying fsck -y." ;\
90: fsck -y || { \
91: echo "Automatic file system check failed; help!" ;\
92: exit 1 ;\
93: } ;\
94: else \
95: echo "Automatic file system check failed; help!" ;\
96: exit 1 ;\
97: fi \
98: ;; \
99: 12) echo "Boot interrupted." ;\
100: exit 1 \
101: ;; \
102: 130) exit 1 \
103: ;; \
104: *) echo "Unknown error, help!" ;\
105: exit 1 \
106: ;; \
107: esac
108:
109: hostname:
110: echo "MRC:$@> Setting to ${HOSTNAME}."
111: hostname ${HOSTNAME}
112:
113: kld: bootfs
114: .if defined(KLD_LIST)
8bc8c738d5 2022-05-31 115: echo "MRC:$@> Loading kernel modules: ${KLD_LIST}" ;\
8bc8c738d5 2022-05-31 116: kldload -n ${KLD_LIST}
117: .endif
118:
119: # ldconfig
120: .for path in ${LDCONFIG_PATHS} /etc/ld-elf.so.conf
121: .if exists(${path})
122: ldc+=${path}
123: .endif
124: .endfor
125:
126: .for dir in ${LDCONFIG_LOCAL_DIRS}
127: .if exists(${dir})
128: ldc+=${:!find ${dir} -type f!}
129: .endif
130: .endfor
131:
132: ldconfig: mountlate
133: echo "MRC:$@> Initializing shared libraries: ${ldc}"; \
134: ldconfig -elf ${ldc}
135:
136: microcode: mountlate
137: test -d /usr/local/share/cpucontrol || exit 0 ;\
138: echo "MRC:$@> Updating microcode." ;\
139: kldload -n cpuctl || exit 1 ;\
140: for cpu in $$(jot ${NCPU} 0); do \
141: { cpucontrol -u -d /usr/local/share/cpucontrol /dev/cpuctl$${cpu} \
142: || exit 1 ;\
143: } | grep -v '^TEST' ;\
144: cpucontrol -e /dev/cpuctl$${cpu} || exit 1 ;\
145: done
146:
147: mixers=${:!find /dev -name 'mixer*'!:S/\/dev\///}
148:
149: mixer: mount cleanvar
150: echo "MRC:$@> Restoring levels."
151: .for mixer in ${mixers}
152: if [ -r /var/db/${mixer}-state ]; then \
153: mixer -f /dev/${mixer} `cat /var/db/${mixer}-state` ;\
154: fi
155: .endfor
156:
157: mixer_exit:
158: echo "MRC:$@> Saving mixer levels."
159: .for mixer in ${mixers}
160: if [ -r /dev/${mixer} ]; then \
161: mixer -f /dev/${mixer} -s > /var/db/${mixer}-state ;\
162: fi
163: .endfor
164:
165: DAEMON_EXIT: mixer_exit
166:
167: excludes=${NETFS_TYPES:C/:.*//}
168:
169: mount: root zfs
170: echo "MRC:$@> Mount local FS." ;\
171: mount -uo rw -a ;\
172: mount ;\
173: mount -a -t no${excludes:ts,}
174:
175: mountlate: NETWORK mount cleanvar runshm devd mounttmpfs
176: echo "MRC:$@> Mount late FS." ;\
177: mount -a
178:
179: msgs: mount
180: echo "MRC:$@> Making bounds." ;\
181: test ! -d /var/msgs -o -f /var/msgs/bound -o -L /var/msgs/bounds || \
182: echo 0 > /var/msgs/bounds
183:
184: newsyslog: mountlate sysdb
185: if [ -n "$${NEWSYSLOG_ENABLE}" ]; then \
186: echo "MRC:$@> Trimming log files." ;\
187: /usr/sbin/newsyslog ${NEWSYSLOG_FLAGS} ;\
188: fi
189:
190: nextboot: mount
191: .if exists(/boot/nextkernel)
192: echo "MRC:$@> Removing nextboot setting."
193: rm -f /boot/nextkernel
194: .endif
195:
196: .if empty(NFSCLIENT_ENABLE:tl:Mno)
197: DAEMON_rpcbind_ENABLE=yes
198: .endif
199:
200: nfsclient: NETWORK rpcbind
201: if [ -n "$${NFSCLIENT_ENABLE}" ]; then \
202: kldload -n nfs ;\
203: fi
204:
205: nfsclient_exit: DAEMON_EXIT
206: .if empty(RPC_UMNTALL_ENABLE:tl:Mno)
207: echo "MRC:$@> Sending RPC unmount notifications."; \
208: test -f /var/db/mounttab || true && \
209: rpc.umntall -k
210: .endif
211:
212: NETWORK_EXIT: nfsclient_exit
213:
214: netif: adjkerntz wlans cloned kld mounttmpfs utmpx
215: echo "MRC:$@> Starting interfaces: ${IFCONFIG_IFACES}"
216: .for iface in ${IFCONFIG_IFACES}
217: .for item in ${IFCONFIG_${iface}:tW:ts;}
218: ifconfig ${iface} ${item}
219: .endfor
220: .undef _IFCONFIG_ARGS
221: .endfor
222:
223: pf: pflogd
224: .if empty(PF_ENABLE:tl:Mno)
225: echo "MRC:$@> Enabling and loading rules."
226: kldload -n pf || exit 1
227: if [ -r ${PF_RULES} ]; then \
228: pfctl -Fa || exit 1 ;\
229: pfctl -f ${PF_RULES} ${PF_FLAGS} || exit 1 ;\
230: pfctl -Si | grep -q Enabled && pfctl -e ;\
231: else \
232: echo "MRC:$@> Can't find file with rules at ${PF_RULES}." ;\
233: exit 1 ;\
234: fi
235: .endif
236:
237: pwcheck: mountlate syslogd
238: echo "MRC:$@> Checking password lock file."
239: .if exists(/etc/ptmp)
240: logger -s -p auth.err \
241: "password file may be incorrect -- /etc/ptmp exists"
242: .endif
243:
244: random: mount devfs
245: echo "MRC:$@> Seeding."
246: sysctl kern.seedenable=1 > /dev/null
247: ( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww ;) 2>&1 |\
248: dd status=none of=/dev/random bs=8k 2>/dev/null
249: dd if=/bin/ps status=none of=/dev/random bs=8k 2>/dev/null
250: if [ -d $${ENTROPY_DIR} ]; then \
251: find $${ENTROPY_DIR} -type f |\
252: xargs -n1 -Ifoo dd status=none if=foo of=/dev/random bs=8k 2>/dev/null ;\
253: else \
254: if [ -r ${ENTROPY_FILE} ]; then \
255: dd status=none if=${ENTROPY_FILE} of=/dev/random bs=8k 2>/dev/null ;\
256: fi \
257: fi
258: sysctl kern.seedenable=0 > /dev/null
259:
260: random_exit:
261: rm -f ${ENTROPY_FILE}
262: ( \
263: umask 077 ;\
264: dd if=/dev/random of=${ENTROPY_FILE} bs=8k count=1 2>/dev/null || \
265: echo "MRC:$@> entropy file write failed." ;\
266: )
267:
268: DAEMON_EXIT: random_exit
269:
270: root: fsck bootfs
271: echo "MRC:$@> Mount root R/W."
272: mount -uo rw
273:
274: savecore: dumpon
275: .if empty(DUMPDEV:tl:Mno) && exists(${DUMPDEV}) && exists(${DUMPDIR})
276: echo "MRC:$@> Saving coredump."
277: savecore ${DUMPDIR} ${DUMPDEV}
278: .if empty(CRASHINFO_ENABLE:tl:Mno)
279: crashinfo -d ${DUMPDIR}
280: .endif
281: .endif
282:
283: swap: savecore
284: .if ${:!sysctl -n vm.swap_enabled!}} != 0
285: echo "MRC:$@> Enabling swap."
286: swapon -a
287: .endif
288:
289: sysctl: kld root
290: .if exists(/etc/sysctl.conf)
291: echo "MRC:$@> Setting sysctl defaults."
292: awk '$$0~/^[ ]*(#.*)?$$/{next}{print}' < /etc/sysctl.conf | \
293: xargs -n1 sysctl
294: .endif
295:
296: sysdb: mountlate
297: echo "MRC:$@> Building databases."
298: install -c -m 644 -g wheel /dev/null /var/run/utmpx
299:
300: wlans: kld
301: echo "MRC:$@> Configuring wlans."
302: for dev in $$(sysctl -n net.wlan.devices); do \
303: eval all_wlans=\$${WLANS_$${dev}} ;\
304: for wlan in $${all_wlans}; do \
305: eval wlan_args=\$${WLANS_$${wlan}_ARGS} ;\
306: ifconfig $${wlan} create wlandev $${dev} $${wlan_args} ;\
307: ifconfig $${wlan} up ;\
308: done \
309: done
310:
311: zfs:
312: .if empty(ZFS_ENABLE:tl:Mno)
313: zfs mount -va || exit $$?
314: zfs share -a || exit $$?
315: touch /etc/zfs/exports
316: .endif
317:
318: runshm: cleanvar
319: echo "MRC:$@> Preparing /var/run."
320: . if exists(TMPFS_VAR_RUN_ENABLE)
321: /rescue/find /var/run -mindepth 1 -delete
322: mount_tmpfs dummy /var/run
323: . else
324: mkdir -p /var/run/shm
325: mount_tmpfs -m 01777 dummy /var/run/shm
326: . endif
327: mtree -deiqU -f /etc/mtree/BSD.var.dist -p /var
328:
329: mounttmpfs: cleanvar
330: echo "MRC:$@> Mount tmpfs and populating /var/run."
331: .if exists(TMPFS_TMP_ENABLE)
332: mount | awk 'BEGIN{x=1}$$3~/\/tmp/{x=0}END{exit(x)}' || {
333: /rescue/find /tmp -mindepth 1 -delete
334: mount_tmpfs -m 01777 dummy /tmp
335: }
336: .endif
337:
338: utmpx: runshm
339: echo "MRC:$@> Install utmpx."
340: install -m 644 -g wheel /dev/null /var/run/utmpx