alicelinux

A lightweight musl + clang/llvm + libressl + busybox distro
git clone https://codeberg.org/emmett1/alicelinux
Log | Files | Refs | README | LICENSE

rc.boot (3237B)


      1 #!/bin/sh
      2 
      3 PATH=/bin:/usr/bin:/sbin:/usr/sbin
      4 
      5 echo "> Alice booting..."
      6 
      7 echo "> Mounting virtual filesystems..."
      8 mountpoint -q /proc    || mount -t proc proc /proc -o nosuid,noexec,nodev
      9 mountpoint -q /sys     || mount -t sysfs sys /sys -o nosuid,noexec,nodev
     10 mountpoint -q /run     || mount -t tmpfs run /run -o mode=0755,nosuid,nodev
     11 mountpoint -q /dev     || mount -t devtmpfs dev /dev -o mode=0755,nosuid
     12 mkdir -p /run/lock /dev/pts /dev/shm /run/runit
     13 mountpoint -q /dev/pts || mount /dev/pts >/dev/null 2>&1 || mount -t devpts devpts /dev/pts -o mode=0620,gid=5,nosuid,noexec
     14 mountpoint -q /dev/shm || mount /dev/shm >/dev/null 2>&1 || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev
     15 
     16 if [ "$(command -v udevd)" ]; then
     17 	echo "> Starting udevd daemon..."
     18 	udevd --daemon
     19 	udevadm trigger --action=add    --type=subsystems
     20 	udevadm trigger --action=add    --type=devices
     21 	udevadm settle
     22 else
     23 	# In the case the user may preffer mdevd as opposed to busybox mdev
     24 	if [ ! -d "/var/service/mdevd" ]; then
     25 		echo "> Starting mdev..."
     26 		echo "/sbin/mdev" > /proc/sys/kernel/hotplug
     27 		mdev -s
     28 	fi
     29 	find /sys -name 'modalias' -type f -exec cat '{}' + | sort -u | xargs modprobe -b -a 2>/dev/null
     30 	ln -s /proc/self/fd /dev/fd
     31 	ln -s fd/0          /dev/stdin
     32 	ln -s fd/1          /dev/stdout
     33 	ln -s fd/2          /dev/stderr
     34 fi
     35 
     36 echo "> Loading kernel modules..."
     37 if [ -f /etc/rc.modules ]; then
     38     while read -r module; do
     39         [ -n "$module" ] && ! echo "$module" | grep -q '^#' && modprobe "$module"
     40     done < /etc/rc.modules
     41 fi
     42 
     43 echo "> Bringing up loopback interface..."
     44 ip link set lo up
     45 
     46 echo "> Remounting root as read-only..."
     47 mount -o remount,ro /
     48 
     49 for arg in $(cat /proc/cmdline); do
     50     case $arg in
     51          fastboot) FASTBOOT=1;;
     52         forcefsck) FORCEFSCK="-f";;
     53     esac
     54 done
     55 
     56 if [ ! "$FASTBOOT" ]; then
     57 	echo "> Running filesystem check..."
     58 	fsck $FORCEFSCK -ATat noopts=_netdev
     59 	if [ "$?" -gt 1 ]; then
     60 		echo "*******************************************"
     61 		echo "**        Filesystem check failed        **"
     62 		echo "** You been dropped to maintenance shell **"
     63 		echo "*******************************************"
     64 		sulogin -p
     65 	fi
     66 fi
     67 
     68 echo "> Enabling swap..."
     69 swapon -a
     70 
     71 echo "> Remounting root as read-write..."
     72 mount -o remount,rw /
     73 
     74 echo "> Mounting all filesystems..."
     75 mount -a
     76 
     77 if [ ! -f /etc/hostname ]; then
     78 	echo localhost > /etc/hostname
     79 fi
     80 echo "> Setting hostname..."
     81 hostname -F /etc/hostname
     82 
     83 echo "> Cleaning stale PID files and /tmp..."
     84 find /var/run -name "*.pid" -delete
     85 find /tmp -xdev -mindepth 1 ! -name lost+found -delete
     86 
     87 if [ -f "/etc/sysctl.conf" ]; then
     88 	echo "> Applying sysctl settings..."
     89 	sysctl -q -p
     90 fi
     91 
     92 if [ -e /dev/rtc ] || [ -e /dev/rtc0 ]; then
     93 	echo "> Restoring hardware clock..."
     94 	hwclock -s -u
     95 fi
     96 
     97 if [ -f "/var/lib/random-seed" ]; then
     98 	echo "> Seeding /dev/urandom..."
     99 	cat /var/lib/random-seed >/dev/urandom
    100 	rm -f /var/lib/random-seed
    101 fi
    102 
    103 if [ -d /sys/firmware/efi/efivars ]; then
    104 	echo "> Mounting efivarfs..."
    105 	mount -t efivarfs none /sys/firmware/efi/efivars
    106 fi
    107 
    108 dmesg >/var/log/dmesg.log
    109 
    110 if [ -x /etc/rc.boot.local ]; then
    111 	echo "> Running local boot script..."
    112 	/etc/rc.boot.local
    113 fi
    114 
    115 IFS=. read -r boottime _ < /proc/uptime
    116 echo "booted in ${boottime}s..."