Annotation For init.mk
Logged in as anonymous

Lines of init.mk from check-in 6de7ae29c1 that are changed by the sequence of edits moving toward check-in f49abe7565:

                         1: # Meta targets
                         2: 
                         3: TARGETS:=adjkerntz bootfs cleanvar cleartmp cloned devfs dmesg dumpon fsck \
6de7ae29c1 2023-11-04    4: 	hostname kld ldconfig microcode mixer mount mountlate msgs netif \
6de7ae29c1 2023-11-04    5: 	newsyslog nextboot nfsclient pf pwcheck random root runshm savecore swap \
6de7ae29c1 2023-11-04    6: 	sysctl sysdb wlans zfs mounttmpfs utmpx
                         7: 
                         8: OTHER_TARGETS+=mixer_exit nfsclient_exit random_exit
                         9: 
                        10: DAEMON: pwcheck sysctl sysdb NETWORK SERVERS ldconfig nfsclient cleartmp pflogd
                        11: 
                        12: LOGIN: DAEMON dntpd msgs powerd pflogd
                        13: 
                        14: NETWORK: netif devd hostname
                        15: 
                        16: SERVERS: swap mountlate syslogd newsyslog
                        17: 
                        18: SERVICE: netif mount random hostname cleanvar
                        19: 
                        20: # regular targets
                        21: 
                        22: adjkerntz: random mount
                        23: 	echo "MRC:$@> Adjust kernel timezone."
                        24: 	adjkerntz -i &
                        25: 
                        26: bootfs: fsck
                        27: 	echo "MRC:$@> Checking whether we need /boot mounted."
                        28: 	mount -vadr | grep -q ' /boot$$' && mount -r /boot || true
                        29: 
                        30: cleanvar: mount
                        31: 	echo "MRC:$@> Cleaning '/var's."
                        32: .for dir in ${CLEANVAR_DIRS}
                        33: 	if [ -d ${dir} ]; then \
6de7ae29c1 2023-11-04   34: 		/rescue/find ${dir} -mindepth 1 -delete ;\
                        35: 	fi
                        36: .endfor
                        37: 
                        38: cleartmp: mountlate
                        39: 	echo "MRC:$@> Clearing tmp."
                        40: 	find -x /tmp -mindepth 1 ! -name lost+found ! -name snapshots \
                        41: 		! -path "./snapshots/*" ! -name quota.user ! -name quota.group \
                        42: 		-delete -type d -prune
                        43: 	rm -fr /tmp/.X11-unix /tmp/.X*-lock
                        44: 	mkdir -m 1777 /tmp/.X11-unix
                        45: 
                        46: cloned: kld
                        47: .if !empty(CLONED_INTERFACES)
                        48: 	echo "MRC:$@> Cloning interfaces: ${CLONED_INTERFACES}"
                        49: .	for iface in ${CLONED_INTERFACES}
                        50: 	ifconfig ${iface} create
                        51: .	endfor
                        52: .endif
                        53: 
                        54: devfs:
                        55: 	echo "MRC:$@> Applying rules: ${DEVFS_CONFIG_FILES}"
                        56: .for file in ${DEVFS_CONFIG_FILES}
                        57: .	if exists(${file})
                        58: 	devfsctl -a -f ${file}
                        59: .	endif
                        60: .endfor
                        61: 
                        62: dmesg: mountlate
                        63: .if !empty(DMESG_FILE)
                        64: 	echo "MRC:$@> Writing dmesg."
                        65: 	( umask 022 ; dmesg -a > ${DMESG_FILE} ;)
                        66: .endif
                        67: 
                        68: dumpon: random
                        69: .if !empty(DUMPDEV)
                        70: 	if [ -e ${DUMPDEV} ]; then \
6de7ae29c1 2023-11-04   71: 		echo "MRC:$@> Setting dumpon device to ${DUMPDEV}" ;\
6de7ae29c1 2023-11-04   72: 		dumpon -v ${DUMPDEV} ;\
                        73: 	fi
                        74: .endif
                        75: 
                        76: fsck:
6de7ae29c1 2023-11-04   77: 	echo "MRC:$@> Checking disks." ;\
6de7ae29c1 2023-11-04   78: 	fsck -p ;\
                        79: 	case $$? in \
                        80: 	0) ;; \
                        81: 	2) exit 1 \
                        82: 		;; \
6de7ae29c1 2023-11-04   83: 	4) echo "Rebooting..." ;\
                        84: 		reboot ;\
6de7ae29c1 2023-11-04   85: 		echo "Reboot failed; help!" ;\
                        86: 		exit 1 \
                        87: 		;; \
                        88: 	8) if [ -n "$${FSCK_Y_ENABLE}" ]; then \
6de7ae29c1 2023-11-04   89: 			echo "File system preen failed, trying fsck -y." ;\
                        90: 			fsck -y || { \
6de7ae29c1 2023-11-04   91: 				echo "Automatic file system check failed; help!" ;\
6de7ae29c1 2023-11-04   92: 				exit 1 ;\
6de7ae29c1 2023-11-04   93: 			} ;\
                        94: 		else \
6de7ae29c1 2023-11-04   95: 			echo "Automatic file system check failed; help!" ;\
6de7ae29c1 2023-11-04   96: 			exit 1 ;\
                        97: 		fi \
                        98: 		;; \
6de7ae29c1 2023-11-04   99: 	12) echo "Boot interrupted." ;\
                       100: 		exit 1 \
                       101: 		;; \
                       102: 	130) exit 1 \
                       103: 		;; \
6de7ae29c1 2023-11-04  104: 	*) echo "Unknown error, help!" ;\
                       105: 		exit 1 \
                       106: 		;; \
                       107: 	esac
                       108: 
                       109: hostname:
                       110: 	echo "MRC:$@> Setting to ${HOSTNAME}."
                       111: 	hostname ${HOSTNAME}
                       112: 
                       113: kld: bootfs
                       114: .if defined(KLD_LIST)
                       115: 	echo "MRC:$@> Loading kernel modules: ${KLD_LIST}"
                       116: .	for KLD in ${KLD_LIST}
                       117: 	kldload -n ${KLD} || echo "MRC:$@> Failed to load module: ${KLD}"
                       118: .	endfor
                       119: 	true
                       120: .endif
                       121: 
                       122: # ldconfig
                       123: .for path in ${LDCONFIG_PATHS} /etc/ld-elf.so.conf
                       124: .if exists(${path})
                       125: ldc+=${path}
                       126: .endif
                       127: .endfor
                       128: 
                       129: .for dir in ${LDCONFIG_LOCAL_DIRS}
                       130: .if exists(${dir})
                       131: ldc+=${:!find ${dir} -type f!}
                       132: .endif
                       133: .endfor
                       134: 
                       135: ldconfig: mountlate
6de7ae29c1 2023-11-04  136: 	echo "MRC:$@> Initializing shared libraries: ${ldc}"; \
                       137: 	ldconfig -elf ${ldc}
                       138: 
                       139: microcode: mountlate
6de7ae29c1 2023-11-04  140: 	test -d /usr/local/share/cpucontrol || exit 0 ;\
6de7ae29c1 2023-11-04  141: 	echo "MRC:$@> Updating microcode." ;\
6de7ae29c1 2023-11-04  142: 	kldload -n cpuctl || exit 1 ;\
6de7ae29c1 2023-11-04  143: 	for cpu in $$(jot ${NCPU} 0); do \
6de7ae29c1 2023-11-04  144: 		{ cpucontrol -u -d /usr/local/share/cpucontrol /dev/cpuctl$${cpu} \
6de7ae29c1 2023-11-04  145: 			|| exit 1 ;\
6de7ae29c1 2023-11-04  146: 		} | grep -v '^TEST' ;\
6de7ae29c1 2023-11-04  147: 		cpucontrol -e /dev/cpuctl$${cpu} || exit 1 ;\
6de7ae29c1 2023-11-04  148: 	done
6de7ae29c1 2023-11-04  149: 
6de7ae29c1 2023-11-04  150: mixers=${:!find /dev -name 'mixer*'!:S/\/dev\///}
6de7ae29c1 2023-11-04  151: 
6de7ae29c1 2023-11-04  152: mixer: mount cleanvar
                       153: 	echo "MRC:$@> Restoring levels."
6de7ae29c1 2023-11-04  154: .for mixer in ${mixers}
6de7ae29c1 2023-11-04  155: 	if [ -r /var/db/${mixer}-state ]; then \
6de7ae29c1 2023-11-04  156: 		mixer -f /dev/${mixer} `cat /var/db/${mixer}-state` ;\
6de7ae29c1 2023-11-04  157: 	fi
6de7ae29c1 2023-11-04  158: .endfor
                       159: 
                       160: mixer_exit:
                       161: 	echo "MRC:$@> Saving mixer levels."
6de7ae29c1 2023-11-04  162: .for mixer in ${mixers}
6de7ae29c1 2023-11-04  163: 	if [ -r /dev/${mixer} ]; then \
6de7ae29c1 2023-11-04  164: 		mixer -f /dev/${mixer} -s > /var/db/${mixer}-state ;\
6de7ae29c1 2023-11-04  165: 	fi
6de7ae29c1 2023-11-04  166: .endfor
                       167: 
                       168: DAEMON_EXIT: mixer_exit
                       169: 
                       170: excludes=${NETFS_TYPES:C/:.*//}
                       171: 
                       172: mount: root zfs
6de7ae29c1 2023-11-04  173: 	echo "MRC:$@> Mount local FS." ;\
6de7ae29c1 2023-11-04  174: 	mount -uo rw -a ;\
6de7ae29c1 2023-11-04  175: 	mount ;\
                       176: 	mount -a -t no${excludes:ts,}
                       177: 
                       178: mountlate: NETWORK mount cleanvar runshm devd mounttmpfs
6de7ae29c1 2023-11-04  179: 	echo "MRC:$@> Mount late FS." ;\
                       180: 	mount -a
                       181: 
                       182: msgs: mount
6de7ae29c1 2023-11-04  183: 	echo "MRC:$@> Making bounds." ;\
6de7ae29c1 2023-11-04  184: 		test ! -d /var/msgs -o -f /var/msgs/bound -o -L /var/msgs/bounds || \
                       185: 		echo 0 > /var/msgs/bounds
                       186: 
                       187: newsyslog: mountlate sysdb
                       188: 	if [ -n "$${NEWSYSLOG_ENABLE}" ]; then \
6de7ae29c1 2023-11-04  189: 		echo "MRC:$@> Trimming log files." ;\
6de7ae29c1 2023-11-04  190: 		/usr/sbin/newsyslog ${NEWSYSLOG_FLAGS} ;\
                       191: 	fi
                       192: 
                       193: nextboot: mount
                       194: .if exists(/boot/nextkernel)
                       195: 	echo "MRC:$@> Removing nextboot setting."
                       196: 	rm -f /boot/nextkernel
                       197: .endif
                       198: 
                       199: .if empty(NFSCLIENT_ENABLE:tl:Mno)
                       200: DAEMON_rpcbind_ENABLE=yes
                       201: .endif
                       202: 
                       203: nfsclient: NETWORK rpcbind
                       204: 	if [ -n "$${NFSCLIENT_ENABLE}" ]; then \
6de7ae29c1 2023-11-04  205: 		kldload -n nfs ;\
                       206: 	fi
                       207: 
                       208: nfsclient_exit: DAEMON_EXIT
                       209: .if empty(RPC_UMNTALL_ENABLE:tl:Mno)
6de7ae29c1 2023-11-04  210: 	echo "MRC:$@> Sending RPC unmount notifications."; \
6de7ae29c1 2023-11-04  211: 	test -f /var/db/mounttab || true && \
6de7ae29c1 2023-11-04  212: 		rpc.umntall -k
                       213: .endif
                       214: 
                       215: NETWORK_EXIT: nfsclient_exit
                       216: 
6de7ae29c1 2023-11-04  217: netif: adjkerntz wlans cloned kld mounttmpfs utmpx
                       218: 	echo "MRC:$@> Starting interfaces: ${IFCONFIG_IFACES}"
                       219: .for iface in ${IFCONFIG_IFACES}
                       220: .	for item in ${IFCONFIG_${iface}:tW:ts;}
                       221: 	ifconfig ${iface} ${item}
                       222: .	endfor
                       223: .	undef _IFCONFIG_ARGS
                       224: .endfor
                       225: 
                       226: pf: pflogd
                       227: .if empty(PF_ENABLE:tl:Mno)
                       228: 	echo "MRC:$@> Enabling and loading rules."
6de7ae29c1 2023-11-04  229: 	kldload -n pf || exit 1
6de7ae29c1 2023-11-04  230: 	if [ -r ${PF_RULES} ]; then \
6de7ae29c1 2023-11-04  231: 		pfctl -Fa || exit 1 ;\
6de7ae29c1 2023-11-04  232: 		pfctl -f ${PF_RULES} ${PF_FLAGS} || exit 1 ;\
6de7ae29c1 2023-11-04  233: 		pfctl -Si | grep -q Enabled && pfctl -e ;\
6de7ae29c1 2023-11-04  234: 	else \
6de7ae29c1 2023-11-04  235: 		echo "MRC:$@> Can't find file with rules at ${PF_RULES}." ;\
6de7ae29c1 2023-11-04  236: 		exit 1 ;\
                       237: 	fi
                       238: .endif
                       239: 
                       240: pwcheck: mountlate syslogd
                       241: 	echo "MRC:$@> Checking password lock file."
                       242: .if exists(/etc/ptmp)
                       243: 	logger -s -p auth.err \
                       244: 		"password file may be incorrect -- /etc/ptmp exists"
                       245: .endif
                       246: 
                       247: random: mount devfs
                       248: 	echo "MRC:$@> Seeding."
                       249: 	sysctl kern.seedenable=1 > /dev/null
6de7ae29c1 2023-11-04  250: 	( ps -fauxww; sysctl -a; date; df -ib; dmesg; ps -fauxww ;) 2>&1 |\
                       251: 		dd status=none of=/dev/random bs=8k 2>/dev/null
                       252: 	dd if=/bin/ps status=none of=/dev/random bs=8k 2>/dev/null
                       253: 	if [ -d $${ENTROPY_DIR} ]; then \
6de7ae29c1 2023-11-04  254: 		find $${ENTROPY_DIR} -type f |\
6de7ae29c1 2023-11-04  255: 			xargs -n1 -Ifoo dd status=none if=foo of=/dev/random bs=8k 2>/dev/null ;\
                       256: 	else \
                       257: 		if [ -r ${ENTROPY_FILE} ]; then \
6de7ae29c1 2023-11-04  258: 			dd status=none if=${ENTROPY_FILE} of=/dev/random bs=8k 2>/dev/null ;\
                       259: 		fi \
                       260: 	fi
                       261: 	sysctl kern.seedenable=0 > /dev/null
                       262: 
                       263: random_exit:
6de7ae29c1 2023-11-04  264: 	rm -f ${ENTROPY_FILE}
                       265: 	( \
6de7ae29c1 2023-11-04  266: 		umask 077 ;\
                       267: 		dd if=/dev/random of=${ENTROPY_FILE} bs=8k count=1 2>/dev/null || \
6de7ae29c1 2023-11-04  268: 			echo "MRC:$@> entropy file write failed." ;\
                       269: 	)
                       270: 
                       271: DAEMON_EXIT: random_exit
                       272: 
                       273: root: fsck bootfs
                       274: 	echo "MRC:$@> Mount root R/W."
                       275: 	mount -uo rw
                       276: 
                       277: savecore: dumpon
                       278: .if empty(DUMPDEV:tl:Mno) && exists(${DUMPDEV}) && exists(${DUMPDIR})
                       279: 	echo "MRC:$@> Saving coredump."
                       280: 	savecore ${DUMPDIR} ${DUMPDEV}
                       281: .if empty(CRASHINFO_ENABLE:tl:Mno)
                       282: 	crashinfo -d ${DUMPDIR}
                       283: .endif
                       284: .endif
                       285: 
                       286: swap: savecore
                       287: .if ${:!sysctl -n vm.swap_enabled!}} != 0
                       288: 	echo "MRC:$@> Enabling swap."
                       289: 	swapon -a
                       290: .endif
                       291: 
                       292: sysctl: kld root
                       293: .if exists(/etc/sysctl.conf)
                       294: 	echo "MRC:$@> Setting sysctl defaults."
                       295: 	awk '$$0~/^[ ]*(#.*)?$$/{next}{print}' < /etc/sysctl.conf | \
                       296: 		xargs -n1 sysctl
                       297: .endif
                       298: 
                       299: sysdb: mountlate
                       300: 	echo "MRC:$@> Building databases."
                       301: 	install -c -m 644 -g wheel /dev/null /var/run/utmpx
                       302: 
                       303: wlans: kld
6de7ae29c1 2023-11-04  304: 	echo "MRC:$@> Configuring wlans."
                       305: 	for dev in $$(sysctl -n net.wlan.devices); do \
6de7ae29c1 2023-11-04  306: 		eval all_wlans=\$${WLANS_$${dev}} ;\
                       307: 		for wlan in $${all_wlans}; do \
6de7ae29c1 2023-11-04  308: 			eval wlan_args=\$${WLANS_$${wlan}_ARGS} ;\
6de7ae29c1 2023-11-04  309: 			ifconfig $${wlan} create wlandev $${dev} $${wlan_args} ;\
6de7ae29c1 2023-11-04  310: 			ifconfig $${wlan} up ;\
                       311: 		done \
                       312: 	done
                       313: 
                       314: zfs:
                       315: .if empty(ZFS_ENABLE:tl:Mno)
                       316: 	zfs mount -va || exit $$?
                       317: 	zfs share -a || exit $$?
                       318: 	touch /etc/zfs/exports
                       319: .endif
                       320: 
                       321: runshm: cleanvar
                       322: 	echo "MRC:$@> Preparing /var/run."
                       323: .	if exists(TMPFS_VAR_RUN_ENABLE)
                       324: 	/rescue/find /var/run -mindepth 1 -delete
                       325: 	mount_tmpfs dummy /var/run
                       326: .	else
                       327: 	mkdir -p /var/run/shm
                       328: 	mount_tmpfs -m 01777 dummy /var/run/shm
                       329: .	endif
                       330: 	mtree -deiqU -f /etc/mtree/BSD.var.dist -p /var
                       331: 
                       332: mounttmpfs: cleanvar
                       333: 	echo "MRC:$@> Mount tmpfs and populating /var/run."
                       334: .if exists(TMPFS_TMP_ENABLE)
6de7ae29c1 2023-11-04  335: 	mount | awk 'BEGIN{x=1}$$3~/\/tmp/{x=0}END{exit(x)}' || {
6de7ae29c1 2023-11-04  336: 		/rescue/find /tmp -mindepth 1 -delete
6de7ae29c1 2023-11-04  337: 		mount_tmpfs -m 01777 dummy /tmp
                       338: 	}
                       339: .endif
                       340: 
                       341: utmpx: runshm
                       342: 	echo "MRC:$@> Install utmpx."
                       343: 	install -m 644 -g wheel /dev/null /var/run/utmpx