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