rc/rc

124 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
#
# /etc/rc: system boot script
#
echo "The system is coming up. Please wait."
# Load configuration
. /etc/rc.conf
# Start udev
/sbin/mdev -s
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
# Those two seem to be already mounted at this point on Alpine.
# FIXME: I have no idea why. Who does that? kernel config? kernel parameters?
#/bin/mount -t proc none /proc
#/bin/mount -t sysfs none /sys
# FIXME: Should probably be replaced by mdev or something... right?
#/sbin/start_udev
# FIXME: this loads kernel drivers. Not sure it should be here, but... may it should?
# FIXME: this also makes the system rely on /usr/bin to be bootable. blergh
/usr/bin/find /sys -name modalias -type f -print0 | xargs -0 sort -u \
| /usr/bin/xargs modprobe -b -a 2> /dev/null
# Create device-mapper device nodes and scan for LVM volume groups
if [ -x /sbin/lvm ]; then
/sbin/vgscan --mknodes --ignorelockingfailure
/sbin/vgchange --sysinit -a y
fi
# Mount root read-only
/bin/mount -o remount,ro /
if [ -f /forcefsck ]; then
FORCEFSCK="-f"
fi
# Check filesystems
/sbin/fsck $FORCEFSCK -A -T -a
if [ $? -gt 1 ]; then
echo
echo "*************** FILESYSTEM CHECK FAILED ******************"
echo "* *"
echo "* Please repair manually and reboot. Note that the root *"
echo "* file system is currently mounted read-only. To remount *"
echo "* it read-write type: mount -n -o remount,rw / *"
echo "* When you exit the maintainance shell the system will *"
echo "* reboot automatically. *"
echo "* *"
echo "************************************************************"
echo
/sbin/sulogin -p
echo "Automatic reboot in progress..."
/bin/umount -a -r
/bin/mount -o remount,ro /
/sbin/reboot -f
exit 0
fi
# Mount local filesystems
/bin/mount -o remount,rw /
/bin/mount -a -O no_netdev
# Activate swap
/sbin/swapon -a
# Clean up misc files
: > /var/run/utmp
/bin/rm -rf /forcefsck /fastboot /etc/nologin /etc/shutdownpid
(cd /var/run && /usr/bin/find . -name "*.pid" -delete)
(cd /var/lock && /usr/bin/find . ! -type d -delete)
(cd /tmp && /usr/bin/find . ! -name . -delete)
/bin/mkdir -m 1777 /tmp/.ICE-unix
# Set kernel variables
/sbin/sysctl -p > /dev/null
# Update shared library links
/sbin/ldconfig
# Configure host name
if [ "$HOSTNAME" ]; then
echo "hostname: $HOSTNAME"
/bin/hostname $HOSTNAME
fi
# Load random seed
/bin/cat /var/lib/urandom/seed > /dev/urandom
# Configure system clock
if [ "$TIMEZONE" ]; then
/bin/ln -snf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
fi
/sbin/hwclock --hctosys
# Load console font
# FIXME: Disabled because no font?
#if [ "$FONT" ]; then
# echo "font: $FONT"
# /usr/sbin/setfont $FONT
#fi
# Load console keymap
if [ "$KEYMAP" ]; then
echo "keyboard: $KEYMAP (DISABLED BECAUSE LOADKEYS UNAVAILABLE)"
#/usr/bin/loadkeys -q $KEYMAP
# zcat "$KEYMAP" | loadkmap
fi
# Screen blanks after 15 minutes idle time
#/usr/bin/setterm -blank 15
# Run module initialization script
if [ -x /etc/rc.modules ]; then
/etc/rc.modules
fi
# Save boot messages
/bin/dmesg > /var/log/boot
# End of file