Initial commit.
This is basically a fork of CRUX’s rc. All files added in this commit and not rewritten since are to be considered under GPL. Please look at CRUX’s core ports repository’s license file for the exact terms of the license.master
commit
579e431144
|
@ -0,0 +1,31 @@
|
||||||
|
#
|
||||||
|
# /etc/inittab: system runlevel description
|
||||||
|
#
|
||||||
|
|
||||||
|
# Runlevels:
|
||||||
|
# 0 Halt
|
||||||
|
# 1(S) Single-user
|
||||||
|
# 2 Multi-user
|
||||||
|
# 3-5 Not used
|
||||||
|
# 6 Reboot
|
||||||
|
|
||||||
|
id:2:initdefault:
|
||||||
|
|
||||||
|
rc::sysinit:/etc/rc
|
||||||
|
rs:S1:wait:/etc/rc.single
|
||||||
|
rm:2:wait:/etc/rc.multi
|
||||||
|
rd:06:wait:/etc/rc.shutdown
|
||||||
|
su:S:wait:/sbin/sulogin -p
|
||||||
|
|
||||||
|
c1:2:respawn:/sbin/getty 38400 tty1 linux
|
||||||
|
c2:2:respawn:/sbin/getty 38400 tty2 linux
|
||||||
|
c3:2:respawn:/sbin/getty 38400 tty3 linux
|
||||||
|
c4:2:respawn:/sbin/getty 38400 tty4 linux
|
||||||
|
c5:2:respawn:/sbin/getty 38400 tty5 linux
|
||||||
|
c6:2:respawn:/sbin/getty 38400 tty6 linux
|
||||||
|
s1:2:respawn:/sbin/getty 38400 ttyS0 vt100
|
||||||
|
|
||||||
|
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
|
||||||
|
pf::powerfail:/sbin/shutdown -t3 -h now
|
||||||
|
|
||||||
|
# End of file
|
|
@ -0,0 +1,123 @@
|
||||||
|
#!/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
|
|
@ -0,0 +1,12 @@
|
||||||
|
#
|
||||||
|
# /etc/rc.conf: system configuration
|
||||||
|
#
|
||||||
|
|
||||||
|
FONT=default
|
||||||
|
KEYMAP=us
|
||||||
|
TIMEZONE=UTC
|
||||||
|
HOSTNAME=host
|
||||||
|
SYSLOG=sysklogd
|
||||||
|
SERVICES=(lo crond)
|
||||||
|
|
||||||
|
# End of file
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /etc/rc.fix: adjustements startup file (multi-user)
|
||||||
|
#
|
||||||
|
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# 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
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d /var/cache/fontconfig ] && [ -z "`/bin/ls /var/cache/fontconfig/`" ]; then
|
||||||
|
fc-cache --system-only &> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# End of file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /etc/rc.local: local multi-user startup script
|
||||||
|
#
|
||||||
|
|
||||||
|
# End of file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /etc/rc.modules: module initialization script
|
||||||
|
#
|
||||||
|
|
||||||
|
/sbin/depmod -a
|
||||||
|
|
||||||
|
# End of file
|
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /etc/rc.multi: multi-user startup script
|
||||||
|
#
|
||||||
|
|
||||||
|
# Load configuration
|
||||||
|
. /etc/rc.conf
|
||||||
|
|
||||||
|
# Run fixes startup file
|
||||||
|
if [ -x /etc/rc.fix ]; then
|
||||||
|
/etc/rc.fix
|
||||||
|
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]"
|
||||||
|
fi
|
||||||
|
for service in ${SERVICES[@]}; do
|
||||||
|
echo -n " $service"
|
||||||
|
/etc/rc.d/$service start &> /tmp/rc.$$ || echo -n "[ERROR]"
|
||||||
|
/usr/bin/logger -t $service < /tmp/rc.$$
|
||||||
|
/bin/rm -f /tmp/rc.$$
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run local startup script
|
||||||
|
if [ -x /etc/rc.local ]; then
|
||||||
|
/etc/rc.local
|
||||||
|
fi
|
||||||
|
|
||||||
|
# End of file
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /etc/rc.shutdown: system shutdown script
|
||||||
|
#
|
||||||
|
|
||||||
|
# Load configuration
|
||||||
|
. /etc/rc.conf
|
||||||
|
|
||||||
|
# Set linefeed mode to avoid staircase effect
|
||||||
|
/bin/stty onlcr
|
||||||
|
|
||||||
|
echo "The system is coming down. Please wait."
|
||||||
|
|
||||||
|
if [ "$PREVLEVEL" = "2" ]; then
|
||||||
|
# Shutdown services
|
||||||
|
if [ "${SERVICES[*]}" ]; then
|
||||||
|
for service in "${SERVICES[@]}"; do
|
||||||
|
R_SERVICES=($service ${R_SERVICES[@]})
|
||||||
|
done
|
||||||
|
for service in "${R_SERVICES[@]}"; do
|
||||||
|
/etc/rc.d/$service stop &> /tmp/rc.$$
|
||||||
|
/usr/bin/logger -t $service < /tmp/rc.$$
|
||||||
|
/bin/rm -f /tmp/rc.$$
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Terminate all processes
|
||||||
|
/sbin/killall5 -15
|
||||||
|
/bin/sleep 5
|
||||||
|
/sbin/killall5 -9
|
||||||
|
|
||||||
|
# Save random seed
|
||||||
|
/bin/dd if=/dev/urandom of=/var/lib/urandom/seed count=1 2> /dev/null
|
||||||
|
|
||||||
|
# Save system clock
|
||||||
|
/sbin/hwclock --systohc
|
||||||
|
|
||||||
|
# Write to wtmp file before unmounting
|
||||||
|
/sbin/halt -w
|
||||||
|
|
||||||
|
# Turn off swap
|
||||||
|
/sbin/swapoff -a
|
||||||
|
|
||||||
|
# Unmount file systems
|
||||||
|
/bin/umount -a -d -r -t nosysfs,noproc,nodevtmpfs
|
||||||
|
if [ -x /sbin/lvm ]; then
|
||||||
|
/sbin/vgchange --ignorelockingfailure -a n
|
||||||
|
fi
|
||||||
|
/bin/umount -a -r
|
||||||
|
|
||||||
|
# Remount root filesystem read-only
|
||||||
|
/bin/mount -o remount,ro /
|
||||||
|
|
||||||
|
# Power off or reboot
|
||||||
|
if [ "$RUNLEVEL" = "0" ]; then
|
||||||
|
/sbin/poweroff -d -f -i
|
||||||
|
else
|
||||||
|
/sbin/reboot -d -f -i
|
||||||
|
fi
|
||||||
|
|
||||||
|
# End of file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /etc/rc.single: single-user startup script
|
||||||
|
#
|
||||||
|
|
||||||
|
# Load configuration
|
||||||
|
. /etc/rc.conf
|
||||||
|
|
||||||
|
if [ "$PREVLEVEL" = "2" ]; then
|
||||||
|
# Shutdown services
|
||||||
|
if [ "${SERVICES[*]}" ]; then
|
||||||
|
for service in "${SERVICES[@]}"; do
|
||||||
|
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.$$
|
||||||
|
/bin/rm -f /tmp/rc.$$
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$PREVLEVEL" != "N" ]; then
|
||||||
|
# Terminate all processes
|
||||||
|
/sbin/killall5 -15
|
||||||
|
/bin/sleep 5
|
||||||
|
/sbin/killall5 -9
|
||||||
|
|
||||||
|
if ! /bin/mountpoint -q /proc ; then
|
||||||
|
/bin/mount -n -t proc none /proc
|
||||||
|
fi
|
||||||
|
if ! /bin/mountpoint -q /sys ; then
|
||||||
|
/bin/mount -n -t sysfs none /sys
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Start udev
|
||||||
|
/sbin/start_udev
|
||||||
|
|
||||||
|
if [ -f /etc/rc.d/$SYSLOG -a -x /etc/rc.d/$SYSLOG ]; then
|
||||||
|
/etc/rc.d/$SYSLOG start &> /dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$RUNLEVEL" = "1" ]; then
|
||||||
|
# Enter single-user mode
|
||||||
|
exec /sbin/init -t1 S
|
||||||
|
fi
|
||||||
|
|
||||||
|
# End of file
|
Loading…
Reference in New Issue