view profiles/SMALL_/files/etc/rc.d/mountcritlocal @ 443:eddcdc561685

Autoconfig /tmp depend on files: tmpfs.ko - mount tmpfs to /tmp else md + ufs else md + msdos.
author Aleksandr Rybalko <ray@ddteam.net>
date Thu, 20 Sep 2012 15:34:37 +0300
parents 1dc8c70afbe5
children
line wrap: on
line source
#!/bin/sh

# PROVIDE: mountcritlocal

. /etc/rc.subr
. /etc/network.subr

name="MAIN"
start_cmd="mountcritlocal_start"

mountcritlocal_start()
{
	# XXX: check TMPFS again
	# XXX: get useful size: small for /etc or big for upgrade
	_IS_ETC_MOUNTED=0
	if [ -f /boot/kernel/tmpfs.ko -a "x${TMPFS_ETC_ENABLED}" != "xno" ]; then
		mount -t tmpfs tmpfs /tmp
		_IS_ETC_MOUNTED=1
	else
		md=$(mdconfig -a -t malloc -s 1m)
		if [ -f /boot/kernel/ufs.ko ]; then
			newfs -b 4096 -f 512 -n -o space /dev/${md} > /dev/null
			mount -t ufs /dev/${md} /tmp
			_IS_ETC_MOUNTED=1
		else
			if [ -f /boot/kernel/msdosfs.ko ]; then
				newfs_msdos -n 1 /dev/${md} > /dev/null
				mount -t msdosfs /dev/${md} /tmp
				_IS_ETC_MOUNTED=1
			else
				mdconfig -d ${md}
			fi
		fi
	fi

	mkdir -p /tmp/etc
	for dir in account at audit cache db empty lib log mail msgs preserve \
	    run spool/lock tmp; do
		mkdir -p /tmp/var/${dir}
	done
	touch /tmp/var/log/all.log

	mount_unionfs /tmp/etc /etc

	/etc/rc.restore_config
}

load_rc_config $name

run_rc_command $*