changeset 575:3c0d8d9fe11e

core/rc: simplify rc.init
author David Demelier <markand@malikania.fr>
date Mon, 08 Jul 2019 20:16:00 +0200
parents 789137658fdb
children 9eadb49b7fbf
files core/rc/rc.init
diffstat 1 files changed, 36 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/core/rc/rc.init	Mon Jul 08 20:11:00 2019 +0200
+++ b/core/rc/rc.init	Mon Jul 08 20:16:00 2019 +0200
@@ -25,41 +25,37 @@
 	printf "\nWelcome to \033[33;1mVanilla Linux\033[0m\n\n"
 fi
 
-if [ -n "$HOSTNAME" ] && [ -x /bin/hostname ]; then
+if [ -n "$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
+echo "Setting kernel parameters"
+/bin/sysctl -p >/dev/null 2>&1
+
+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 [ -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 /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 /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
+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
+echo "done"
 
 # Clean pid files before starting any services.
 find /var/run -type f -name "*.pid" -delete
@@ -79,21 +75,20 @@
 	/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 /
+# 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
+# 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
+/bin/fsck $force -A -T -C -a >/dev/null 2>&1
 
-	if [ "$?" -gt 1 ]; then
-		echo "* Filesystem check failed"
-		/bin/sulogin -p
-	fi
+if [ "$?" -gt 1 ]; then
+	echo "* Filesystem check failed"
+	/bin/sulogin -p
+	/bin/reboot
 fi
 
 # Remount / and enable swap as the system is ready.
@@ -101,9 +96,7 @@
 /bin/swapon -a
 
 # Update shared library caches.
-if [ -x /bin/ldconfig ]; then
-	/bin/ldconfig
-fi
+/bin/ldconfig
 
 if [ -n "$TIMEZONE" ] && [ "$TIMEZONE" != "UTC" ]; then
 	echo -n "Setting timezone: "
@@ -117,12 +110,12 @@
 fi
 
 # Console font and keymap.
-if [ -n "$FONT" ] && [ -x /bin/setfont ]; then
+if [ -n "$FONT" ]; then
 	echo "Setting font: $FONT"
 	/bin/setfont $FONT
 fi
 
-if [ -n "$KEYMAP" ] && [ -x /bin/loadkeys ]; then
+if [ -n "$KEYMAP" ]; then
 	echo "Setting keymap: $KEYMAP"
 	/bin/loadkeys $KEYMAP
 fi