alicelinux

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

commit 5b06140deda36925abe23115dc9affab61527279
parent d1304e447af44d2a455125866b9ffd838909416a
Author: emmett1 <emmett1.2miligrams@protonmail.com>
Date:   Wed, 10 Sep 2025 08:14:17 +0800

initscripts: updated to 20250910

Diffstat:
Mrepos/core/initscripts/.checksum | 5+++--
Mrepos/core/initscripts/.files | 1+
Mrepos/core/initscripts/abuild | 6+++---
Mrepos/core/initscripts/rc.boot | 38+++++++++++++++++++++++++++++++++-----
Arepos/core/initscripts/rc.modules | 2++
Mrepos/core/initscripts/rc.shutdown | 61++++++++++++++++++++++++++++++++++++++++++++++---------------
6 files changed, 88 insertions(+), 25 deletions(-)

diff --git a/repos/core/initscripts/.checksum b/repos/core/initscripts/.checksum @@ -1,5 +1,6 @@ 1ac605ef6b89575ce73faef8a7a55d8c57f4530e70ea9b45fcf0ebc02b7e4fad inittab -7121dccc36a4f025b98ca9511f8249b5f3958ad446b5846ad3f8f3d22a85ba44 rc.boot +44a457da79602f6bc01f6c619be19422d3f7842dbc4e310c9932d91073b01438 rc.boot 6407df1e6c4bb27a0197cdceda085317d365c87221347599f5eb3d98684925fc rc.boot.local -cc87f21b3b0851cbbf433f31b248159adf5be61f2766d68176ad5d7814f9041b rc.shutdown +8c62edf89b05313a2e13036fb00e50bcb67ea3a46b3e58131986c7be2ea2db1d rc.modules +caa61c03a486b8c188a5bb976c170501465534857111f63fcc72d3b35fab271a rc.shutdown 6407df1e6c4bb27a0197cdceda085317d365c87221347599f5eb3d98684925fc rc.shutdown.local diff --git a/repos/core/initscripts/.files b/repos/core/initscripts/.files @@ -2,6 +2,7 @@ drwxr-xr-x root/root etc/ -rw-r--r-- root/root etc/inittab.new -rwxr-xr-x root/root etc/rc.boot.local.new -rwxr-xr-x root/root etc/rc.boot.new +-rwxr-xr-x root/root etc/rc.modules.new -rwxr-xr-x root/root etc/rc.shutdown.local.new -rwxr-xr-x root/root etc/rc.shutdown.new drwxr-xr-x root/root var/ diff --git a/repos/core/initscripts/abuild b/repos/core/initscripts/abuild @@ -1,11 +1,11 @@ name=initscripts -version=20240726 +version=20250910 release=1 -source="rc.boot rc.shutdown rc.boot.local rc.shutdown.local inittab" +source="rc.boot rc.shutdown rc.boot.local rc.shutdown.local rc.modules inittab" build() { mkdir -p $PKG/etc $PKG/var/service - for i in boot boot.local shutdown shutdown.local; do + for i in boot boot.local shutdown shutdown.local modules; do install -m755 $SRC/rc.$i $PKG/etc/rc.$i done install -m644 $SRC/inittab $PKG/etc/inittab diff --git a/repos/core/initscripts/rc.boot b/repos/core/initscripts/rc.boot @@ -2,8 +2,9 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin -echo "Alice booting..." +echo "> Alice booting..." +echo "> Mounting virtual filesystems..." mountpoint -q /proc || mount -t proc proc /proc -o nosuid,noexec,nodev mountpoint -q /sys || mount -t sysfs sys /sys -o nosuid,noexec,nodev mountpoint -q /run || mount -t tmpfs run /run -o mode=0755,nosuid,nodev @@ -13,6 +14,7 @@ mountpoint -q /dev/pts || mount /dev/pts >/dev/null 2>&1 || mount -t devpts devp mountpoint -q /dev/shm || mount /dev/shm >/dev/null 2>&1 || mount -t tmpfs shm /dev/shm -o mode=1777,nosuid,nodev if [ "$(command -v udevd)" ]; then + echo "> Starting udevd daemon..." udevd --daemon udevadm trigger --action=add --type=subsystems udevadm trigger --action=add --type=devices @@ -20,6 +22,7 @@ if [ "$(command -v udevd)" ]; then else # In the case the user may preffer mdevd as opposed to busybox mdev if [ ! -d "/var/service/mdevd" ]; then + echo "> Starting mdev..." echo "/sbin/mdev" > /proc/sys/kernel/hotplug mdev -s fi @@ -30,8 +33,17 @@ else ln -s fd/2 /dev/stderr fi -swapon -a +echo "> Loading kernel modules..." +if [ -f /etc/rc.modules ]; then + while read -r module; do + [ -n "$module" ] && ! echo "$module" | grep -q '^#' && modprobe "$module" + done < /etc/rc.modules +fi + +echo "> Bringing up loopback interface..." ip link set lo up + +echo "> Remounting root as read-only..." mount -o remount,ro / for arg in $(cat /proc/cmdline); do @@ -42,6 +54,7 @@ for arg in $(cat /proc/cmdline); do done if [ ! "$FASTBOOT" ]; then + echo "> Running filesystem check..." fsck $FORCEFSCK -ATat noopts=_netdev if [ "$?" -gt 1 ]; then echo "*******************************************" @@ -52,36 +65,51 @@ if [ ! "$FASTBOOT" ]; then fi fi +echo "> Enabling swap..." +swapon -a + +echo "> Remounting root as read-write..." mount -o remount,rw / + +echo "> Mounting all filesystems..." mount -a if [ ! -f /etc/hostname ]; then - echo alice > /etc/hostname + echo localhost > /etc/hostname fi +echo "> Setting hostname..." hostname -F /etc/hostname +echo "> Cleaning stale PID files and /tmp..." find /var/run -name "*.pid" -delete find /tmp -xdev -mindepth 1 ! -name lost+found -delete if [ -f "/etc/sysctl.conf" ]; then + echo "> Applying sysctl settings..." sysctl -q -p fi -hwclock -s -u +if [ -e /dev/rtc ] || [ -e /dev/rtc0 ]; then + echo "> Restoring hardware clock..." + hwclock -s -u +fi if [ -f "/var/lib/random-seed" ]; then + echo "> Seeding /dev/urandom..." cat /var/lib/random-seed >/dev/urandom rm -f /var/lib/random-seed fi if [ -d /sys/firmware/efi/efivars ]; then + echo "> Mounting efivarfs..." mount -t efivarfs none /sys/firmware/efi/efivars fi dmesg >/var/log/dmesg.log if [ -x /etc/rc.boot.local ]; then - /etc/rc.boot.local + echo "> Running local boot script..." + /etc/rc.boot.local fi IFS=. read -r boottime _ < /proc/uptime diff --git a/repos/core/initscripts/rc.modules b/repos/core/initscripts/rc.modules @@ -0,0 +1,2 @@ +# list kernel modules + diff --git a/repos/core/initscripts/rc.shutdown b/repos/core/initscripts/rc.shutdown @@ -1,27 +1,58 @@ #!/bin/sh -echo "shutting down" +echo "> Shutting down system..." if [ -x /etc/rc.shutdown.local ]; then - /etc/rc.shutdown.local + echo "> Running local shutdown scripts..." + /etc/rc.shutdown.local fi -if [ "$(command -v udevadm)" ]; then - udevadm control --exit +if command -v udevadm >/dev/null 2>&1; then + echo "> Stopping udev..." + udevadm control --exit fi -sv down /var/service/* -dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null -hwclock -w -u -kill -s TERM -1 +echo "> Stopping all services..." +sv force-stop /var/service/* 2>/dev/null + +sleep 1 + +if [ -w /var/lib/random-seed ]; then + echo "> Saving random seed..." + dd if=/dev/urandom of=/var/lib/random-seed count=1 bs=512 2>/dev/null +fi + +if [ -e /dev/rtc ] || [ -e /dev/rtc0 ]; then + echo "> Syncing hardware clock..." + hwclock -w -u 2>/dev/null +fi + +echo "> Terminating processes..." +kill -s TERM -1 2>/dev/null sleep 2 -kill -s KILL -1 -swapoff -a -ip link set lo down -umount -a -r -t noproc -mount -o remount,ro / + +kill -s KILL -1 2>/dev/null +sleep 1 + +echo "> Disabling swap..." +swapoff -a 2>/dev/null + +echo "> Bringing down network..." +ip link set lo down 2>/dev/null + +for iface in $(ip link show | grep '^[0-9]' | awk -F: '{print $2}' | tr -d ' ' | grep -v '^lo$'); do + ip link set "$iface" down 2>/dev/null +done + +echo "> Unmounting filesystems..." +umount -a -r -t noproc 2>/dev/null + +echo "> Remounting root as read-only..." +mount -o remount,ro / 2>/dev/null + +echo "> Syncing filesystems..." sync + sleep 1 -wait -echo bye +echo "> Shutdown complete. Bye!"