view core/sysvinit/rc.init @ 448:32de384fc96f

terminals/xterm: add patch from Alpine
author David Demelier <markand@malikania.fr>
date Fri, 05 Apr 2019 13:46:20 +0200
parents 0d51fe2867b5
children 014d018468fb
line wrap: on
line source

#
# /etc/rc.init: system initialization script
#
# Copyright (c) 2019 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

if [ -f /etc/rc.conf ]; then
	. /etc/rc.conf
fi

if [ "${BANNER:-yes}" = "yes" ]; then
	printf "\nWelcome to \033[34mVanilla Linux\033[0m\n\n"
fi

if [ -n "$HOSTNAME" ] && [ -x /usr/bin/hostname ]; then
	echo "Setting hostname: $HOSTNAME"
	/usr/bin/hostname "$HOSTNAME"
fi

if [ -x /usr/sbin/sysctl ]; then
	echo "Setting kernel parameters."
	/usr/sbin/sysctl -p >/dev/null 2>&1
fi

if [ -x /usr/bin/mountpoint ]; then
	echo -n "Mounting filesystems: "

	if ! /usr/bin/mountpoint /dev >/dev/null 2>&1; then
		/usr/bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1
		echo -n "/dev "
	fi

	if ! /usr/bin/mountpoint /proc >/dev/null 2>&1; then
		/usr/bin/mount -t proc proc /proc >/dev/null 2>&1
		echo -n "/proc "
	fi

	if ! /usr/bin/mountpoint /sys >/dev/null 2>&1; then
		/usr/bin/mount -t sysfs sysfs /sys >/dev/null 2>&1
		echo -n "/sys "
	fi

	if ! /usr/bin/mountpoint /run >/dev/null 2>&1; then
		/usr/bin/mount -t tmpfs tmpfs /run >/dev/null 2>&1
		echo -n "/run "
	fi

	echo "done."
fi

if [ -x /etc/rc.d/udevd ]; then
	/etc/rc.d/udevd start
fi

if [ -x /usr/sbin/fsck ]; then
	# Make sure / is ro in case of initrd.
	/usr/bin/mount -o remount,ro /

	# If /etc/forcefsck is there, force check.
	if [ -f /etc/forcefsck ]; then
		force="-f"
	fi

	/usr/sbin/fsck $force -A -T -C -a >/dev/null 2>&1

	if [ "$?" -gt 1 ]; then
		echo "* Filesystem check failed"
		/usr/sbin/sulogin -p
	fi
fi

# Remount / and enable swap as the system is ready.
/usr/bin/mount -o remount,rw /
/usr/sbin/swapon -a

if [ -n "$TIMEZONE" ]; then
	echo -n "Setting timezone: "

	if [ -f /usr/share/zoneinfo/$TIMEZONE ]; then
		/usr/bin/ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
		echo "$TIMEZONE."
	else
		echo "$TIMEZONE not found."
	fi
fi

# cleanup some files.
rm -f /etc/forcefsck