Diff
Logged in as anonymous

Differences From Artifact [86dd3c18d7]:

To Artifact [850c3a593a]:


1
2
3
4
5
6
7
8
9
10
11
12
13
# Meta targets

TARGETS:=adjkerntz bootfs cleanvar cleartmp cloned devfs dmesg dumpon fsck \
	hostname kld ldconfig microcode mixer mount mountlate msgs netif \
	newsyslog nextboot nfsclient pf pwcheck random root runshm savecore swap \
	sysctl sysdb wlans zfs

OTHER_TARGETS+=mixer_exit nfsclient_exit random_exit

DAEMON: pwcheck sysctl sysdb NETWORK SERVERS ldconfig nfsclient cleartmp pflogd

LOGIN: DAEMON dntpd msgs powerd pflogd






|







1
2
3
4
5
6
7
8
9
10
11
12
13
# Meta targets

TARGETS:=adjkerntz bootfs cleanvar cleartmp cloned devfs dmesg dumpon fsck \
	hostname kld ldconfig microcode mixer mount mountlate msgs netif \
	newsyslog nextboot nfsclient pf pwcheck random root runshm savecore swap \
	sysctl sysdb wlans zfs mounttmpfs utmpx

OTHER_TARGETS+=mixer_exit nfsclient_exit random_exit

DAEMON: pwcheck sysctl sysdb NETWORK SERVERS ldconfig nfsclient cleartmp pflogd

LOGIN: DAEMON dntpd msgs powerd pflogd

24
25
26
27
28
29
30
31
32

33

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
	adjkerntz -i

bootfs: fsck
	echo "MRC:$@> Checking whether we need /boot mounted."
	mount -vadr | grep -q ' /boot$$' && mount -r /boot || true

cleanvar: mount
	echo "MRC:$@> Cleaning 'var's."
.for dir in ${CLEANVAR_DIRS}

	test -d ${dir} && find ${dir} -mindepth 1 -delete || true

.endfor
	install -m644 /dev/null /var/run/utmpx

cleartmp: mountlate
	echo "MRC:$@> Clearing tmp."; \
	find -x /tmp -mindepth 1 ! -name lost+found \
			! -name snapshots ! -path "./snapshots/*" \
			! -name quota.user ! -name quota.group \
			-delete -type d -prune ;\
		rm -f /tmp/.X*-lock ;\
		rm -fr /tmp/.X11-unix ;\
		mkdir -m 1777 /tmp/.X11-unix

cloned: kld
.if !empty(CLONED_INTERFACES)
	echo "MRC:$@> Cloning interfaces: ${CLONED_INTERFACES}"
.	for iface in ${CLONED_INTERFACES}
	ifconfig ${iface} create
.	endfor
.endif

devfs:
	echo "MRC:$@> Applying rules: ${DEVFS_CONFIG_FILES}"
.for file in ${DEVFS_CONFIG_FILES}
.	if exists(${file})
	devfsctl -a -f ${file}
.	endif
.endfor

dmesg: mountlate
.if !empty(DMESG_FILE)
	echo "MRC:$@> Writing dmesg."
	umask 022 ; dmesg -a >> ${DMESG_FILE}
.endif

dumpon: random
.if !empty(DUMPDEV)
	if [ -e ${DUMPDEV} ]; then \
		echo "MRC:$@> Setting dumpon device to ${DUMPDEV}"; \
		dumpon -v ${DUMPDEV}; \
	fi
.endif

fsck:
	echo "MRC:$@> Checking disks." ;\
	fsck -p ;\
	case $$? in \
	0) ;; \
	2) exit 1 \
		;; \
	4) echo "Rebooting..." ;\
		reboot ;\
		echo "Reboot failed; help!" ;\
		exit 1 \
		;; \
	8) if [ -n "$${FSCK_Y_ENABLE}" ]; then \
			echo "File system preen failed, trying fsck -y." ;\
			fsck -y || {\
				echo "Automatic file system check failed; help!" ;\
				exit 1 ;\
			} ;\
		else \
			echo "Automatic file system check failed; help!" ;\
			exit 1 ;\
		fi \







|

>
|
>

<


|
|
<
|
|
<
|
|




















|





|
|

















|







24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40

41
42

43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
	adjkerntz -i

bootfs: fsck
	echo "MRC:$@> Checking whether we need /boot mounted."
	mount -vadr | grep -q ' /boot$$' && mount -r /boot || true

cleanvar: mount
	echo "MRC:$@> Cleaning '/var's."
.for dir in ${CLEANVAR_DIRS}
	if [ -d ${dir} ]; then \
		/rescue/find ${dir} -mindepth 1 -delete ;\
	fi
.endfor


cleartmp: mountlate
	echo "MRC:$@> Clearing tmp."
	find -x /tmp -mindepth 1 ! -name lost+found ! -name snapshots \

		! -path "./snapshots/*" ! -name quota.user ! -name quota.group \
		-delete -type d -prune

	rm -fr /tmp/.X11-unix /tmp/.X*-lock
	mkdir -m 1777 /tmp/.X11-unix

cloned: kld
.if !empty(CLONED_INTERFACES)
	echo "MRC:$@> Cloning interfaces: ${CLONED_INTERFACES}"
.	for iface in ${CLONED_INTERFACES}
	ifconfig ${iface} create
.	endfor
.endif

devfs:
	echo "MRC:$@> Applying rules: ${DEVFS_CONFIG_FILES}"
.for file in ${DEVFS_CONFIG_FILES}
.	if exists(${file})
	devfsctl -a -f ${file}
.	endif
.endfor

dmesg: mountlate
.if !empty(DMESG_FILE)
	echo "MRC:$@> Writing dmesg."
	( umask 022 ; dmesg -a > ${DMESG_FILE} ;)
.endif

dumpon: random
.if !empty(DUMPDEV)
	if [ -e ${DUMPDEV} ]; then \
		echo "MRC:$@> Setting dumpon device to ${DUMPDEV}" ;\
		dumpon -v ${DUMPDEV} ;\
	fi
.endif

fsck:
	echo "MRC:$@> Checking disks." ;\
	fsck -p ;\
	case $$? in \
	0) ;; \
	2) exit 1 \
		;; \
	4) echo "Rebooting..." ;\
		reboot ;\
		echo "Reboot failed; help!" ;\
		exit 1 \
		;; \
	8) if [ -n "$${FSCK_Y_ENABLE}" ]; then \
			echo "File system preen failed, trying fsck -y." ;\
			fsck -y || { \
				echo "Automatic file system check failed; help!" ;\
				exit 1 ;\
			} ;\
		else \
			echo "Automatic file system check failed; help!" ;\
			exit 1 ;\
		fi \
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

mount: root zfs
	echo "MRC:$@> Mount local FS." ;\
	mount -uo rw -a ;\
	mount ;\
	mount -a -t no${excludes:ts,}

mountlate: NETWORK mount cleanvar runshm devd
	echo "MRC:$@> Mount late FS." ;\
	mount -a

msgs: mount
	echo "MRC:$@> Making bounds." ;\
		test ! -d /var/msgs -o -f /var/msgs/bound -o -L /var/msgs/bounds || \
		echo 0 > /var/msgs/bounds







|







168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

mount: root zfs
	echo "MRC:$@> Mount local FS." ;\
	mount -uo rw -a ;\
	mount ;\
	mount -a -t no${excludes:ts,}

mountlate: NETWORK mount cleanvar runshm devd mounttmpfs
	echo "MRC:$@> Mount late FS." ;\
	mount -a

msgs: mount
	echo "MRC:$@> Making bounds." ;\
		test ! -d /var/msgs -o -f /var/msgs/bound -o -L /var/msgs/bounds || \
		echo 0 > /var/msgs/bounds
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262

263
264
265

266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
























	echo "MRC:$@> Sending RPC unmount notifications."; \
	test -f /var/db/mounttab || true && \
		rpc.umntall -k
.endif

NETWORK_EXIT: nfsclient_exit

netif: adjkerntz wlans cloned kld
	echo "MRC:$@> Starting interfaces: ${IFCONFIG_IFACES}"
.for iface in ${IFCONFIG_IFACES}
.for item in ${IFCONFIG_${iface}:tW:ts;}
	ifconfig ${iface} ${item}
.endfor
.undef _IFCONFIG_ARGS
.endfor

pf: pflogd
.if empty(PF_ENABLE:tl:Mno)
	echo "MRC:$@> Enabling and loading rules." ;\
	kldload -n pf || exit 1 ;\
	if [ -r ${PF_RULES} ]; then \
		pfctl -Fa || exit 1 ;\
		pfctl -f ${PF_RULES} ${PF_FLAGS} || exit 1 ;\
		pfctl -Si | grep -q Enabled && pfctl -e; \
	else \
		echo "MRC:$@> Can't find file with rules at ${PF_RULES}." ;\
		exit 1 ;\
	fi
.endif

pwcheck: mountlate syslogd
	echo "MRC:$@> Checking password lock file."
.if exists(/etc/ptmp)
	logger -s -p auth.err \
		"password file may be incorrect -- /etc/ptmp exists"
.endif

random: mount devfs
	echo "MRC:$@> Seeding." ;\
	sysctl kern.seedenable=1 > /dev/null ;\
	{ ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww; } 2>&1 | \
		dd status=none of=/dev/random bs=8k ;\
	dd if=/bin/ps status=none of=/dev/random bs=8k ;\
	if [ -d $${ENTROPY_DIR} ]; then \
		find $${ENTROPY_DIR} -type f |\
			xargs -n1 -Ifoo dd status=none if=foo of=/dev/random bs=8k ;\
	else \
		if [ -r ${ENTROPY_FILE} ]; then \
			dd status=none if=${ENTROPY_FILE} of=/dev/random bs=8k ;\
		fi ;\
	fi ;\
	sysctl kern.seedenable=0 > /dev/null

random_exit:
	rm -f ${ENTROPY_FILE}; \

	umask 077 && \
	dd if=/dev/random of=${ENTROPY_FILE} bs=8k count=1 || \
		echo "MRC:$@> entropy file write failed."


DAEMON_EXIT: random_exit

root: fsck bootfs
	echo "MRC:$@> Mount root R/W." ;\
	mount -uo rw

runshm: cleanvar
	echo "MRC:$@> Mount and populate /var/run/shm."; \
	mkdir -p /var/run/shm; \
	mount_tmpfs -m 01777 dummy /var/run/shm; \
	mkdir -p -m 01777 /var/run/shm/tmp; \

savecore: dumpon
.if empty(DUMPDEV:tl:Mno) && exists(${DUMPDEV}) && exists(${DUMPDIR})
	echo "MRC:$@> Saving coredump."; \
	savecore ${DUMPDIR} ${DUMPDEV}
.if empty(CRASHINFO_ENABLE:tl:Mno)
	crashinfo -d ${DUMPDIR}
.endif
.endif

swap: savecore
.if ${:!sysctl -n vm.swap_enabled!}} != 0
	echo "MRC:$@> Enabling swap."; \
	swapon -a
.endif

sysctl: kld root
.if exists(/etc/sysctl.conf)
	echo "MRC:$@> Setting sysctl defaults."; \
	awk '$$0~/^[ ]*(#.*)?$$/{next}{print}' < /etc/sysctl.conf | \
		xargs -n1 sysctl
.endif

sysdb: mountlate
	echo "MRC:$@> Building databases."; \
	install -c -m 644 -g wheel /dev/null /var/run/utmpx

wlans: kld
	echo "MRC:$@> Configuring wlans."; \
	for dev in $$(sysctl -n net.wlan.devices); do \
		eval all_wlans=\$${WLANS_$${dev}}; \
		for wlan in $${all_wlans}; do \
			eval wlan_args=\$${WLANS_$${wlan}_ARGS}; \
			ifconfig $${wlan} create wlandev $${dev} $${wlan_args}; \
			ifconfig $${wlan} up; \
		done; \
	done

zfs:
.if empty(ZFS_ENABLE:tl:Mno)
	zfs mount -va || exit $$? ;\
	zfs share -a || exit $$? ;\
	test -r /etc/zfs/exports || touch /etc/zfs/exports
.endif































|










|
|



|














|
|
|
|
|


|


|
|
|



|
>
|
|
|
>




|


<
<
<
<
<
<


|








|





|





|



|

|

|
|
|
|




|
|
|

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273






274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
	echo "MRC:$@> Sending RPC unmount notifications."; \
	test -f /var/db/mounttab || true && \
		rpc.umntall -k
.endif

NETWORK_EXIT: nfsclient_exit

netif: adjkerntz wlans cloned kld mounttmpfs utmpx
	echo "MRC:$@> Starting interfaces: ${IFCONFIG_IFACES}"
.for iface in ${IFCONFIG_IFACES}
.for item in ${IFCONFIG_${iface}:tW:ts;}
	ifconfig ${iface} ${item}
.endfor
.undef _IFCONFIG_ARGS
.endfor

pf: pflogd
.if empty(PF_ENABLE:tl:Mno)
	echo "MRC:$@> Enabling and loading rules."
	kldload -n pf || exit 1
	if [ -r ${PF_RULES} ]; then \
		pfctl -Fa || exit 1 ;\
		pfctl -f ${PF_RULES} ${PF_FLAGS} || exit 1 ;\
		pfctl -Si | grep -q Enabled && pfctl -e ;\
	else \
		echo "MRC:$@> Can't find file with rules at ${PF_RULES}." ;\
		exit 1 ;\
	fi
.endif

pwcheck: mountlate syslogd
	echo "MRC:$@> Checking password lock file."
.if exists(/etc/ptmp)
	logger -s -p auth.err \
		"password file may be incorrect -- /etc/ptmp exists"
.endif

random: mount devfs
	echo "MRC:$@> Seeding."
	sysctl kern.seedenable=1 > /dev/null
	( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww ;) 2>&1 |\
		dd status=none of=/dev/random bs=8k 2>/dev/null
	dd if=/bin/ps status=none of=/dev/random bs=8k 2>/dev/null
	if [ -d $${ENTROPY_DIR} ]; then \
		find $${ENTROPY_DIR} -type f |\
			xargs -n1 -Ifoo dd status=none if=foo of=/dev/random bs=8k 2>/dev/null ;\
	else \
		if [ -r ${ENTROPY_FILE} ]; then \
			dd status=none if=${ENTROPY_FILE} of=/dev/random bs=8k 2>/dev/null ;\
		fi \
	fi
	sysctl kern.seedenable=0 > /dev/null

random_exit:
	rm -f ${ENTROPY_FILE}
	( \
		umask 077 ;\
		dd if=/dev/random of=${ENTROPY_FILE} bs=8k count=1 2>/dev/null || \
			echo "MRC:$@> entropy file write failed." ;\
	)

DAEMON_EXIT: random_exit

root: fsck bootfs
	echo "MRC:$@> Mount root R/W."
	mount -uo rw







savecore: dumpon
.if empty(DUMPDEV:tl:Mno) && exists(${DUMPDEV}) && exists(${DUMPDIR})
	echo "MRC:$@> Saving coredump."
	savecore ${DUMPDIR} ${DUMPDEV}
.if empty(CRASHINFO_ENABLE:tl:Mno)
	crashinfo -d ${DUMPDIR}
.endif
.endif

swap: savecore
.if ${:!sysctl -n vm.swap_enabled!}} != 0
	echo "MRC:$@> Enabling swap."
	swapon -a
.endif

sysctl: kld root
.if exists(/etc/sysctl.conf)
	echo "MRC:$@> Setting sysctl defaults."
	awk '$$0~/^[ ]*(#.*)?$$/{next}{print}' < /etc/sysctl.conf | \
		xargs -n1 sysctl
.endif

sysdb: mountlate
	echo "MRC:$@> Building databases."
	install -c -m 644 -g wheel /dev/null /var/run/utmpx

wlans: kld
	echo "MRC:$@> Configuring wlans."
	for dev in $$(sysctl -n net.wlan.devices); do \
		eval all_wlans=\$${WLANS_$${dev}} ;\
		for wlan in $${all_wlans}; do \
			eval wlan_args=\$${WLANS_$${wlan}_ARGS} ;\
			ifconfig $${wlan} create wlandev $${dev} $${wlan_args} ;\
			ifconfig $${wlan} up ;\
		done \
	done

zfs:
.if empty(ZFS_ENABLE:tl:Mno)
	zfs mount -va || exit $$?
	zfs share -a || exit $$?
	touch /etc/zfs/exports
.endif

runshm: cleanvar
	echo "MRC:$@> Preparing /var/run."
.	if exists(TMPFS_VAR_RUN_ENABLE)
	/rescue/find /var/run -mindepth 1 -delete
	mount_tmpfs dummy /var/run
.	else
	mkdir -p /var/run/shm
	mount_tmpfs -m 01777 dummy /var/run/shm
.	endif
	mtree -deiqU -f /etc/mtree/BSD.var.dist -p /var

mounttmpfs: cleanvar
	echo "MRC:$@> Mount tmpfs and populating /var/run."
.if exists(TMPFS_TMP_ENABLE)
	mount | awk 'BEGIN{x=1}$$3~/\/tmp/{x=0}END{exit(x)}' || {
		/rescue/find /tmp -mindepth 1 -delete
		mount_tmpfs -m 01777 dummy /tmp
	}
.endif

utmpx: runshm
	echo "MRC:$@> Install utmpx."
	install -m 644 -g wheel /dev/null /var/run/utmpx