diff core/rc/rc.init @ 566:ddb052f876cd

core/rc: move etc services to rc, closes #1666
author David Demelier <markand@malikania.fr>
date Fri, 05 Jul 2019 20:58:54 +0200
parents core/etc/rc.init@15992f10ced3
children 290ca0287e5d
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/rc/rc.init	Fri Jul 05 20:58:54 2019 +0200
@@ -0,0 +1,131 @@
+#!/bin/sh
+#
+# /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[33;1mVanilla Linux\033[0m\n\n"
+fi
+
+if [ -n "$HOSTNAME" ] && [ -x /bin/hostname ]; then
+	echo "Setting hostname: $HOSTNAME"
+	/bin/hostname "$HOSTNAME"
+fi
+
+if [ -x /bin/sysctl ]; then
+	echo "Setting kernel parameters."
+	/bin/sysctl -p >/dev/null 2>&1
+fi
+
+if [ -x /bin/mountpoint ]; then
+	echo -n "Mounting filesystems: "
+
+	if ! /bin/mountpoint /dev >/dev/null 2>&1; then
+		/bin/mount -t devtmpfs devtmpfs /dev >/dev/null 2>&1
+		echo -n "/dev "
+	fi
+
+	if ! /bin/mountpoint /proc >/dev/null 2>&1; then
+		/bin/mount -t proc proc /proc >/dev/null 2>&1
+		echo -n "/proc "
+	fi
+
+	if ! /bin/mountpoint /sys >/dev/null 2>&1; then
+		/bin/mount -t sysfs sysfs /sys >/dev/null 2>&1
+		echo -n "/sys "
+	fi
+
+	if ! /bin/mountpoint /run >/dev/null 2>&1; then
+		/bin/mount -t tmpfs tmpfs /run >/dev/null 2>&1
+		echo -n "/run "
+	fi
+
+	echo "done."
+fi
+
+# Clean pid files before starting any services.
+find /var/run -type f -name "*.pid" -delete
+
+#
+# Start a device service. Both eudev and busybox's mdev are supported but only
+# one at a time must be enabled.
+#
+if [ -x /etc/rc.d/udevd ] && [ -x /etc/rc.d/busybox.mdev ]; then
+	echo "Warning: both /etc/rc.d/udevd and /etc/rc.d/busybox.mdev are enabled" 1>&2
+	echo "Warning: using udevd instead" 1>&2
+fi
+
+if [ -x /etc/rc.d/udevd ]; then
+	/etc/rc.d/udevd start
+elif [ -x /etc/rc.d/busybox.mdev ]; then
+	/etc/rc.d/busybox.mdev start
+fi
+
+if [ -x /bin/fsck ]; then
+	# Make sure / is ro in case of initrd.
+	/bin/mount -o remount,ro /
+
+	# If /etc/forcefsck is there, force check.
+	if [ -f /etc/forcefsck ]; then
+		force="-f"
+	fi
+
+	/bin/fsck $force -A -T -C -a >/dev/null 2>&1
+
+	if [ "$?" -gt 1 ]; then
+		echo "* Filesystem check failed"
+		/bin/sulogin -p
+	fi
+fi
+
+# Remount / and enable swap as the system is ready.
+/bin/mount -o remount,rw /
+/bin/swapon -a
+
+# Update shared library caches.
+if [ -x /bin/ldconfig ]; then
+	/bin/ldconfig
+fi
+
+if [ -n "$TIMEZONE" ]; then
+	echo -n "Setting timezone: "
+
+	if [ -f /share/zoneinfo/$TIMEZONE ]; then
+		/bin/ln -sf /share/zoneinfo/$TIMEZONE /etc/localtime
+		echo "$TIMEZONE."
+	else
+		echo "$TIMEZONE not found."
+	fi
+fi
+
+# Console font and keymap.
+if [ -n "$FONT" ] && [ -x /bin/setfont ]; then
+	echo "Setting font: $FONT"
+	/bin/setfont $FONT
+fi
+
+if [ -n "$KEYMAP" ] && [ -x /bin/loadkeys ]; then
+	echo "Setting keymap: $KEYMAP"
+	/bin/loadkeys $KEYMAP
+fi
+
+# Cleanup some files.
+rm -f /etc/forcefsck