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