Lines of
init.mk
from check-in 35e11e77a2
that are changed by the sequence of edits moving toward
check-in 0be859974c:
1: # Meta targets
2:
3: TARGETS+=adjkerntz bootfs cleanvar cleartmp cloned devfs dmesg dumpon fsck \
35e11e77a2 2019-10-25 4: hostname ifconfig kld ldconfig microcode mixer mount mountlate msgs \
35e11e77a2 2019-10-25 5: newsyslog nextboot nfsclient pwcheck random root rpc_umntall runshm \
6: savecore swap sysctl sysdb wlans
7:
35e11e77a2 2019-10-25 8: DAEMON: pwcheck sysctl sysdb NETWORK SERVERS ldconfig nfsclient cleartmp
9:
35e11e77a2 2019-10-25 10: LOGIN: DAEMON dntpd msgs powerd
11:
35e11e77a2 2019-10-25 12: NETWORK: ifconfig devd hostname
13:
14: SERVERS: swap mountlate syslogd newsyslog
15:
35e11e77a2 2019-10-25 16: SERVICE: ifconfig 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:
35e11e77a2 2019-10-25 112: ifconfig: adjkerntz wlans cloned kld
35e11e77a2 2019-10-25 113: echo "MRC:$@> Starting interfaces: ${IFCONFIG_IFACES}"
35e11e77a2 2019-10-25 114: .for iface in ${IFCONFIG_IFACES}
35e11e77a2 2019-10-25 115: .for item in ${IFCONFIG_${iface}:tW:ts;}
35e11e77a2 2019-10-25 116: ifconfig ${iface} ${item}
35e11e77a2 2019-10-25 117: .endfor
35e11e77a2 2019-10-25 118: .undef _IFCONFIG_ARGS
35e11e77a2 2019-10-25 119: .endfor
35e11e77a2 2019-10-25 120:
121: kld: bootfs
122: .if defined(KLD_LIST)
123: echo "MRC:$@> Loading kernel modules: ${KLD_LIST}"
124: kldload -n ${KLD_LIST}
125: .endif
126:
127: .for path in ${LDCONFIG_PATHS} /etc/ld-elf.so.conf
128: .if exists(${path})
129: ldc+=${path}
130: .endif
131: .endfor
132:
133: .for dir in ${LDCONFIG_LOCAL_DIRS}
134: .if exists(${dir})
135: ldc+=${:!find ${dir} -type f!}
136: .endif
137: .endfor
138:
139: ldconfig: mountlate
140: echo "MRC:$@> Initializing shared libraries: ${ldc}"; \
141: ldconfig -elf ${ldc}
142:
143: microcode: mountlate
144: .if exists(/usr/local/share/cpucontrol)
145: echo "MRC:$@> Updating." ;\
146: kldload -n cpuctl || exit 1 ;\
147: for cpu in $$(jot "$$(sysctl -n hw.ncpu)" 0); do \
148: ( cpucontrol -u -d /usr/local/share/cpucontrol /dev/cpuctl$${cpu} \
149: || exit 1 \
150: ) | grep -v '^TEST' ;\
151: cpucontrol -e /dev/cpuctl$${cpu} || exit 1 ;\
152: done
153: .endif
154:
155: mixers=${:!find /dev -name 'mixer*'!:S/\/dev\///}
156:
157: mixer: mount cleanvar
158: echo "MRC:$@> Restoring levels."
159: .for mixer in ${mixers}
160: test -f /var/db/${mixer}-state || true && mixer -f /dev/${mixer} \
161: `cat /var/db/${mixer}-state`
162: .endfor
163:
164: excludes=${NETFS_TYPES:C/:.*//}
165:
166: mount: root
167: echo "MRC:$@> Mount local FS."
168: mount -a -t no${excludes:ts,}
169:
170: mountlate: NETWORK mount cleanvar runshm devd
171: echo "MRC:$@> Mount late FS."
172: mount -a
173:
174: msgs: mount
175: echo "MRC:$@> Making bounds." ;\
176: test ! -d /var/msgs -o -f /var/msgs/bound -o -L /var/msgs/bounds || \
177: echo 0 > /var/msgs/bounds
178:
179: newsyslog: mountlate sysdb
180: test -z "$${NEWSYSLOG_ENABLE}" || \
181: echo "MRC:$@> Trimming log files." ;\
182: /usr/sbin/newsyslog ${NEWSYSLOG_FLAGS}
183:
184: nextboot: mount
185: .if exists(/boot/nextkernel)
186: echo "MRC:$@> Removing nextboot setting."
187: rm -f /boot/nextkernel
188: .endif
189:
190: .if empty(NFSCLIENT_ENABLE:tl:Mno)
191: DAEMON_rpcbind_ENABLE=yes
192: .endif
193:
194: nfsclient: NETWORK rpcbind rpc_umntall
195: test -z "$${NFSCLIENT_ENABLE}" || kldload -n nfs
196:
197: pwcheck: mountlate syslogd
198: echo "MRC:$@> Checking password lock file."
199: .if exists(/etc/ptmp)
200: logger -s -p auth.err "password file may be incorrect -- /etc/ptmp \
201: exists"
202: .endif
203:
204: random: mount devfs
35e11e77a2 2019-10-25 205: echo "MRC:$@> Seeding."
35e11e77a2 2019-10-25 206: sysctl kern.seedenable=1 > /dev/null
207: ( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; ) 2>&1 | \
35e11e77a2 2019-10-25 208: dd status=none of=/dev/random bs=8k
35e11e77a2 2019-10-25 209: cat /bin/ls | dd status=none of=/dev/random bs=8k
35e11e77a2 2019-10-25 210: .if exists(ENTROPY_DIR) # XXX
35e11e77a2 2019-10-25 211: .for file in ${:!find ${ENTROPY_DIR} -type f!}
35e11e77a2 2019-10-25 212: dd status=none if=${file} of=/dev/random bs=8k
35e11e77a2 2019-10-25 213: .endfor
35e11e77a2 2019-10-25 214: .elif exists(ENTROPY_FILE)
35e11e77a2 2019-10-25 215: dd status=none if=${ENTROPY_FILE} of=/dev/random bs=8k
35e11e77a2 2019-10-25 216: .endif
217: sysctl kern.seedenable=0 > /dev/null
218:
219: root: fsck bootfs
220: echo "MRC:$@> Mount root R/W."
221: mount -uo rw /
222: umount -a
223:
224: rpc_umntall: mountlate NETWORK rpcbind
35e11e77a2 2019-10-25 225: .if empty(RPC_UMNTALL_ENABLE:tl:Mno) # XXX
226: echo "MRC:$@> Sending RPC unmount notifications."; \
227: test -f /var/db/mounttab || true && \
228: rpc.umntall -k &
229: .endif
230:
231: runshm: cleanvar
232: echo "MRC:$@> Mount and populate /var/run/shm."; \
233: mkdir -p /var/run/shm; \
234: mount_tmpfs -m 01777 dummy /var/run/shm; \
235: mkdir -p -m 01777 /var/run/shm/tmp; \
236:
237: savecore: dumpon
238: .if empty(DUMPDEV:tl:Mno) && exists(${DUMPDEV}) && exists(${DUMPDIR})
239: echo "MRC:$@> Saving coredump."; \
240: savecore ${DUMPDIR} ${DUMPDEV}
241: .if empty(CRASHINFO_ENABLE:tl:Mno)
242: crashinfo -d ${DUMPDIR}
243: .endif
244: .endif
245:
246: swap: savecore
247: .if ${:!sysctl -n vm.swap_enabled!}} != 0
248: echo "MRC:$@> Enabling swap."; \
249: swapon -a
250: .endif
251:
252: sysctl: kld root
253: .if exists(/etc/sysctl.conf)
254: echo "MRC:$@> Setting sysctl defaults."; \
255: awk '$$0~/^[ ]*(#.*)?$$/{next}{print}' < /etc/sysctl.conf | \
256: xargs -n1 sysctl
257: .endif
258:
259: sysdb: mountlate
260: echo "MRC:$@> Building databases."; \
261: dev_mkdb; \
262: install -c -m 644 -g wheel /dev/null /var/run/utmpx
263:
264: wlans: kld
265: echo "MRC:$@> Configuring wlans."; \
266: for dev in $$(sysctl -n net.wlan.devices); do \
267: eval all_wlans=\$${WLANS_$${dev}}; \
268: for wlan in $${all_wlans}; do \
269: eval wlan_args=\$${WLANS_$${wlan}_ARGS}; \
270: ifconfig $${wlan} create wlandev $${dev} $${wlan_args}; \
271: ifconfig $${wlan} up; \
272: done; \
273: done