diff options
-rw-r--r-- | filelist | 11 | ||||
-rw-r--r-- | functions | 45 | ||||
-rw-r--r-- | inittab | 29 | ||||
-rw-r--r-- | rc.conf | 33 | ||||
-rwxr-xr-x | rc.local | 6 | ||||
-rwxr-xr-x | rc.multi | 26 | ||||
-rw-r--r-- | rc.proto | 33 | ||||
-rwxr-xr-x | rc.shutdown | 78 | ||||
-rwxr-xr-x | rc.single | 44 | ||||
-rwxr-xr-x | rc.sysinit | 108 |
10 files changed, 413 insertions, 0 deletions
diff --git a/filelist b/filelist new file mode 100644 index 0000000..8e6572c --- /dev/null +++ b/filelist @@ -0,0 +1,11 @@ +.PKGINFO +etc/ +etc/rc.d/ +etc/rc.d/functions +etc/inittab +etc/rc.conf +etc/rc.local +etc/rc.multi +etc/rc.shutdown +etc/rc.single +etc/rc.sysinit diff --git a/functions b/functions new file mode 100644 index 0000000..2923928 --- /dev/null +++ b/functions @@ -0,0 +1,45 @@ +# +# functions +# + +STAT_COL=68 + +deltext() { + echo -ne "\033[$(($STAT_COL+4))G" +} + +stat_busy() { + echo -n "[ $1 " + awk "BEGIN { for (j=length(\"$1\"); j<$STAT_COL; j++) printf \" \" }" + echo -n " BUSY ]" +} + +stat_done() { + deltext + echo " DONE ]" +} + +stat_fail() { + deltext + echo " FAILED ]" +} + +checkret() { + $* >/dev/null 2>&1 + if [ $? -gt 0 ]; then + stat_fail + else + stat_done + fi +} + +add_daemon() { + [ -d /var/run/daemons ] || mkdir -p /var/run/daemons + touch /var/run/daemons/$1 +} + +rm_daemon() { + rm -f /var/run/daemons/$1 +} + +# End of file @@ -0,0 +1,29 @@ +# +# /etc/inittab +# + +# Runlevels: +# 0 Halt +# 1(S) Single-user +# 2 Multi-user +# 3-5 Not used +# 6 Reboot + +id:2:initdefault: + +rc::sysinit:/etc/rc.sysinit +rs:S1:wait:/etc/rc.single +rm:2:wait:/etc/rc.multi +rh:06:wait:/etc/rc.shutdown +su:S:wait:/sbin/sulogin -p + +c1:2:respawn:/sbin/agetty 38400 vc/1 linux +c2:2:respawn:/sbin/agetty 38400 vc/2 linux +c3:2:respawn:/sbin/agetty 38400 vc/3 linux +c4:2:respawn:/sbin/agetty 38400 vc/4 linux +c5:2:respawn:/sbin/agetty 38400 vc/5 linux +c6:2:respawn:/sbin/agetty 38400 vc/6 linux + +ca::ctrlaltdel:/sbin/shutdown -t3 -r now + +# End of file @@ -0,0 +1,33 @@ +# +# /etc/rc.conf +# + +# +# Localization +# +KEYMAP=us +TIMEZONE=Canada/Pacific + +# +# Networking +# +HOSTNAME=myhost + +# +# Daemons to start at boot-up +# +DAEMONS=() + +# +# PCMCIA +# +# Set to "yes" to use PCMCIA Services +PCMCIA=no +# Should be either i82365 or tcic +PCIC=i82365 +PCIC_OPTS= +CORE_OPTS= +CARDMGR_OPTS= +SCHEME= + +# End of file diff --git a/rc.local b/rc.local new file mode 100755 index 0000000..b8e8ef5 --- /dev/null +++ b/rc.local @@ -0,0 +1,6 @@ +#!/bin/sh +# +# /etc/rc.local: Local multi-user startup script. +# + +# End of file diff --git a/rc.multi b/rc.multi new file mode 100755 index 0000000..c3c48d8 --- /dev/null +++ b/rc.multi @@ -0,0 +1,26 @@ +#!/bin/sh +# +# /etc/rc.multi +# + +. /etc/rc.conf +. /etc/rc.d/functions + +# Start pcmcia +if [ "$PCMCIA" = "yes" -a -f /etc/rc.d/pcmcia ]; then + /etc/rc.d/pcmcia start +fi + +stat_busy "Starting Network" +stat_done + +# Start daemons +for daemon in "${DAEMONS[@]}"; do + /etc/rc.d/$daemon start +done + +if [ -x /etc/rc.local ]; then + /etc/rc.local +fi + +# End of file diff --git a/rc.proto b/rc.proto new file mode 100644 index 0000000..3bf45e3 --- /dev/null +++ b/rc.proto @@ -0,0 +1,33 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions + +case "$1" in + start) + stat_busy "Starting Daemon" + /usr/sbin/daemon + if [ $? -gt 0 ]; then + stat_fail + else + add_daemon daemon + stat_done + fi + ;; + stop) + stat_busy "Stopping Daemon" + killall -q daemon + if [ $? -gt 0 ]; then + stat_fail + else + rm_daemon daemon + stat_done + fi + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "usage: $0 {start|stop|restart}" +esac diff --git a/rc.shutdown b/rc.shutdown new file mode 100755 index 0000000..01f12d2 --- /dev/null +++ b/rc.shutdown @@ -0,0 +1,78 @@ +#!/bin/sh +# +# /etc/rc.shutdown +# + +. /etc/rc.conf +. /etc/rc.d/functions + +# avoid staircase effect +/bin/stty onlcr + +echo -n "[ Shutting Down " +echo " ]" + +if [ "$PREVLEVEL" = "2" ]; then + # Shutdown daemons + if [ -d /var/run/daemons ]; then + for daemon in `ls /var/run/daemons`; do + /etc/rc.d/$daemon stop + done + fi + + # Shutdown network + stat_busy "Shutting Down Network" + stat_done + + # Shutdown pcmcia + if [ "$PCMCIA" = "yes" -a -f /etc/rc.d/pcmcia ]; then + /etc/rc.d/pcmcia stop + fi +fi + +# Terminate all processes +stat_busy "Sending SIGTERM To Processes" +/sbin/killall5 -15 &> /dev/null +/usr/bin/sleep 5 +stat_done + +stat_busy "Sending SIGKILL To Processes" +/sbin/killall5 -9 &> /dev/null +stat_done + +stat_busy "Saving Random Seed" +/bin/dd if=/dev/urandom of=/var/run/random-seed count=1 bs=512 2> /dev/null +stat_done + +stat_busy "Saving System Clock" +/sbin/hwclock --systohc +stat_done + +# Write to wtmp file before unmounting +/sbin/halt -w + +stat_busy "Deactivating Swap" +/sbin/swapoff -a +stat_done + +stat_busy "Unmounting Filesystems" +/bin/umount -a +stat_done + +stat_busy "Remounting Root Filesystem Read-only" +/bin/mount -n -o remount,ro / +stat_done +echo "" + +# Power off or reboot +if [ "$RUNLEVEL" = "0" ]; then + echo -n "[ POWER OFF " + echo " ]" + /sbin/poweroff -d -f -i +else + echo -n "[ REBOOTING " + echo " ]" + /sbin/reboot -d -f -i +fi + +# End of file diff --git a/rc.single b/rc.single new file mode 100755 index 0000000..fab12ff --- /dev/null +++ b/rc.single @@ -0,0 +1,44 @@ +#!/bin/sh +# +# /etc/rc.single +# + +. /etc/rc.conf +. /etc/rc.d/functions + +if [ "$PREVLEVEL" = "2" ]; then + # Shutdown daemons + stat_busy "Shutting Down Daemons" + stat_done + + # Shutdown network + stat_busy "Shutting Down Network" + stat_done +fi + +if [ "$PREVLEVEL" != "N" ]; then + stat_busy "Sending SIGTERM To Processes" + /sbin/killall5 -15 &> /dev/null + /usr/bin/sleep 5 + stat_done + + stat_busy "Sending SIGKILL To Processes" + /sbin/killall5 -9 &> /dev/null + stat_done + + stat_busy "Starting DevFS Daemon" + /sbin/devfsd /dev + stat_done + + stat_busy "Starting Log Daemons" + /usr/sbin/syslogd -m 0 + /usr/sbin/klogd -c 4 + stat_done +fi + +if [ "$RUNLEVEL" = "1" ]; then + echo "Entering single-user mode..." + exec /sbin/init -t1 S +fi + +# End of file diff --git a/rc.sysinit b/rc.sysinit new file mode 100755 index 0000000..286e1d9 --- /dev/null +++ b/rc.sysinit @@ -0,0 +1,108 @@ +#!/bin/sh +# +# /etc/rc.sysinit +# + +echo -n "[ " +echo " ]" +echo -n "[ Booting Proto Linux 0.1" +echo " ]" +echo -n "[ " +echo " ]" + +. /etc/rc.conf +. /etc/rc.d/functions + +stat_busy "Starting DevFS Daemon" +checkret /sbin/devfsd /dev + +stat_busy "Activating Swap" +checkret /sbin/swapon -a + +stat_busy "Mounting Root Read-only" +checkret /bin/mount -n -o remount,ro / + +stat_busy "Checking Filesystems" +/sbin/fsck -A -T -C -a +if [ $? -gt 1 ]; then + stat_fail + 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 + /bin/mount -n -o remount,ro / + /sbin/reboot -f + exit 0 +fi +stat_done + +stat_busy "Mounting Local Filesystems" +/bin/mount -n -o remount,rw / +/bin/rm -f /etc/mtab* +/bin/mount -a -t nonfs +stat_done + +stat_busy "Removing Leftover Files" +/bin/rm -f /etc/nologin &> /dev/null +/bin/rm -f /etc/shutdownpid &> /dev/null +/bin/rm -f /var/locks/* &> /dev/null +/bin/rm -f /var/run/*.pid &> /dev/null +/bin/rm -rf /tmp/* /tmp/.* &> /dev/null +: > /var/run/utmp +stat_done + +stat_busy "Updating Shared Library Links" +/sbin/ldconfig +stat_done + +if [ "$HOSTNAME" != "" ]; then + stat_busy "Setting Hostname: $HOSTNAME" + /bin/hostname $HOSTNAME + stat_done +fi + +stat_busy "Starting System Logger" +checkret /usr/sbin/syslogd -m 0 + +stat_busy "Starting Kernel Logger" +checkret /usr/sbin/klogd -c 4 + +stat_busy "Updating Module Dependencies" +checkret /sbin/depmod -a + +stat_busy "Initializing Random Seed" +if [ -f /var/run/random-seed ]; then + /bin/cat /var/run/random-seed > /dev/urandom +fi +stat_done + +stat_busy "Configuring System Clock" +if [ ! -f /etc/adjtime ]; then + echo "0.0 0 0.0" > /etc/adjtime +fi +if [ "$TIMEZONE" != "" ]; then + /bin/ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime +fi +/sbin/hwclock --hctosys +stat_done + +if [ "$KEYMAP" != "" ]; then + stat_busy "Loading Keyboard Map: $KEYMAP" + /bin/loadkeys -q $KEYMAP + stat_done +fi + +# Screen blanks after 15 minutes idle time +/usr/bin/setterm -blank 15 + +# End of file |