Mercurial > vanilla
diff core/sysvinit/rc.init @ 184:36f3ab3945d7
core/sysvinit: add basic init scripts
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 16 Mar 2019 21:54:36 +0100 |
parents | |
children | 01b5d3175215 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/sysvinit/rc.init Sat Mar 16 21:54:36 2019 +0100 @@ -0,0 +1,68 @@ +# +# /etc/rc.init: system initialization script +# + +if [ -f /etc/rc.conf ]; then + source /etc/rc.conf +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 /proc >/dev/null 2>&1; then + /usr/bin/mount -t proc none /proc >/dev/null 2>&1 + echo -n "/proc " + fi + + if ! /usr/bin/mountpoint /sys >/dev/null 2>&1; then + /usr/bin/mount -t sysfs none /sys >/dev/null 2>&1 + echo -n "/sys " + fi + + echo "done." +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