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