Lines of
init.mk
from check-in 5f60bcc749
that are changed by the sequence of edits moving toward
check-in 88e0b45310:
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:
5f60bcc749 2019-10-23 25: CLEANVAR_DIRS?=/var/run /var/spool/lock /var/spool/uucp/.Temp
5f60bcc749 2019-10-23 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
5f60bcc749 2019-10-23 49:
5f60bcc749 2019-10-23 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:
5f60bcc749 2019-10-23 60: DMESG_FILE?=/var/run/dmesg.boot
5f60bcc749 2019-10-23 61:
62: dmesg: mountlate
63: echo "MRC:$@> Writing dmesg."
64: umask 022 ; dmesg -a >> ${DMESG_FILE}
5f60bcc749 2019-10-23 65:
5f60bcc749 2019-10-23 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:
5f60bcc749 2019-10-23 107: HOSTNAME?=Amnesiac
5f60bcc749 2019-10-23 108:
109: hostname:
110: echo "MRC:$@> Setting to ${HOSTNAME}."
111: hostname ${HOSTNAME}
5f60bcc749 2019-10-23 112:
5f60bcc749 2019-10-23 113: IFCONFIG_IFACES?=lo0
5f60bcc749 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}
119: .for item in ${IFCONFIG_${iface}:tW:ts;}
120: ifconfig ${iface} ${item}
121: .endfor
122: .undef _IFCONFIG_ARGS
123: .endfor
124:
125: kld: bootfs
126: .if defined(KLD_LIST)
127: echo "MRC:$@> Loading kernel modules: ${KLD_LIST}"
128: kldload -n ${KLD_LIST}
129: .endif
5f60bcc749 2019-10-23 130:
5f60bcc749 2019-10-23 131: LDCONFIG_PATHS?=/lib /usr/lib /usr/local/lib /usr/pkg/lib
5f60bcc749 2019-10-23 132: LDCONFIG_LOCAL_DIRS?=/usr/local/libdata/ldconfig
133:
134: .for path in ${LDCONFIG_PATHS} /etc/ld-elf.so.conf
135: .if exists(${path})
136: ldc+=${path}
137: .endif
138: .endfor
139:
140: .for dir in ${LDCONFIG_LOCAL_DIRS}
141: .if exists(${dir})
142: ldc+=${:!find ${dir} -type f!}
143: .endif
144: .endfor
145:
146: ldconfig: mountlate
147: echo "MRC:$@> Initializing shared libraries: ${ldc}"; \
148: ldconfig -elf ${ldc}
149:
150: mixers=${:!find /dev -name 'mixer*'!:S/\/dev\///}
151:
152: mixer: mount cleanvar
153: echo "MRC:$@> Restoring levels."
154: .for mixer in ${mixers}
155: -test -f /var/db/${mixer}-state && mixer -f /dev/${mixer} `cat /var/db/${mixer}-state`
156: .endfor
157:
5f60bcc749 2019-10-23 158: NETFS_TYPES?=nfs:NFS smbfs:SMB
5f60bcc749 2019-10-23 159:
160: excludes=${NETFS_TYPES:C/:.*//}
161:
162: mount: root
163: echo "MRC:$@> Mount local FS."
164: mount -a -t no${excludes:ts,}
165:
166: mountlate: NETWORK mount cleanvar runshm devd
167: echo "MRC:$@> Mount late FS."
168: mount -a
169:
170: msgs: mount
171: echo "MRC:$@> Making bounds." ;\
172: test ! -d /var/msgs -o -f /var/msgs/bound -o -L /var/msgs/bounds || \
173: echo 0 > /var/msgs/bounds
174:
5f60bcc749 2019-10-23 175: NEWSYSLOG_ENABLE?=no
5f60bcc749 2019-10-23 176:
177: newsyslog: mountlate sysdb
178: test -z "$${NEWSYSLOG_ENABLE}" || \
179: echo "MRC:$@> Trimming log files." ;\
180: /usr/sbin/newsyslog ${NEWSYSLOG_FLAGS}
181:
182: nextboot: mount
183: .if exists(/boot/nextkernel)
184: echo "MRC:$@> Removing nextboot setting."
185: rm -f /boot/nextkernel
186: .endif
5f60bcc749 2019-10-23 187:
5f60bcc749 2019-10-23 188: NFSCLIENT_ENABLE?=no
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 exists"
201: .endif
202:
5f60bcc749 2019-10-23 203: ENTROPY_FILE?=/var/db/entropy/random
5f60bcc749 2019-10-23 204: ENTROPY_DIR?=/var/db/entropy
5f60bcc749 2019-10-23 205:
206: random: mount devfs
207: echo "MRC:$@> Seeding."
208: sysctl kern.seedenable=1 > /dev/null
5f60bcc749 2019-10-23 209: ( ps -fauxww; ${SYSCTL} -a; date; df -ib; dmesg; ps -fauxww; ) 2>&1 | dd status=none of=/dev/random bs=8k
210: cat /bin/ls | dd status=none of=/dev/random bs=8k
5f60bcc749 2019-10-23 211: .if exists(ENTROPY_DIR)
212: .for file in ${:!find ${ENTROPY_DIR} -type f!}
213: dd status=none if=${file} of=/dev/random bs=8k
214: .endfor
215: .elif exists(ENTROPY_FILE)
216: dd status=none if=${ENTROPY_FILE} of=/dev/random bs=8k
217: .endif
218: sysctl kern.seedenable=0 > /dev/null
219:
220: root: fsck bootfs
221: echo "MRC:$@> Mount root R/W."
222: mount -uo rw /
223: umount -a
224:
225: rpc_umntall: mountlate NETWORK rpcbind
5f60bcc749 2019-10-23 226: .if empty(RPC_UMNTALL_ENABLE:tl:Mno)
227: echo "MRC:$@> Sending RPC unmount notifications."; \
228: test -f /var/db/mounttab || true && \
229: rpc.umntall -k &
230: .endif
231:
232: runshm: cleanvar
233: echo "MRC:$@> Mount and populate /var/run/shm."; \
234: mkdir -p /var/run/shm; \
235: mount_tmpfs -m 01777 dummy /var/run/shm; \
236: mkdir -p -m 01777 /var/run/shm/tmp; \
5f60bcc749 2019-10-23 237:
5f60bcc749 2019-10-23 238: DUMPDIR?=/var/crash
5f60bcc749 2019-10-23 239: CRASHINFO_ENABLE?=no
240:
241: savecore: dumpon
242: .if empty(DUMPDEV:tl:Mno) && exists(${DUMPDEV}) && exists(${DUMPDIR})
243: echo "MRC:$@> Saving coredump."; \
244: savecore ${DUMPDIR} ${DUMPDEV}
245: .if empty(CRASHINFO_ENABLE:tl:Mno)
246: crashinfo -d ${DUMPDIR}
247: .endif
248: .endif
249:
250: swap: savecore
251: .if ${:!sysctl -n vm.swap_enabled!}} != 0
252: echo "MRC:$@> Enabling swap."; \
253: swapon -a
254: .endif
255:
256: sysctl: kld root
257: .if exists(/etc/sysctl.conf)
258: echo "MRC:$@> Setting sysctl defaults."; \
259: awk '$$0~/^[ ]*(#.*)?$$/{next}{print}' < /etc/sysctl.conf | xargs -n1 sysctl
260: .endif
261:
262: sysdb: mountlate
263: echo "MRC:$@> Building databases."; \
264: dev_mkdb; \
265: install -c -m 644 -g wheel /dev/null /var/run/utmpx
266:
267: wlans: kld
268: echo "MRC:$@> Configuring wlans."; \
269: for dev in `sysctl -n net.wlan.devices`; do \
270: eval all_wlans=\$${WLANS_$${dev}}; \
271: for wlan in $${all_wlans}; do \
272: eval wlan_args=\$${WLANS_$${wlan}_ARGS}; \
273: ifconfig $${wlan} create wlandev $${dev} $${wlan_args}; \
274: ifconfig $${wlan} up; \
275: done; \
276: done