rc: 2.32 -> 2.33

This commit is contained in:
Tim Biermann 2024-07-19 21:01:30 +02:00
parent 1fd66c9e55
commit cc07dcce91
Signed by: tb
GPG Key ID: 42F8B4E30B673606
10 changed files with 190 additions and 86 deletions

View File

@ -4,6 +4,7 @@ drwxr-xr-x root/root etc/
-rw-r--r-- root/root etc/rc.conf
drwxr-xr-x root/root etc/rc.d/
-rwxr-xr-x root/root etc/rc.fix
-rwxr-xr-x root/root etc/rc.functions
-rwxr-xr-x root/root etc/rc.local
-rwxr-xr-x root/root etc/rc.modules
-rwxr-xr-x root/root etc/rc.multi

View File

@ -1,13 +1,14 @@
untrusted comment: verify with /etc/ports/core.pub
RWRJc1FUaeVeqs38PmJ6zdDzwtmlgXp9Mri3sIXmTjQ4DH9f0OCjBMNh0LQh0P+Ew4QPYRXad2jcDQ1OBNaA4R2/XB3tBmmWnwQ=
SHA256 (Pkgfile) = b6308712bfd76142197506e2b6b704bdff07324cd6b222c5413d0f3fb1b4c508
SHA256 (.footprint) = 83ecef9b904362368a7a581a43b3ea9b658bdbe8265ffae433068ee5beba15e4
RWRJc1FUaeVeqtyNKaQPdAFB3EiNs8g3ale0j1r7287LM3dr23Rji+DMvLFUDtgOBJ3Ahw/lZzzMsxxIAUFjm+M1azzDL7JO6wU=
SHA256 (Pkgfile) = 38e8a61308d55462acea47cc1088dd2ede3652c24a58394acb7fa297357facb5
SHA256 (.footprint) = 19fc8bf3e0efb55c6556056f3315a002bd44615fa2b465a0ba0da87536c07fbf
SHA256 (inittab) = 7914281a73ee7746c7c16fe63d1631f3714f63467f2655c550c5f8b7c2f1fee7
SHA256 (rc) = 58341d2b8cb66f0a786452f2da472aff8d640f94a09e42ed8f3efd62305fbee5
SHA256 (rc) = 0ed21debe4e7f7dfb392f83d53bc3fd8178523faec55979544851d8a0f502cde
SHA256 (rc.modules) = 74d94558fe68f2a4b7b0f3dc2215c291300bc416d27e6d79d95f303cfc918788
SHA256 (rc.single) = 14a7487258f3b5f2406a860c34666abacf23eb37962d80fce66e496dd111061a
SHA256 (rc.multi) = a8115a0c3ddd98a5ac1f6dc9d1f23e7d1c0d2db65f709f59deadac312ed6a618
SHA256 (rc.single) = ebdc5f7c5329006330df1df24a162ac55bd109d0d98774ecff463153af770ca0
SHA256 (rc.multi) = dd0f790d027c702946da714d6d264fb9a590a634149ef8632822ce8ba3c6d854
SHA256 (rc.local) = e39147ee4d402b2fea96639185d6055b361b1a44090653acf5790b51db6acdd1
SHA256 (rc.fix) = 0d2eef2326f8660e70e047192c82a0cb865bc8c933e12ffe5b817e8cd536f5b0
SHA256 (rc.shutdown) = 284122ae86248cf93e9806b6e1d3ffca9ad2ee3978434581b491e39887b14ec9
SHA256 (rc.conf) = 37c3b0dd2a76fe6fbdec9ec90bfbfa2e8e7db9cece2fceec1f4899aa1e3e14a5
SHA256 (rc.fix) = be4133cd59017158b44e78d7ac53953986d8e9828866d0f7f71564ff71b9b406
SHA256 (rc.functions) = a2a2f82705999b53a0b9a903c7cd2d5d874185d00fb4dc2125172906886d8268
SHA256 (rc.shutdown) = e2c65c427369b10466788d06cfdda35709e0b25d8a0be9f08033a521893607b4
SHA256 (rc.conf) = 6863f0708d70eb4531bb53a5a1adce7dad17e1acf373cc8b42055aa168491ee1

View File

@ -3,22 +3,24 @@
# Maintainer: CRUX System Team, core-ports at crux dot nu
name=rc
version=2.32
release=2
source=(inittab rc rc.modules rc.single rc.multi rc.local rc.fix rc.shutdown rc.conf)
version=2.33
release=1
source=(inittab rc rc.modules rc.single rc.multi rc.local rc.fix
rc.functions rc.shutdown rc.conf)
build() {
install -d $PKG/etc/rc.d
install -m 644 inittab $PKG/etc
install -m 755 rc $PKG/etc
install -m 755 rc.modules $PKG/etc
install -m 755 rc.single $PKG/etc
install -m 755 rc.multi $PKG/etc
install -m 755 rc.local $PKG/etc
install -m 755 rc.fix $PKG/etc
install -m 755 rc.shutdown $PKG/etc
install -m 644 rc.conf $PKG/etc
install -d $PKG/var/log $PKG/var/lib/urandom
touch $PKG/var/log/boot $PKG/var/lib/urandom/seed
chmod 640 $PKG/var/log/boot $PKG/var/lib/urandom/seed
install -d $PKG/etc/rc.d
install -m 644 inittab $PKG/etc
install -m 755 rc $PKG/etc
install -m 755 rc.modules $PKG/etc
install -m 755 rc.single $PKG/etc
install -m 755 rc.multi $PKG/etc
install -m 755 rc.local $PKG/etc
install -m 755 rc.fix $PKG/etc
install -m 755 rc.shutdown $PKG/etc
install -m 755 rc.functions $PKG/etc
install -m 644 rc.conf $PKG/etc
install -d $PKG/var/log $PKG/var/lib/urandom
touch $PKG/var/log/boot $PKG/var/lib/urandom/seed
chmod 640 $PKG/var/log/boot $PKG/var/lib/urandom/seed
}

132
rc/rc
View File

@ -3,45 +3,90 @@
# /etc/rc: system boot script
#
echo "The system is coming up. Please wait."
printf "%s\n" "The system is coming up. Please wait."
# Load configuration
. /etc/rc.conf
# Load functions
. /etc/rc.functions
# Start udev
/bin/mount -t proc none /proc
/bin/mount -t sysfs none /sys
/sbin/start_udev
# Setup a working environment with eudev
# - if /dev is not mounted - mount as a devtmpfs (CONFIG_DEVTMPFS=y)
# - if /dev is mounted (e.g. due to handover from initramfs or
# CONFIG_DEVTMPFS_MOUNT=y), remount with specific options
# - some video drivers require exec access in /dev, thus it's set here
# - for completness, we add few sanity limits (2k non-empty files, 16k inodes)
printinfo "\nMounting /proc.."
if ! /bin/mountpoint -q /proc; then
/bin/mount -t proc none /proc || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
fi
printinfo "\nMounting /sys.."
if ! /bin/mountpoint -q /sys; then
/bin/mount -t sysfs none /sys || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
fi
printinfo "\nMounting /run.."
if ! /bin/mountpoint -q /run ; then
/bin/mount -n -t tmpfs -o mode="0755,nosuid,nodev,exec" tmpfs /run || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
fi
printinfo "\nMounting /dev.."
UDEVOPTS="exec,nosuid,noatime,mode=0755,nr_blocks=2048,nr_inodes=16384"
if ! /bin/mountpoint -q /dev; then
/bin/mount -n -t devtmpfs -o ${UDEVOPTS} dev /dev || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
else
/bin/mount -n -o remount,${UDEVOPTS} dev /dev || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
fi
printinfo "\nMounting /dev/pts.."
if ! /bin/mountpoint -q /dev/pts; then
/bin/mkdir -m 755 /dev/pts
/bin/mount -t devpts -o noexec,nosuid,gid=tty,mode=0620 devpts /dev/pts || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
fi
printinfo "\nMounting /dev/shm.."
if ! /bin/mountpoint -q /dev/shm; then
/bin/mkdir -m 1777 /dev/shm
/bin/mount shm -t tmpfs -o defaults,exec,rw /dev/shm || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
fi
printinfo "\nStarting udev.."
/sbin/start_udev || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
# 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
printinfo "Found lvm, creating device nodes and lvm volumes"
/sbin/vgscan --mknodes --ignorelockingfailure || printf "$(BOLD "$(RED)")" "[ERROR]"
/sbin/vgchange --sysinit -a y || printf "$(BOLD "$(RED)")" "[ERROR]"
fi
# Mount root read-only
/bin/mount -o remount,ro /
printinfo "\nMounting / in read-only mode.."
/bin/mount -o remount,ro / || { printf "$(BOLD "$(RED)")" "[ERROR]"; exit 1; }
if [ -f /forcefsck ]; then
FORCEFSCK="-f"
printinfo "\n/forcefsck detected, setting force flag to fsck"
FORCEFSCK="-f"
fi
# Check filesystems
printinfo "\nChecking filesystems.."
/sbin/fsck $FORCEFSCK -A -T -C -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
printf "\n%s$(BOLD "$(RED)")%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n" \
"***************" " FILESYSTEM CHECK FAILED " "******************" \
"* *" \
"* Please repair manually and reboot. Note that the root *" \
"* file system is currently mounted read-only. To remount *" \
"* it read-write type: mount -n -o remount,rw / *" \
"* When you exit the maintenance shell the system will *" \
"* reboot automatically. *" \
"* *" \
"************************************************************"
/sbin/sulogin -p
echo "Automatic reboot in progress..."
printf "%s\n" "Automatic reboot in progress..."
/bin/umount -a -r
/bin/mount -o remount,ro /
/sbin/reboot -f
@ -49,31 +94,39 @@ if [ $? -gt 1 ]; then
fi
# Mount local filesystems
/bin/mount -o remount,rw /
/bin/mount -a -O no_netdev
printinfo "\nMounting / in read-write mode.."
/bin/mount -o remount,rw / || printf "$(BOLD "$(RED)")" "[ERROR]"
printinfo "\nMounting other filesystems (excl. network devices)..\t"
/bin/mount -a -O no_netdev || printf "$(BOLD "$(RED)")" "[ERROR]"
# Create user dir in /run
/bin/mkdir -m 0755 /run/user
printinfo "\nCreating /run/user.."
/bin/mkdir -m 0755 /run/user || printf "$(BOLD "$(RED)")" "[ERROR]"
# Activate swap
/sbin/swapon -a
printinfo "\nMounting swap.."
/sbin/swapon -a || printf "$(BOLD "$(RED)")" "[ERROR]"
# Clean up misc files
: > /run/utmp
/bin/rm -rf /forcefsck /fastboot /etc/nologin /etc/shutdownpid
(cd /var/lock && /usr/bin/find . ! -type d -delete)
(cd /tmp && /usr/bin/find . ! -name . -delete)
/bin/mkdir -m 1777 /tmp/.ICE-unix /tmp/.X11-unix
printinfo "\nDeleting temporary files.."
: > /run/utmp || printf "$(BOLD "$(RED)")" "[ERROR]"
/bin/rm -rf /forcefsck /fastboot /etc/nologin /etc/shutdownpid || printf "$(BOLD "$(RED)")" "[ERROR]"
(cd /var/lock && /usr/bin/find . ! -type d -delete) || printf "$(BOLD "$(RED)")" "[ERROR]"
(cd /tmp && /usr/bin/find . ! -name . -delete) || printf "$(BOLD "$(RED)")" "[ERROR]"
/bin/mkdir -m 1777 /tmp/.ICE-unix /tmp/.X11-unix || printf "$(BOLD "$(RED)")" "[ERROR]"
# Set kernel variables
/sbin/sysctl -p > /dev/null
printinfo "\nSetting kernel variables.."
/sbin/sysctl -p > /dev/null || printf "$(BOLD "$(RED)")" "[ERROR]"
# Update shared library links
/sbin/ldconfig
printinfo "\nUpdating shared library links.."
/sbin/ldconfig || printf "$(BOLD "$(RED)")" "[ERROR]"
# Configure host name
if [ "$HOSTNAME" ]; then
echo "hostname: $HOSTNAME"
printf "\n$(BOLD "%s") %s\n" "Hostname:" "$HOSTNAME"
/bin/hostname "$HOSTNAME"
fi
@ -86,20 +139,25 @@ if [ "$TIMEZONE" ]; then
fi
/sbin/hwclock --hctosys
# Default language
printf "$(BOLD "%s") %s\n" "LANG:" "${LANG:-C.UTF-8}"
export LANG
# Load console font
if [ "$FONT" ]; then
echo "font: $FONT"
printf "$(BOLD "%s") %s\n" "Font:" "$FONT"
/usr/bin/setfont "$FONT"
fi
# Load console keymap
if [ "$KEYMAP" ]; then
echo "keyboard: $KEYMAP"
printf "$(BOLD "%s") %s\n" "Keyboard:" "$KEYMAP"
/usr/bin/loadkeys -q "$KEYMAP"
fi
# Screen blanks after 15 minutes idle time
/usr/bin/setterm -blank 15
# Screen timeout, defaults to 15m
printf "$(BOLD "%s") %s\n" "Screen Timeout:" "${BLANKTIME:-15}"
/usr/bin/setterm -blank "${BLANKTIME:-15}"
# Run module initialization script
if [ -x /etc/rc.modules ]; then

View File

@ -2,11 +2,14 @@
# /etc/rc.conf: system configuration
#
FONT=default
KEYMAP=us
TIMEZONE=UTC
BLANKTIME=15
HOSTNAME=host
KEYMAP=us
LANG=C.UTF-8
SYSLOG=sysklogd
TIMEZONE=UTC
USE_COLOR=false
VERBOSE=false
SERVICES=(lo net crond)
# End of file

View File

@ -7,15 +7,15 @@
# X11 font-related checks
#######################################################################
if [ -d /usr/share/fonts/X11 ]; then
for i in `/bin/ls -d /usr/share/fonts/X11/*`; do
if [ ! -f $i/fonts.dir ]; then
mkfontdir $i &> /dev/null
mkfontscale $i &> /dev/null
for i in $(/bin/ls -d /usr/share/fonts/X11/*); do
if [ ! -f "$i/fonts.dir" ]; then
mkfontdir "$i" &> /dev/null
mkfontscale "$i" &> /dev/null
fi
done
fi
if [ -d /var/cache/fontconfig ] && [ -z "`/bin/ls /var/cache/fontconfig/`" ]; then
if [ -d /var/cache/fontconfig ] && [ -z "$(/bin/ls /var/cache/fontconfig/)" ]; then
fc-cache --system-only &> /dev/null
fi

30
rc/rc.functions Normal file
View File

@ -0,0 +1,30 @@
#!/bin/bash
#
# /etc/rc.functions: functions to be used by the system boot script
#
RED() {
case $USE_COLOR in
true) printf '\033[31m%s\033[0m' "$1";;
false) printf '%s' "$1";;
*) printf '%s' "$1";;
esac
}
GREEN() {
case $USE_COLOR in
true) printf '\033[32m%s\033[0m' "$1";;
false) printf '%s' "$1";;
*) printf '%s' "$1";;
esac
}
BOLD() {
printf '\033[1m%s\033[0m' "$1"
}
printinfo() {
if [ "$VERBOSE" = true ]; then
printf '%b' "$1"
fi
}

View File

@ -5,6 +5,8 @@
# Load configuration
. /etc/rc.conf
# Load functions
. /etc/rc.functions
# Run fixes startup file
if [ -x /etc/rc.fix ]; then
@ -12,19 +14,19 @@ if [ -x /etc/rc.fix ]; then
fi
# Start services
if [ "$SYSLOG" -o "${SERVICES[*]}" ]; then
echo -n "starting services:"
if [ -f /etc/rc.d/$SYSLOG -a -x /etc/rc.d/$SYSLOG ]; then
echo -n " $SYSLOG"
/etc/rc.d/$SYSLOG start &> /dev/null || echo -n "[ERROR]"
if [ "$SYSLOG" ] || [ "${SERVICES[*]}" ]; then
printf "$(BOLD "Starting services:")"
if [ -f /etc/rc.d/$SYSLOG ] && [ -x /etc/rc.d/$SYSLOG ]; then
printf " %s" "$SYSLOG"
/etc/rc.d/$SYSLOG start &> /dev/null || printf "$(BOLD "$(RED "[ERROR]")")"
fi
for service in ${SERVICES[@]}; do
echo -n " $service"
/etc/rc.d/"$service" start &> /tmp/rc.$$ || echo -n "[ERROR]"
for service in "${SERVICES[@]}"; do
printf " %s" "$service"
/etc/rc.d/"$service" start &> /tmp/rc.$$ || printf "$(BOLD "$(RED "[ERROR]")")"
/usr/bin/logger -t "$service" -f /tmp/rc.$$
/bin/rm -f /tmp/rc.$$
done
echo
printf "\n"
fi
# Run local startup script

View File

@ -5,24 +5,29 @@
# Load configuration
. /etc/rc.conf
# Load functions
. /etc/rc.functions
# Set linefeed mode to avoid staircase effect
/bin/stty onlcr
echo "The system is coming down. Please wait."
printf "\n%s\n" "The system is coming down. Please wait."
if [ "$PREVLEVEL" = "2" ]; then
# Shutdown services
printf "$(BOLD "Stopping services:")"
if [ "${SERVICES[*]}" ]; then
for service in "${SERVICES[@]}"; do
R_SERVICES=($service ${R_SERVICES[@]})
R_SERVICES=("$service" "${R_SERVICES[@]}")
done
for service in "${R_SERVICES[@]}"; do
/etc/rc.d/$service stop &> /tmp/rc.$$
printf " %s" "$service"
/etc/rc.d/$service stop &> /tmp/rc.$$ || printf "$(BOLD "$(RED "[ERROR]")")"
/usr/bin/logger -t $service -f /tmp/rc.$$
/bin/rm -f /tmp/rc.$$
done
fi
printf '\n'
fi
# Terminate all processes

View File

@ -5,16 +5,18 @@
# Load configuration
. /etc/rc.conf
# Load functions
. /etc/rc.functions
if [ "$PREVLEVEL" = "2" ]; then
# Shutdown services
if [ "${SERVICES[*]}" ]; then
for service in "${SERVICES[@]}"; do
R_SERVICES=($service ${R_SERVICES[@]})
R_SERVICES=("$service ${R_SERVICES[@]}")
done
for service in "${R_SERVICES[@]}"; do
/etc/rc.d/$service stop &> /tmp/rc.$$
/usr/bin/logger -t $service -f /tmp/rc.$$
/etc/rc.d/"$service" stop &> /tmp/rc.$$
/usr/bin/logger -t "$service" -f /tmp/rc.$$
/bin/rm -f /tmp/rc.$$
done
fi
@ -36,7 +38,7 @@ if [ "$PREVLEVEL" != "N" ]; then
# Start udev
/sbin/start_udev
if [ -f /etc/rc.d/$SYSLOG -a -x /etc/rc.d/$SYSLOG ]; then
if [ -f /etc/rc.d/$SYSLOG ] && [ -x /etc/rc.d/$SYSLOG ]; then
/etc/rc.d/$SYSLOG start &> /dev/null
fi
fi