diff options
Diffstat (limited to 'source/a/sysvinit-scripts/scripts')
-rw-r--r-- | source/a/sysvinit-scripts/scripts/fetch-rescan-scsi-bus.sh | 1 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/inittab | 74 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.4 | 48 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.6 | 266 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.K | 106 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.M | 355 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.S | 382 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.local | 9 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.sysvinit | 58 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rescan-scsi-bus.sh | 558 |
10 files changed, 1857 insertions, 0 deletions
diff --git a/source/a/sysvinit-scripts/scripts/fetch-rescan-scsi-bus.sh b/source/a/sysvinit-scripts/scripts/fetch-rescan-scsi-bus.sh new file mode 100644 index 00000000..29dccf78 --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/fetch-rescan-scsi-bus.sh @@ -0,0 +1 @@ +lftpget http://www.garloff.de/kurt/linux/rescan-scsi-bus.sh diff --git a/source/a/sysvinit-scripts/scripts/inittab b/source/a/sysvinit-scripts/scripts/inittab new file mode 100644 index 00000000..862f704c --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/inittab @@ -0,0 +1,74 @@ +# +# inittab This file describes how the INIT process should set up +# the system in a certain run-level. +# +# Version: @(#)inittab 2.04 17/05/93 MvS +# 2.10 02/10/95 PV +# 3.00 02/06/1999 PV +# 4.00 04/10/2002 PV +# +# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org> +# Modified by: Patrick J. Volkerding, <volkerdi@slackware.com> +# + +# These are the default runlevels in Slackware: +# 0 = halt +# 1 = single user mode +# 2 = unused (but configured the same as runlevel 3) +# 3 = multiuser mode (default Slackware runlevel) +# 4 = X11 with KDM/GDM/XDM (session managers) +# 5 = unused (but configured the same as runlevel 3) +# 6 = reboot + +# Default runlevel. (Do not set to 0 or 6) +id:3:initdefault: + +# System initialization (runs when system boots). +si:S:sysinit:/etc/rc.d/rc.S + +# Script to run when going single user (runlevel 1). +su:1S:wait:/etc/rc.d/rc.K + +# Script to run when going multi user. +rc:2345:wait:/etc/rc.d/rc.M + +# What to do at the "Three Finger Salute". +ca::ctrlaltdel:/sbin/shutdown -t5 -r now + +# Runlevel 0 halts the system. +l0:0:wait:/etc/rc.d/rc.0 + +# Runlevel 6 reboots the system. +l6:6:wait:/etc/rc.d/rc.6 + +# What to do when power fails. +pf::powerfail:/sbin/genpowerfail start + +# If power is back, cancel the running shutdown. +pg::powerokwait:/sbin/genpowerfail stop + +# These are the standard console login getties in multiuser mode: +c1:1235:respawn:/sbin/agetty 38400 tty1 linux +c2:1235:respawn:/sbin/agetty 38400 tty2 linux +c3:1235:respawn:/sbin/agetty 38400 tty3 linux +c4:1235:respawn:/sbin/agetty 38400 tty4 linux +c5:1235:respawn:/sbin/agetty 38400 tty5 linux +c6:12345:respawn:/sbin/agetty 38400 tty6 linux + +# Local serial lines: +#s1:12345:respawn:/sbin/agetty -L ttyS0 9600 vt100 +#s2:12345:respawn:/sbin/agetty -L ttyS1 9600 vt100 + +# Dialup lines: +#d1:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS0 vt100 +#d2:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS1 vt100 + +# Runlevel 4 used to be for an X window only system, until we discovered +# that it throws init into a loop that keeps your load avg at least 1 all +# the time. Thus, there is now one getty opened on tty6. Hopefully no one +# will notice. ;^) +# It might not be bad to have one text console anyway, in case something +# happens to X. +x1:4:respawn:/etc/rc.d/rc.4 + +# End of /etc/inittab diff --git a/source/a/sysvinit-scripts/scripts/rc.4 b/source/a/sysvinit-scripts/scripts/rc.4 new file mode 100644 index 00000000..be8a9c74 --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/rc.4 @@ -0,0 +1,48 @@ +#! /bin/sh +# +# rc.4 This file is executed by init(8) when the system is being +# initialized for run level 4 (XDM) +# +# Version: @(#)/etc/rc.d/rc.4 2.00 02/17/93 +# +# Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> +# At least 47% rewritten by: Patrick J. Volkerding <volkerdi@slackware.com> +# + +# Tell the viewers what's going to happen... +echo "Starting up X11 session manager..." + +# Try to use GNOME's gdm session manager. This comes first because if +# gdm is on the machine then the user probably installed it and wants +# to use it by default: +if [ -x /usr/bin/gdm ]; then + exec /usr/bin/gdm -nodaemon +fi + +# Someone thought that gdm looked prettier in /usr/sbin, +# so look there, too: +if [ -x /usr/sbin/gdm ]; then + exec /usr/sbin/gdm -nodaemon +fi + +# Not there? OK, try to use KDE's kdm session manager: +if [ -x /opt/kde/bin/kdm ]; then + exec /opt/kde/bin/kdm -nodaemon +elif [ -x /usr/bin/kdm ]; then + exec /usr/bin/kdm -nodaemon +fi + +# If all you have is XDM, I guess it will have to do: +if [ -x /usr/bin/xdm ]; then + exec /usr/bin/xdm -nodaemon +elif [ -x /usr/X11R6/bin/xdm ]; then + exec /usr/X11R6/bin/xdm -nodaemon +fi + +# error +echo +echo "Hey, you don't have KDM, GDM, or XDM. Can't use runlevel 4 without" +echo "one of those installed." +sleep 30 + +# All done. diff --git a/source/a/sysvinit-scripts/scripts/rc.6 b/source/a/sysvinit-scripts/scripts/rc.6 new file mode 100644 index 00000000..2d5028e3 --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/rc.6 @@ -0,0 +1,266 @@ +#! /bin/sh +# +# rc.6 This file is executed by init when it goes into runlevel +# 0 (halt) or runlevel 6 (reboot). It kills all processes, +# unmounts file systems and then either halts or reboots. +# +# Version: @(#)/etc/rc.d/rc.6 2.47 Sat Jan 13 13:37:26 PST 2001 +# +# Author: Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org> +# Modified by: Patrick J. Volkerding, <volkerdi@slackware.com> +# + +# Set the path. +PATH=/sbin:/etc:/bin:/usr/bin + +# If there are SystemV init scripts for this runlevel, run them. +if [ -x /etc/rc.d/rc.sysvinit ]; then + . /etc/rc.d/rc.sysvinit +fi + +# Set linefeed mode to avoid staircase effect. +/bin/stty onlcr + +echo "Running shutdown script $0:" + +# Find out how we were called. +case "$0" in + *0) + command="halt" + ;; + *6) + command=reboot + ;; + *) + echo "$0: call me as \"rc.0\" or \"rc.6\" please!" + exit 1 + ;; +esac + +# Save the system time to the hardware clock using hwclock --systohc. +if [ -x /sbin/hwclock ]; then + # Check for a broken motherboard RTC clock (where ioports for rtc are + # unknown) to prevent hwclock causing a hang: + if ! grep -q -w rtc /proc/ioports ; then + CLOCK_OPT="--directisa" + fi + if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then + echo "Saving system time to the hardware clock (UTC)." + /sbin/hwclock $CLOCK_OPT --utc --systohc + else + echo "Saving system time to the hardware clock (localtime)." + /sbin/hwclock $CLOCK_OPT --localtime --systohc + fi +fi + +# Run any local shutdown scripts: +if [ -x /etc/rc.d/rc.local_shutdown ]; then + /etc/rc.d/rc.local_shutdown stop +fi + +# Stop the Apache web server: +if [ -x /etc/rc.d/rc.httpd ]; then + /etc/rc.d/rc.httpd stop +fi + +# Stop the MySQL database: +if [ -r /var/run/mysql/mysql.pid ]; then + . /etc/rc.d/rc.mysqld stop +fi + +# Stop the Samba server: +if [ -x /etc/rc.d/rc.samba ]; then + . /etc/rc.d/rc.samba stop +fi + +# Shut down the NFS server: +if [ -x /etc/rc.d/rc.nfsd ]; then + /etc/rc.d/rc.nfsd stop +fi + +# Shut down the SSH server: +if [ -x /etc/rc.d/rc.sshd ]; then + /etc/rc.d/rc.sshd stop +fi + +# Shut down the SASL authentication daemon: +if [ -x /etc/rc.d/rc.saslauthd ]; then + /etc/rc.d/rc.saslauthd stop +fi + +# Shut down OpenLDAP: +if [ -x /etc/rc.d/rc.openldap ]; then + /etc/rc.d/rc.openldap stop +fi + +# Stop D-Bus: +if [ -x /etc/rc.d/rc.messagebus ]; then + sh /etc/rc.d/rc.messagebus stop +fi + +# Unmount any NFS, SMB, or CIFS filesystems: +echo "Unmounting remote filesystems." +/bin/umount -v -a -r -t nfs,smbfs,cifs + +# Try to shut down pppd: +PS="$(ps ax)" +if echo "$PS" | /bin/grep -q -w pppd ; then + if [ -x /usr/sbin/ppp-off ]; then + /usr/sbin/ppp-off + fi +fi + +# Bring down the networking system, but first make sure that this +# isn't a diskless client with the / partition mounted via NFS: +if ! /bin/mount | /bin/grep -q 'on / type nfs' ; then + if [ -x /etc/rc.d/rc.inet1 ]; then + . /etc/rc.d/rc.inet1 stop + fi +fi + +# In case dhcpcd might have been manually started on the command line, +# look for the .pid file, and shut dhcpcd down if it's found: +if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then + /sbin/dhcpcd -k 1> /dev/null 2> /dev/null + # A little time for /etc/resolv.conf and/or other files to + # restore themselves. + sleep 2 +fi + +# Shut down PCMCIA devices: +if [ -x /etc/rc.d/rc.pcmcia ]; then + . /etc/rc.d/rc.pcmcia stop + # The cards might need a little extra time here to deactivate: + /bin/sleep 5 +fi + +# Turn off process accounting: +if [ -x /sbin/accton -a -r /var/log/pacct ]; then + /sbin/accton off +fi + +# Terminate acpid before syslog: +if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit + . /etc/rc.d/rc.acpid stop +fi + +# Kill all processes. +# INIT is supposed to handle this entirely now, but this didn't always +# work correctly without this second pass at killing off the processes. +# Since INIT already notified the user that processes were being killed, +# we'll avoid echoing this info this time around. +if [ ! "$1" = "fast" ]; then # shutdown did not already kill all processes + /sbin/killall5 -15 + /bin/sleep 5 + /sbin/killall5 -9 +fi + +# Try to turn off quota. +if /bin/grep -q quota /etc/fstab ; then + if [ -x /sbin/quotaoff ]; then + echo "Turning off filesystem quotas." + /sbin/quotaoff -a + fi +fi + +# Carry a random seed between reboots. +echo "Saving random seed from /dev/urandom in /etc/random-seed." +# Use the pool size from /proc, or 512 bytes: +if [ -r /proc/sys/kernel/random/poolsize ]; then + /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(cat /proc/sys/kernel/random/poolsize) 2> /dev/null +else + /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null +fi +/bin/chmod 600 /etc/random-seed + +# Before unmounting file systems write a reboot or halt record to wtmp. +$command -w + +# Clear /var/lock/subsys. +if [ -d /var/lock/subsys ]; then + rm -f /var/lock/subsys/* +fi + +# Turn off swap: +echo "Turning off swap." +/sbin/swapoff -a +/bin/sync + +# Umount any LVM volumes: +if /bin/mount | /bin/grep -q '^/dev/mapper/' ; then + echo "Unmounting LVM volumes." + /bin/umount -v $(/bin/mount | /bin/grep '^/dev/mapper/' | /bin/cut -d ' ' -f 3 | /bin/tac) +fi + +echo "Unmounting local file systems." +/bin/umount -v -a -t no,proc,sysfs + +echo "Remounting root filesystem read-only." +/bin/mount -v -n -o remount,ro / + +# This never hurts: +/bin/sync + +# Close any volumes opened by cryptsetup: +if [ -f /etc/crypttab -a -x /sbin/cryptsetup.static ]; then + cat /etc/crypttab | grep -v "^#" | grep -v "^$" | while read line; do + # NOTE: we only support LUKS formatted volumes (except for swap)! + LUKS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f1 -d' ') + DEV=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f2 -d' ') + OPTS=$(echo $line | tr '\t' ' ' | tr -s ' ' | cut -f4 -d' ') + if /sbin/cryptsetup.static isLuks $DEV 2>/dev/null ; then + echo "Locking LUKS crypt volume '${LUKS}':" + /sbin/cryptsetup.static luksClose ${LUKS} + elif echo $OPTS | grep -wq swap ; then + # If any of the volumes was used as encrypted swap, + # then run mkswap on the underlying device - + # in case other Linux installations on this computer should use it: + echo "Erasing encrypted swap '${LUKS}' and restoring normal swap on ${DEV}:" + /sbin/cryptsetup.static remove ${LUKS} + mkswap $DEV + fi + done +fi + +# Deactivate LVM volume groups: +if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then + echo "Deactivating LVM volume groups:" + /sbin/vgchange -an --ignorelockingfailure +fi + +# This never hurts again (especially since root-on-LVM always fails +# to deactivate the / logical volume... but at least it was +# remounted as read-only first) +/bin/sync + +# sleep 3 fixes problems with some hard drives that don't +# otherwise finish syncing before reboot or poweroff +/bin/sleep 3 + +# This is to ensure all processes have completed on SMP machines: +wait + +if [ -x /sbin/genpowerd ]; then + # See if this is a powerfail situation: + if /bin/egrep -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then + # Signal UPS to shut off the inverter: + /sbin/genpowerd -k + if [ ! $? = 0 ]; then + echo + echo "There was an error signaling the UPS." + echo "Perhaps you need to edit /etc/genpowerd.conf to configure" + echo "the serial line and UPS type." + # Wasting 15 seconds of precious power: + /bin/sleep 15 + fi + fi +fi + +# Now halt (poweroff with APM or ACPI enabled kernels) or reboot. +if [ "$command" = "reboot" ]; then + echo "Rebooting." + /sbin/reboot +else + /sbin/poweroff +fi + diff --git a/source/a/sysvinit-scripts/scripts/rc.K b/source/a/sysvinit-scripts/scripts/rc.K new file mode 100644 index 00000000..68609753 --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/rc.K @@ -0,0 +1,106 @@ +#! /bin/sh +# +# rc.K This file is executed by init when it goes into runlevel +# 1, which is the administrative state. It kills all +# daemons and then puts the system into single user mode. +# Note that the file systems are kept mounted. +# +# Version: @(#)/etc/rc.d/rc.K 3.1415 Sat Jan 13 13:37:26 PST 2001 +# +# Author: Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org> +# Modified by: Patrick J. Volkerding <volkerdi@slackware.com> +# + +# Set the path. +PATH=/sbin:/bin:/usr/bin:/usr/sbin + +# Load any needed keyboard mappings: +if [ -x /etc/rc.d/rc.keymap ]; then + . /etc/rc.d/rc.keymap +fi + +# If there are SystemV init scripts for this runlevel, run them. +if [ -x /etc/rc.d/rc.sysvinit ]; then + . /etc/rc.d/rc.sysvinit +fi + +# Try to turn off quota: +if grep -q quota /etc/fstab ; then + if [ -x /sbin/quotaoff ]; then + echo "Turning off filesystem quotas." + /sbin/quotaoff -a + fi +fi + +# Try to turn off accounting: +if [ -x /sbin/accton -a -r /var/log/pacct ]; then + /sbin/accton off +fi + +# Run any local shutdown scripts: +if [ -x /etc/rc.d/rc.local_shutdown ]; then + /etc/rc.d/rc.local_shutdown stop +fi + +# Stop the Apache web server: +if [ -x /etc/rc.d/rc.httpd ]; then + /etc/rc.d/rc.httpd stop +fi + +# Stop the Samba server: +if [ -x /etc/rc.d/rc.samba ]; then + . /etc/rc.d/rc.samba stop +fi + +# Shut down the NFS server: +if [ -x /etc/rc.d/rc.nfsd ]; then + /etc/rc.d/rc.nfsd stop +fi + +# Unmount any NFS, SMB, or CIFS filesystems: +echo "Unmounting remote filesystems." +umount -a -r -t nfs,smbfs,cifs + +# Shut down PCMCIA devices: +if [ -x /etc/rc.d/rc.pcmcia ] ; then + . /etc/rc.d/rc.pcmcia stop + # The cards might need a little extra time here to deactivate: + sleep 5 +fi + +# Terminate acpid before syslog: +if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit + . /etc/rc.d/rc.acpid stop +fi + +# Kill all processes. +echo +echo "Sending all processes the SIGHUP signal." +killall5 -1 +echo -n "Waiting for processes to hang up" +for loop in 0 1 2 3 4 5 ; do + sleep 1 + echo -n "." +done +echo +echo "Sending all processes the SIGTERM signal." +killall5 -15 +echo -n "Waiting for processes to terminate" +for loop in 0 1 2 3 4 5 ; do + sleep 1 + echo -n "." +done +echo +echo "Sending all processes the SIGKILL signal." +killall5 -9 +echo -n "Waiting for processes to exit" +for loop in 0 1 2 3 4 5 ; do + sleep 1 + echo -n "." +done +echo + +# Now go to the single user level +echo "Going to single user mode..." +telinit -t 1 1 + diff --git a/source/a/sysvinit-scripts/scripts/rc.M b/source/a/sysvinit-scripts/scripts/rc.M new file mode 100644 index 00000000..fe2c9b6f --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/rc.M @@ -0,0 +1,355 @@ +#!/bin/sh +# +# rc.M This file is executed by init(8) when the system is being +# initialized for one of the "multi user" run levels (i.e. +# levels 1 through 6). It usually does mounting of file +# systems et al. +# +# Version: @(#)/etc/rc.d/rc.M 2.23 Wed Feb 26 19:20:58 PST 2003 +# +# Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> +# Heavily modified by Patrick Volkerding <volkerdi@slackware.com> +# + +# Tell the viewers what's going to happen. +echo "Going multiuser..." + +# Update all the shared library links: +if [ -x /sbin/ldconfig ]; then + echo "Updating shared library links: /sbin/ldconfig &" + /sbin/ldconfig & +fi + +# Screen blanks after 15 minutes idle time, and powers down in one hour +# if the kernel supports APM or ACPI power management: +/bin/setterm -blank 15 -powersave powerdown -powerdown 60 + +# Set the hostname. +if [ -r /etc/HOSTNAME ]; then + /bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .) +else + # fall back on this old default: + echo "darkstar.example.net" > /etc/HOSTNAME + /bin/hostname darkstar +fi + +# Save the contents of 'dmesg': +/bin/dmesg -s 65536 > /var/log/dmesg + +# Initialize PCMCIA devices: +# +# NOTE: This used to be started near the top of rc.S so that PCMCIA devices +# could be fsck'ed along with the other drives. This had some unfortunate +# side effects, however, since root isn't yet read-write, and /var might not +# even be mounted the .pid files can't be correctly written in /var/run and +# the pcmcia system can't be correctly shut down. If you want some PCMCIA +# partition to be mounted at boot (or when the card is inserted) then add +# the appropriate lines to /etc/pcmcia/scsi.opts. +# +# Note that the stuff in /etc/pcmcia/ is only for 2.4.x kernels using +# 16-bit PCMCIA cards (not 32-bit Cardbus cards!). For example, with a +# wireless card you might need to set options in /etc/pcmcia OR in +# /etc/rc.d/rc.wireless.conf, or even in /etc/rc.d/rc.inet1.conf (with +# extra options if needed for the encryption key, ESSID, etc.) +# +# Hopefully this situation will be unified in the future, but for now +# that's how it is... +# +if [ -x /etc/rc.d/rc.pcmcia ]; then + . /etc/rc.d/rc.pcmcia start + # The cards might need a little extra time here to initialize. + sleep 5 +fi + +# Start the system logger. +if [ -x /etc/rc.d/rc.syslog -a -x /usr/sbin/syslogd -a -d /var/log ]; then + . /etc/rc.d/rc.syslog start +fi + +# Update the X font indexes: +if [ -x /usr/bin/fc-cache ]; then + echo "Updating X font indexes: /usr/bin/fc-cache -f &" + /usr/bin/fc-cache -f & +fi + +# If we are returning from single-user mode we will need to restart +# udevd on systems that use udev: +if grep -wq sysfs /proc/mounts && grep -wq tmpfs /proc/filesystems ; then + if ! grep -wq nohotplug /proc/cmdline ; then + if [ -x /etc/rc.d/rc.udev ]; then + /bin/sh /etc/rc.d/rc.udev start + fi + fi +fi + +# Initialize the networking hardware. +if [ -x /etc/rc.d/rc.inet1 ]; then + . /etc/rc.d/rc.inet1 +fi + +# Look for additional USB/SCSI/IEEE1394/etc devices on multiple LUNs: +if [ -x /etc/rc.d/rc.scanluns ]; then + . /etc/rc.d/rc.scanluns +fi + +# Start networking daemons: +if [ -x /etc/rc.d/rc.inet2 ]; then + . /etc/rc.d/rc.inet2 +fi + +# Mount any additional filesystem types that haven't already been mounted: +mount -a -v 2> /dev/null | grep -v "already mounted" + +# Start the Network Time Protocol daemon: +if [ -x /etc/rc.d/rc.ntpd ]; then + sh /etc/rc.d/rc.ntpd start +fi + +# Remove stale locks and junk files (must be done after mount -a!) +/bin/rm -f /var/lock/* /var/spool/uucp/LCK..* /tmp/.X*lock /tmp/core /core 2> /dev/null + +# Remove stale hunt sockets so the game can start. +if [ -r /tmp/hunt -o -r /tmp/hunt.stats ]; then + echo "Removing your stale hunt sockets from /tmp." + /bin/rm -f /tmp/hunt* +fi + +# Ensure basic filesystem permissions sanity. +chmod 755 / 2> /dev/null +chmod 1777 /tmp /var/tmp + +# Start APM or ACPI daemon. +# If APM is enabled in the kernel, start apmd: +if [ -e /proc/apm ]; then + if [ -x /usr/sbin/apmd ]; then + echo "Starting APM daemon: /usr/sbin/apmd" + /usr/sbin/apmd + fi +elif [ -x /etc/rc.d/rc.acpid ]; then # otherwise, start acpid: + . /etc/rc.d/rc.acpid start +fi + +# Update any existing icon cache files: +if find /usr/share/icons 2> /dev/null | grep -q icon-theme.cache ; then + for theme_dir in /usr/share/icons/* ; do + if [ -r ${theme_dir}/icon-theme.cache ]; then + echo "Updating icon-theme.cache in ${theme_dir}..." + /usr/bin/gtk-update-icon-cache -t -f ${theme_dir} 1> /dev/null 2> /dev/null & + fi + done + # This would be a large file and probably shouldn't be there. + if [ -r /usr/share/icons/icon-theme.cache ]; then + echo "Deleting icon-theme.cache in /usr/share/icons..." + #/usr/bin/gtk-update-icon-cache -t -f /usr/share/icons 1> /dev/null 2> /dev/null & + rm -f /usr/share/icons/icon-theme.cache + fi +fi + +# Update mime database: +if [ -x /usr/bin/update-mime-database -a -d /usr/share/mime ]; then + echo "Updating MIME database: /usr/bin/update-mime-database /usr/share/mime &" + /usr/bin/update-mime-database /usr/share/mime 1> /dev/null 2> /dev/null & +fi + +# Start D-Bus: +if [ -x /etc/rc.d/rc.messagebus ]; then + sh /etc/rc.d/rc.messagebus start +fi + +# Start HAL: +if [ -x /etc/rc.d/rc.hald ]; then + sh /etc/rc.d/rc.hald start +fi + +# Start Bluetooth: +if [ -x /etc/rc.d/rc.bluetooth ]; then + sh /etc/rc.d/rc.bluetooth start +fi + +# Start wicd: +if [ -x /etc/rc.d/rc.wicd ]; then + sh /etc/rc.d/rc.wicd start +fi + +# These GTK+/pango files need to be kept up to date for +# proper input method, pixbuf loaders, and font support. +if [ -x /usr/bin/update-gtk-immodules ]; then + /usr/bin/update-gtk-immodules --verbose +fi +if [ -x /usr/bin/update-gdk-pixbuf-loaders ]; then + /usr/bin/update-gdk-pixbuf-loaders --verbose +fi +if [ -x /usr/bin/update-pango-querymodules ]; then + /usr/bin/update-pango-querymodules --verbose +fi + +# Start dnsmasq, a simple DHCP/DNS server: +if [ -x /etc/rc.d/rc.dnsmasq ]; then + /etc/rc.d/rc.dnsmasq start +fi + +# Start snmpd: +if [ -x /etc/rc.d/rc.snmpd ]; then + /etc/rc.d/rc.snmpd start +fi + +# Start the print spooling system. This will usually be LPRng (lpd) or CUPS. +if [ -x /etc/rc.d/rc.cups ]; then + # Start CUPS: + /etc/rc.d/rc.cups start +elif [ -x /etc/rc.d/rc.lprng ]; then + # Start LPRng (lpd): + . /etc/rc.d/rc.lprng start +fi + +# Start netatalk. (a file/print server for Macs using Appletalk) +if [ -x /etc/rc.d/rc.atalk ]; then + /etc/rc.d/rc.atalk +fi + +# Start smartd, which monitors the status of S.M.A.R.T. compatible +# hard drives and reports any problems. Note some devices (which aren't +# smart, I guess ;) will hang if probed by smartd, so it's commented out +# by default. +#if [ -x /usr/sbin/smartd ]; then +# /usr/sbin/smartd +#fi + +# If we're using udev, make /dev/cdrom and any other optical drive symlinks +# if some udev rule hasn't made them already: +if grep -wq sysfs /proc/mounts && grep -wq tmpfs /proc/filesystems; then + if ! grep -wq nohotplug /proc/cmdline ; then + if [ -x /lib/udev/rc.optical-symlinks -a -x /etc/rc.d/rc.udev ]; then + /bin/sh /lib/udev/rc.optical-symlinks + fi + fi +fi + +# Monitor the UPS with genpowerd. +# To use this, uncomment this section and edit your settings in +# /etc/genpowerd.conf (serial device, UPS type, etc). For more information, +# see "man genpowerd" or the extensive documentation in the +# /usr/doc/genpower-*/ directory. +# You'll also need to configure a similar block in /etc/rc.d/rc.6 if you want +# support for stopping the UPS's inverter after the machine halts. +#if [ -x /sbin/genpowerd ]; then +# echo "Starting genpowerd daemon..." +# /sbin/genpowerd +#fi + +# Turn on process accounting. To enable process accounting, make sure the +# option for BSD process accounting is enabled in your kernel, and then +# create the file /var/log/pacct (touch /var/log/pacct). By default, process +# accounting is not enabled (since /var/log/pacct does not exist). This is +# because the log file can get VERY large. +if [ -x /sbin/accton -a -r /var/log/pacct ]; then + chmod 640 /var/log/pacct + /sbin/accton /var/log/pacct +fi + +# Start crond (Dillon's crond): +# If you want cron to actually log activity to /var/log/cron, then change +# -l10 to -l8 to increase the logging level. +if [ -x /usr/sbin/crond ]; then + /usr/sbin/crond -l10 >>/var/log/cron 2>&1 +fi + +# Start atd (manages jobs scheduled with 'at'): +if [ -x /usr/sbin/atd ]; then + /usr/sbin/atd -b 15 -l 1 +fi + +# Slackware-Mini-Quota-HOWTO: +# To really activate quotas, you'll need to add 'usrquota' and/or 'grpquota' to +# the appropriate partitions as listed in /etc/fstab. Here's an example: +# +# /dev/hda2 /home ext3 defaults,usrquota 1 1 +# +# You'll then need to setup initial quota files at the top of the partitions +# to support quota, like this: +# touch /home/aquota.user /home/aquota.group +# chmod 600 /home/aquota.user /home/aquota.group +# +# Then, reboot to activate the system. +# To edit user quotas, use 'edquota'. See 'man edquota'. Also, the +# official Quota Mini-HOWTO has lots of useful information. That can be found +# here: /usr/doc/Linux-HOWTOs/Quota + +# Check quotas and then turn quota system on: +if grep -q quota /etc/fstab ; then + for quotafs in $(awk '/quota/ {print $2}' /etc/fstab) ; do + /bin/rm -f $quotafs/{a,}quota.{group,user}.new + done + if [ -x /sbin/quotacheck ]; then + echo "Checking filesystem quotas: /sbin/quotacheck -avugm" + /sbin/quotacheck -avugm + fi + if [ -x /sbin/quotaon ]; then + echo "Activating filesystem quotas: /sbin/quotaon -avug" + /sbin/quotaon -avug + fi +fi + +# Start the SASL authentication server. This provides SASL +# authentication services for sendmail: +if [ -x /etc/rc.d/rc.saslauthd ]; then + . /etc/rc.d/rc.saslauthd start +fi + +# Start the sendmail daemon: +if [ -x /etc/rc.d/rc.sendmail ]; then + . /etc/rc.d/rc.sendmail start +fi + +# Load ALSA (sound) defaults: +if [ -x /etc/rc.d/rc.alsa ]; then + . /etc/rc.d/rc.alsa +fi + +# Load a custom screen font if the user has an rc.font script. +if [ -x /etc/rc.d/rc.font ]; then + . /etc/rc.d/rc.font +fi + +# Load a custom keymap if the user has an rc.keymap script. +if [ -x /etc/rc.d/rc.keymap ]; then + . /etc/rc.d/rc.keymap +fi + +# Start the MySQL database: +if [ -x /etc/rc.d/rc.mysqld ]; then + . /etc/rc.d/rc.mysqld start +fi + +# Start Apache web server: +if [ -x /etc/rc.d/rc.httpd ]; then + . /etc/rc.d/rc.httpd start +fi + +# Start OpenLDAP: +if [ -x /etc/rc.d/rc.openldap ]; then + . /etc/rc.d/rc.openldap start +fi + +# Start Samba (a file/print server for Win95/NT machines). +# Samba can be started in /etc/inetd.conf instead. +if [ -x /etc/rc.d/rc.samba ]; then + . /etc/rc.d/rc.samba start +fi + +# Start the GPM mouse server: +if [ -x /etc/rc.d/rc.gpm ]; then + . /etc/rc.d/rc.gpm start +fi + +# If there are SystemV init scripts for this runlevel, run them. +if [ -x /etc/rc.d/rc.sysvinit ]; then + . /etc/rc.d/rc.sysvinit +fi + +# Start the local setup procedure. +if [ -x /etc/rc.d/rc.local ]; then + . /etc/rc.d/rc.local +fi + +# All done. diff --git a/source/a/sysvinit-scripts/scripts/rc.S b/source/a/sysvinit-scripts/scripts/rc.S new file mode 100644 index 00000000..a0072d28 --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/rc.S @@ -0,0 +1,382 @@ +#!/bin/sh +# +# /etc/rc.d/rc.S: System initialization script. +# +# Mostly written by: Patrick J. Volkerding, <volkerdi@slackware.com> +# + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +# Mount /proc right away: +/sbin/mount -v proc /proc -n -t proc + +# Mount sysfs next, if the kernel supports it: +if [ -d /sys ]; then + if grep -wq sysfs /proc/filesystems ; then + if ! grep -wq sysfs /proc/mounts ; then + /sbin/mount -v sysfs /sys -n -t sysfs + fi + fi +fi + +# Initialize udev to manage /dev entries and hotplugging for 2.6.x kernels. +# You may turn off udev by making the /etc/rc.d/rc.udev file non-executable +# or giving the "nohotplug" option at boot, but in the 2.6.x+ kernels udev +# has taken over the job of hotplug (finding hardware and loading the kernel +# modules for it, as well as creating device nodes in /dev). Realize that +# if you turn off udev that you will have to load all the kernel modules +# that you need yourself (possibly in /etc/rc.d/rc.modules, which does not +# promise to list all of them), and make any additional device nodes that you +# need in the /dev directory. Even USB and IEEE1394 devices will need to have +# the modules loaded by hand if udev is not used with a 2.6 kernel. So use it. :-) +if grep -wq sysfs /proc/mounts && grep -wq tmpfs /proc/filesystems ; then + if ! grep -wq nohotplug /proc/cmdline ; then + if [ -x /etc/rc.d/rc.udev ]; then + /bin/sh /etc/rc.d/rc.udev start + fi + fi +fi + +# Initialize the Logical Volume Manager. +# This won't start unless we find /etc/lvmtab (LVM1) or +# /etc/lvm/backup/ (LVM2). This is created by /sbin/vgscan, so to +# use LVM you must run /sbin/vgscan yourself the first time (and +# create some VGs and LVs). +if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then + echo "Initializing LVM (Logical Volume Manager):" + # Check for device-mapper support. + if ! grep -wq device-mapper /proc/devices ; then + # Try to load a device-mapper kernel module: + /sbin/modprobe -q dm-mod + fi + # Scan for new volume groups: + /sbin/vgscan --mknodes --ignorelockingfailure 2> /dev/null + if [ $? = 0 ]; then + # Make volume groups available to the kernel. + # This should also make logical volumes available. + /sbin/vgchange -ay --ignorelockingfailure + fi +fi + +# Open any volumes created by cryptsetup: +if [ -f /etc/crypttab -a -x /sbin/cryptsetup.static ]; then + # First, check for device-mapper support. + if ! grep -wq device-mapper /proc/devices ; then + # If device-mapper exists as a module, try to load it. + # Try to load a device-mapper kernel module: + /sbin/modprobe -q dm-mod + fi + # NOTE: we only support LUKS formatted volumes (except for swap)! + cat /etc/crypttab | grep -v "^#" | grep -v "^$" | while read line; do + eval LUKSARRAY=( $line ) + LUKS="${LUKSARRAY[0]}" + DEV="${LUKSARRAY[1]}" + PASS="${LUKSARRAY[2]}" + OPTS="${LUKSARRAY[3]}" + LUKSOPTS="" + if echo $OPTS | grep -wq ro ; then LUKSOPTS="${LUKSOPTS} --readonly" ; fi + + # Skip LUKS volumes that were already unlocked (in the initrd): + /sbin/cryptsetup.static status $LUKS 1>/dev/null 2>/dev/null && continue + if /sbin/cryptsetup.static isLuks $DEV 2>/dev/null ; then + echo "Unlocking LUKS crypt volume '${LUKS}' on device '$DEV':" + if [ -n "${PASS}" ]; then + if [ -f ${PASS} ]; then + /sbin/cryptsetup.static ${LUKSOPTS} --key-file=${PASS} luksOpen $DEV $LUKS + elif [ "${PASS}" != "none" ]; then + # A password field of 'none' indicates a line for swap: + echo "${PASS}" | /sbin/cryptsetup.static ${LUKSOPTS} luksOpen $DEV $LUKS + fi + else + for i in seq 1 3 ; do + /sbin/cryptsetup.static ${LUKSOPTS} luksOpen $DEV $LUKS </dev/tty0 >/dev/tty0 2>&1 + [ $? -eq 0 ] && break + done + fi + elif echo $OPTS | grep -wq swap ; then + # If any of the volumes is to be used as encrypted swap, + # then encrypt it using a random key and run mkswap: + echo "Creating encrypted swap on device '$DEV' mapped to '${LUKS}':" + /sbin/cryptsetup.static --cipher=aes --key-file=/dev/urandom --key-size=256 create $LUKS $DEV + mkswap /dev/mapper/$LUKS + fi + done +fi + +# Enable swapping: +/sbin/swapon -a + +# Start FUSE, if requested: +if [ -x /etc/rc.d/rc.fuse ]; then + sh /etc/rc.d/rc.fuse start +fi + +# Set the system time from the hardware clock using hwclock --hctosys. +if [ -x /sbin/hwclock ]; then + # Check for a broken motherboard RTC clock (where ioports for rtc are + # unknown) to prevent hwclock causing a hang: + if ! grep -q -w rtc /proc/ioports ; then + CLOCK_OPT="--directisa" + fi + if grep -wq "^UTC" /etc/hardwareclock ; then + echo "Setting system time from the hardware clock (UTC)." + /sbin/hwclock $CLOCK_OPT --utc --hctosys + else + echo "Setting system time from the hardware clock (localtime)." + /sbin/hwclock $CLOCK_OPT --localtime --hctosys + fi +fi + +# Test to see if the root partition is read-only, like it ought to be. +READWRITE=no +if touch /fsrwtestfile 2>/dev/null; then + rm -f /fsrwtestfile + READWRITE=yes +else + echo "Testing root filesystem status: read-only filesystem" +fi + +# See if a forced filesystem check was requested at shutdown: +if [ -r /etc/forcefsck ]; then + FORCEFSCK="-f" +fi + +# Check the root filesystem: +if [ ! $READWRITE = yes ]; then + RETVAL=0 + if [ ! -r /etc/fastboot ]; then + echo "Checking root filesystem:" + /sbin/fsck $FORCEFSCK -C -a / + RETVAL=$? + fi + # An error code of 2 or higher will require a reboot. + if [ $RETVAL -ge 2 ]; then + # An error code equal to or greater than 4 means that some errors + # could not be corrected. This requires manual attention, so we + # offer a chance to try to fix the problem in single-user mode: + if [ $RETVAL -ge 4 ]; then + echo + echo "***********************************************************" + echo "*** An error occurred during the root filesystem check. ***" + echo "*** You will now be given a chance to log into the ***" + echo "*** system in single-user mode to fix the problem. ***" + echo "*** ***" + echo "*** If you are using the ext2 filesystem, running ***" + echo "*** 'e2fsck -v -y <partition>' might help. ***" + echo "***********************************************************" + echo + echo "Once you exit the single-user shell, the system will reboot." + echo + PS1="(Repair filesystem) \#"; export PS1 + sulogin + else # With an error code of 2 or 3, reboot the machine automatically: + echo + echo "***********************************" + echo "*** The filesystem was changed. ***" + echo "*** The system will now reboot. ***" + echo "***********************************" + echo + fi + echo "Unmounting file systems." + /sbin/umount -a -r + /sbin/mount -n -o remount,ro / + echo "Rebooting system." + sleep 2 + reboot -f + fi + # Remount the root filesystem in read-write mode + echo "Remounting root device with read-write enabled." + /sbin/mount -w -v -n -o remount / + if [ $? -gt 0 ] ; then + echo + echo "Attempt to remount root device as read-write failed! This is going to" + echo "cause serious problems." + echo + echo "If you're using the UMSDOS filesystem, you **MUST** mount the root partition" + echo "read-write! You can make sure the root filesystem is getting mounted " + echo "read-write with the 'rw' flag to Loadlin:" + echo + echo "loadlin vmlinuz root=/dev/hda1 rw (replace /dev/hda1 with your root device)" + echo + echo "Normal bootdisks can be made to mount a system read-write with the rdev command:" + echo + echo "rdev -R /dev/fd0 0" + echo + echo "You can also get into your system by using a boot disk with a command like this" + echo "on the LILO prompt line: (change the root partition name as needed)" + echo + echo "LILO: mount root=/dev/hda1 rw" + echo + echo "Please press ENTER to continue, then reboot and use one of the above methods to" + echo -n "get into your machine and start looking for the problem. " + read junk; + fi +else + echo "Testing root filesystem status: read-write filesystem" + echo + echo "*** ERROR: Root partition has already been mounted read-write. Cannot check!" + echo + echo "For filesystem checking to work properly, your system must initially mount" + echo "the root partition as read only. Please modify your kernel with 'rdev' so that" + echo "it does this. If you're booting with LILO, add a line:" + echo + echo " read-only" + echo + echo "to the Linux section in your /etc/lilo.conf and type 'lilo' to reinstall it." + echo + echo "If you boot from a kernel on a floppy disk, put it in the drive and type:" + echo " rdev -R /dev/fd0 1" + echo + echo "If you boot from a bootdisk, or with Loadlin, you can add the 'ro' flag." + echo + echo "This will fix the problem *AND* eliminate this annoying message. :^)" + echo + echo -n "Press ENTER to continue. " + read junk; +fi # Done checking root filesystem + +# Any /etc/mtab that exists here is old, so we delete it to start over: +/bin/rm -f /etc/mtab* +# Remounting the / partition will initialize the new /etc/mtab: +/sbin/mount -w -o remount / + +# Read in the correct / filesystem complete with arguments so mount will +# show them correctly. This does not stop those arguments from functioning +# but does prevent a small bug with /etc/mtab. +/bin/grep ' / ' /proc/mounts | grep -v "^rootfs" > /etc/mtab + +# Fix /etc/mtab to list sys and proc if they were not yet entered in +# /etc/mtab because / was still mounted read-only: +if [ -d /proc/sys ]; then + /sbin/mount -f proc /proc -t proc +fi +if [ -d /sys/bus ]; then + /sbin/mount -f sysfs /sys -t sysfs +fi + +# Configure ISA Plug-and-Play devices: +if [ -r /etc/isapnp.conf ]; then + if [ -x /sbin/isapnp ]; then + /sbin/isapnp /etc/isapnp.conf + fi +fi + +# This loads any kernel modules that are needed. These might be required to +# use your ethernet card, sound card, or other optional hardware. +# Priority is given first to a script named "rc.modules.local", then +# to "rc.modules-$FULL_KERNEL_VERSION", and finally to the plain "rc.modules". +# Note that if /etc/rc.d/rc.modules.local is found, then that will be the ONLY +# rc.modules script the machine will run, so make sure it has everything in +# it that you need. +if [ -x /etc/rc.d/rc.modules.local -a -r /proc/modules ]; then + echo "Running /etc/rc.d/rc.modules.local:" + /bin/sh /etc/rc.d/rc.modules.local +elif [ -x /etc/rc.d/rc.modules-$(uname -r) -a -r /proc/modules ]; then + echo "Running /etc/rc.d/rc.modules-$(uname -r):" + . /etc/rc.d/rc.modules-$(uname -r) +elif [ -x /etc/rc.d/rc.modules -a -r /proc/modules -a -L /etc/rc.d/rc.modules ]; then + echo "Running /etc/rc.d/rc.modules -> $(readlink /etc/rc.d/rc.modules):" + . /etc/rc.d/rc.modules +elif [ -x /etc/rc.d/rc.modules -a -r /proc/modules ]; then + echo "Running /etc/rc.d/rc.modules:" + . /etc/rc.d/rc.modules +fi + +# Configure runtime kernel parameters: +if [ -x /sbin/sysctl -a -r /etc/sysctl.conf ]; then + /sbin/sysctl -e -p /etc/sysctl.conf +fi + +# Check all the non-root filesystems: +if [ ! -r /etc/fastboot ]; then + echo "Checking non-root filesystems:" + /sbin/fsck $FORCEFSCK -C -R -A -a +fi + +# Mount usbfs: +if grep -wq usbfs /proc/filesystems; then + if ! grep -wq usbfs /proc/mounts ; then + if ! grep -wq usbfs /etc/fstab; then + /sbin/mount -v usbfs /proc/bus/usb -t usbfs + else + /sbin/mount -v /proc/bus/usb + fi + fi +fi + +# Mount non-root file systems in fstab, but not NFS or SMB +# because TCP/IP is not yet configured, and not proc or sysfs +# because those have already been mounted. Also check that +# devpts is not already mounted before attempting to mount +# it. With a 2.6.x or newer kernel udev mounts devpts. +# We also need to wait a little bit to let USB and other +# hotplugged devices settle (sorry to slow down the boot): +echo "Mounting non-root local filesystems:" +sleep 3 +if /bin/grep -wq devpts /proc/mounts ; then + /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs,nodevpts +else + /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs +fi + +# Enable swapping again. This is needed in case a swapfile is used, +# as it can't be enabled until the filesystem it resides on has been +# mounted read-write. +/sbin/swapon -a + +# Clean up some temporary files: +rm -f /var/run/* /var/run/*/* /var/run/*/*/* /etc/nologin \ + /etc/dhcpc/*.pid /etc/forcefsck /etc/fastboot \ + /var/state/saslauthd/saslauthd.pid \ + /tmp/.Xauth* 1> /dev/null 2> /dev/null + ( cd /var/log/setup/tmp && rm -rf * ) + ( cd /tmp && rm -rf kde-[a-zA-Z]* ksocket-[a-zA-Z]* hsperfdata_[a-zA-Z]* plugtmp* ) + +# Create /tmp/{.ICE-unix,.X11-unix} if they are not present: +if [ ! -e /tmp/.ICE-unix ]; then + mkdir -p /tmp/.ICE-unix + chmod 1777 /tmp/.ICE-unix +fi +if [ ! -e /tmp/.X11-unix ]; then + mkdir -p /tmp/.X11-unix + chmod 1777 /tmp/.X11-unix +fi + +# Create a fresh utmp file: +touch /var/run/utmp +chown root:utmp /var/run/utmp +chmod 664 /var/run/utmp + +# Update the current kernel level in the /etc/motd (Message Of The Day) file, +# if the first line of that file begins with the word 'Linux'. +# You are free to modify the rest of the file as you see fit. +if [ -x /bin/sed ]; then + /bin/sed -i "{1s/^Linux.*/$(/bin/uname -sr)\./}" /etc/motd +fi + +# If there are SystemV init scripts for this runlevel, run them. +if [ -x /etc/rc.d/rc.sysvinit ]; then + . /etc/rc.d/rc.sysvinit +fi + +# Run serial port setup script: +# CAREFUL! This can make some systems hang if the rc.serial script isn't +# set up correctly. If this happens, you may have to edit the file from a +# boot disk, and/or set it as non-executable: +if [ -x /etc/rc.d/rc.serial ]; then + sh /etc/rc.d/rc.serial start +fi + +# Carry an entropy pool between reboots to improve randomness. +if [ -f /etc/random-seed ]; then + echo "Using /etc/random-seed to initialize /dev/urandom." + cat /etc/random-seed > /dev/urandom +fi +# Use the pool size from /proc, or 512 bytes: +if [ -r /proc/sys/kernel/random/poolsize ]; then + dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(cat /proc/sys/kernel/random/poolsize) 2> /dev/null +else + dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null +fi +chmod 600 /etc/random-seed + diff --git a/source/a/sysvinit-scripts/scripts/rc.local b/source/a/sysvinit-scripts/scripts/rc.local new file mode 100644 index 00000000..65b358bb --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/rc.local @@ -0,0 +1,9 @@ +#!/bin/sh +# +# /etc/rc.d/rc.local: Local system initialization script. +# +# Put any local startup commands in here. Also, if you have +# anything that needs to be run at shutdown time you can +# make an /etc/rc.d/rc.local_shutdown script and put those +# commands in there. + diff --git a/source/a/sysvinit-scripts/scripts/rc.sysvinit b/source/a/sysvinit-scripts/scripts/rc.sysvinit new file mode 100644 index 00000000..916e59ee --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/rc.sysvinit @@ -0,0 +1,58 @@ +#!/bin/sh +# +# rc.sysvinit This file provides basic compatibility with SystemV style +# startup scripts. The SystemV style init system places +# start/stop scripts for each runlevel into directories such as +# /etc/rc.d/rc3.d/ (for runlevel 3) instead of starting them +# from /etc/rc.d/rc.M. This makes for a lot more init scripts, +# and a more complicated execution path to follow through if +# something goes wrong. For this reason, Slackware has always +# used the traditional BSD style init script layout. +# +# However, many binary packages exist that install SystemV +# init scripts. With rc.sysvinit in place, most well-written +# startup scripts will work. This is primarily intended to +# support commercial software, though, and probably shouldn't +# be considered bug free. +# +# Written by Patrick Volkerding <volkerdi@slackware.com>, 1999 +# from an example by Miquel van Smoorenburg <miquels@cistron.nl>. + +# Run an init script: +startup() { + case "$1" in + *.sh) + sh "$@" + ;; + *) + "$@" + ;; + esac +} + +# Set onlcr to avoid staircase effect. +stty onlcr 0>&1 + +if [ "$runlevel" = "" ]; then + runlevel=$RUNLEVEL + export runlevel + prevlevel=$PREVLEVEL + export prevlevel +fi + +# Run kill scripts in the previous runlevel if not "none" +if [ ! "$prevlevel" = "N" ]; then + for script in /etc/rc.d/rc$prevlevel.d/K* ; do + if [ -x $script ]; then + startup $script stop + fi + done +fi + +# Now do the startup scripts: +for script in /etc/rc.d/rc$runlevel.d/S* ; do + if [ -x $script ]; then + startup $script start + fi +done + diff --git a/source/a/sysvinit-scripts/scripts/rescan-scsi-bus.sh b/source/a/sysvinit-scripts/scripts/rescan-scsi-bus.sh new file mode 100644 index 00000000..4378e208 --- /dev/null +++ b/source/a/sysvinit-scripts/scripts/rescan-scsi-bus.sh @@ -0,0 +1,558 @@ +#!/bin/bash +# Skript to rescan SCSI bus, using the +# scsi add-single-device mechanism +# (c) 1998--2008 Kurt Garloff <kurt@garloff.de>, GNU GPL v2 or later +# (c) 2006--2008 Hannes Reinecke, GNU GPL v2 or later +# $Id: rescan-scsi-bus.sh,v 1.29 2008/10/29 10:03:04 garloff Exp $ + +setcolor () +{ + red="\e[0;31m" + green="\e[0;32m" + yellow="\e[0;33m" + bold="\e[0;1m" + norm="\e[0;0m" +} + +unsetcolor () +{ + red=""; green="" + yellow=""; norm="" +} + +# Return hosts. sysfs must be mounted +findhosts_26 () +{ + hosts= + if ! ls /sys/class/scsi_host/host* >/dev/null 2>&1; then + echo "No SCSI host adapters found in sysfs" + exit 1; + fi + for hostdir in /sys/class/scsi_host/host*; do + hostno=${hostdir#/sys/class/scsi_host/host} + if [ -f $hostdir/isp_name ] ; then + hostname="qla2xxx" + elif [ -f $hostdir/lpfc_drvr_version ] ; then + hostname="lpfc" + else + hostname=`cat $hostdir/proc_name` + fi + hosts="$hosts $hostno" + echo "Host adapter $hostno ($hostname) found." + done + hosts=`echo $hosts | sed 's/ /\n/g' | sort -n` +} + +# Return hosts. /proc/scsi/HOSTADAPTER/? must exist +findhosts () +{ + hosts= + for driverdir in /proc/scsi/*; do + driver=${driverdir#/proc/scsi/} + if test $driver = scsi -o $driver = sg -o $driver = dummy -o $driver = device_info; then continue; fi + for hostdir in $driverdir/*; do + name=${hostdir#/proc/scsi/*/} + if test $name = add_map -o $name = map -o $name = mod_parm; then continue; fi + num=$name + driverinfo=$driver + if test -r $hostdir/status; then + num=$(printf '%d\n' `sed -n 's/SCSI host number://p' $hostdir/status`) + driverinfo="$driver:$name" + fi + hosts="$hosts $num" + echo "Host adapter $num ($driverinfo) found." + done + done +} + +# Get /proc/scsi/scsi info for device $host:$channel:$id:$lun +# Optional parameter: Number of lines after first (default = 2), +# result in SCSISTR, return code 1 means empty. +procscsiscsi () +{ + if test -z "$1"; then LN=2; else LN=$1; fi + CHANNEL=`printf "%02i" $channel` + ID=`printf "%02i" $id` + LUN=`printf "%02i" $lun` + if [ -d /sys/class/scsi_device ]; then + SCSIPATH="/sys/class/scsi_device/${host}:${channel}:${id}:${lun}" + if [ -d "$SCSIPATH" ] ; then + SCSISTR="Host: scsi${host} Channel: $CHANNEL Id: $ID Lun: $LUN" + if [ "$LN" -gt 0 ] ; then + IVEND=$(cat ${SCSIPATH}/device/vendor) + IPROD=$(cat ${SCSIPATH}/device/model) + IPREV=$(cat ${SCSIPATH}/device/rev) + SCSIDEV=$(printf ' Vendor: %-08s Model: %-16s Rev: %-4s' "$IVEND" "$IPROD" "$IPREV") + SCSISTR="$SCSISTR +$SCSIDEV" + fi + if [ "$LN" -gt 1 ] ; then + ILVL=$(cat ${SCSIPATH}/device/scsi_level) + type=$(cat ${SCSIPATH}/device/type) + case "$type" in + 0) ITYPE="Direct-Access " ;; + 1) ITYPE="Sequential-Access" ;; + 2) ITYPE="Printer " ;; + 3) ITYPE="Processor " ;; + 4) ITYPE="WORM " ;; + 5) ITYPE="CD-ROM " ;; + 6) ITYPE="Scanner " ;; + 7) ITYPE="Optical Device " ;; + 8) ITYPE="Medium Changer " ;; + 9) ITYPE="Communications " ;; + 10) ITYPE="Unknown " ;; + 11) ITYPE="Unknown " ;; + 12) ITYPE="RAID " ;; + 13) ITYPE="Enclosure " ;; + 14) ITYPE="Direct-Access-RBC" ;; + *) ITYPE="Unknown " ;; + esac + SCSITMP=$(printf ' Type: %-16s ANSI SCSI revision: %02d' "$ITYPE" "$((ILVL - 1))") + SCSISTR="$SCSISTR +$SCSITMP" + fi + + else + return 1 + fi + else + grepstr="scsi$host Channel: $CHANNEL Id: $ID Lun: $LUN" + SCSISTR=`cat /proc/scsi/scsi | grep -A$LN -e"$grepstr"` + fi + if test -z "$SCSISTR"; then return 1; else return 0; fi +} + +# Find sg device with 2.6 sysfs support +sgdevice26 () +{ + if test -e /sys/class/scsi_device/$host\:$channel\:$id\:$lun/device/generic; then + SGDEV=`readlink /sys/class/scsi_device/$host\:$channel\:$id\:$lun/device/generic` + SGDEV=`basename $SGDEV` + else + for SGDEV in /sys/class/scsi_generic/sg*; do + DEV=`readlink $SGDEV/device` + if test "${DEV##*/}" = "$host:$channel:$id:$lun"; then + SGDEV=`basename $SGDEV`; return + fi + done + SGDEV="" + fi +} + +# Find sg device with 2.4 report-devs extensions +sgdevice24 () +{ + if procscsiscsi 3; then + SGDEV=`echo "$SCSISTR" | grep 'Attached drivers:' | sed 's/^ *Attached drivers: \(sg[0-9]*\).*/\1/'` + fi +} + +# Find sg device that belongs to SCSI device $host $channel $id $lun +sgdevice () +{ + SGDEV= + if test -d /sys/class/scsi_device; then + sgdevice26 + else + DRV=`grep 'Attached drivers:' /proc/scsi/scsi 2>/dev/null` + repdevstat=$((1-$?)) + if [ $repdevstat = 0 ]; then + echo "scsi report-devs 1" >/proc/scsi/scsi + DRV=`grep 'Attached drivers:' /proc/scsi/scsi 2>/dev/null` + if [ $? = 1 ]; then return; fi + fi + if ! `echo $DRV | grep 'drivers: sg' >/dev/null`; then + modprobe sg + fi + sgdevice24 + if [ $repdevstat = 0 ]; then + echo "scsi report-devs 0" >/proc/scsi/scsi + fi + fi +} + +# Test if SCSI device is still responding to commands +testonline () +{ + : testonline + if test ! -x /usr/bin/sg_turs; then return 0; fi + sgdevice + if test -z "$SGDEV"; then return 0; fi + sg_turs /dev/$SGDEV >/dev/null 2>&1 + RC=$? + # echo -e "\e[A\e[A\e[A${yellow}Test existence of $SGDEV = $RC ${norm} \n\n\n" + if test $RC = 1; then return $RC; fi + # OK, device online, compare INQUIRY string + INQ=`sg_inq $sg_len_arg /dev/$SGDEV` + IVEND=`echo "$INQ" | grep 'Vendor identification:' | sed 's/^[^:]*: \(.*\)$/\1/'` + IPROD=`echo "$INQ" | grep 'Product identification:' | sed 's/^[^:]*: \(.*\)$/\1/'` + IPREV=`echo "$INQ" | grep 'Product revision level:' | sed 's/^[^:]*: \(.*\)$/\1/'` + STR=`printf " Vendor: %-08s Model: %-16s Rev: %-4s" "$IVEND" "$IPROD" "$IPREV"` + IPTYPE=`echo "$INQ" | sed -n 's/.* Device_type=\([0-9]*\) .*/\1/p'` + IPQUAL=`echo "$INQ" | sed -n 's/ *PQual=\([0-9]*\) Device.*/\1/p'` + if [ "$IPQUAL" != 0 ] ; then + echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nLU not available (PQual $IPQUAL)${norm}\n\n\n" + return 1 + fi + + procscsiscsi + TMPSTR=`echo "$SCSISTR" | grep 'Vendor:'` + if [ "$TMPSTR" != "$STR" ]; then + echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${TMPSTR#* } \nto: $STR ${norm}\n\n\n" + return 1 + fi + TMPSTR=`echo "$SCSISTR" | sed -n 's/.*Type: *\(.*\) *ANSI.*/\1/p'` + if [ $TMPSTR != $TYPE ] ; then + echo -e "\e[A\e[A\e[A\e[A${red}$SGDEV changed: ${bold}\nfrom:${TMPSTR} \nto: $TYPE ${norm}\n\n\n" + return 1 + fi + return $RC +} + +# Test if SCSI device $host $channen $id $lun exists +# Outputs description from /proc/scsi/scsi, returns SCSISTR +testexist () +{ + : testexist + SCSISTR= + if procscsiscsi; then + echo "$SCSISTR" | head -n1 + echo "$SCSISTR" | tail -n2 | pr -o4 -l1 + fi +} + +# Returns the list of existing channels per host +chanlist () +{ + local hcil + local cil + local chan + local tmpchan + + for dev in /sys/class/scsi_device/${host}:* ; do + hcil=${dev##*/} + cil=${hcil#*:} + chan=${cil%%:*} + for tmpchan in $channelsearch ; do + if test "$chan" -eq $tmpchan ; then + chan= + fi + done + if test -n "$chan" ; then + channelsearch="$channelsearch $chan" + fi + done +} + +# Returns the list of existing targets per host +idlist () +{ + local hcil + local cil + local il + local target + local tmpid + + for dev in /sys/class/scsi_device/${host}:${channel}:* ; do + hcil=${dev##*/} + cil=${hcil#*:} + il=${cil#*:} + target=${il%%:*} + for tmpid in $idsearch ; do + if test "$target" -eq $tmpid ; then + target= + fi + done + if test -n "$target" ; then + idsearch="$idsearch $target" + fi + done +} + +# Returns the list of existing LUNs +getluns () +{ + if test ! -x /usr/bin/sg_luns; then return; fi + sgdevice + if test -z "$SGDEV"; then return; fi + sg_luns -d /dev/$SGDEV | sed -n 's/.*lun=\(.*\)/\1/p' +} + +# Perform scan on a single lun +dolunscan() +{ + SCSISTR= + devnr="$host $channel $id $lun" + echo "Scanning for device $devnr ..." + printf "${yellow}OLD: $norm" + testexist + : f $remove s $SCSISTR + if test "$remove" -a "$SCSISTR"; then + # Device exists: Test whether it's still online + # (testonline returns 1 if it's gone or has changed) + testonline + if test $? = 1 -o ! -z "$forceremove"; then + echo -en "\r\e[A\e[A\e[A${red}REM: " + echo "$SCSISTR" | head -n1 + echo -e "${norm}\e[B\e[B" + if test -e /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device; then + echo 1 > /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/delete + # Try reading, should fail if device is gone + echo "$channel $id $lun" > /sys/class/scsi_host/host${host}/scan + else + echo "scsi remove-single-device $devnr" > /proc/scsi/scsi + # Try reading, should fail if device is gone + echo "scsi add-single-device $devnr" > /proc/scsi/scsi + fi + fi + if test $RC = 0 ; then + if test -e /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device; then + echo 1 > /sys/class/scsi_device/${host}:${channel}:${id}:${lun}/device/rescan + fi + fi + + printf "\r\x1b[A\x1b[A\x1b[A${yellow}OLD: $norm" + testexist + if test -z "$SCSISTR"; then + printf "\r${red}DEL: $norm\r\n\n" + let rmvd+=1; + fi + fi + if test -z "$SCSISTR"; then + # Device does not exist, try to add + printf "\r${green}NEW: $norm" + if test -e /sys/class/scsi_host/host${host}/scan; then + echo "$channel $id $lun" > /sys/class/scsi_host/host${host}/scan 2> /dev/null + else + echo "scsi add-single-device $devnr" > /proc/scsi/scsi + fi + testexist + if test -z "$SCSISTR"; then + # Device not present + printf "\r\x1b[A"; + # Optimization: if lun==0, stop here (only if in non-remove mode) + if test $lun = 0 -a -z "$remove" -a $optscan = 1; then + break; + fi + else + let found+=1; + fi + fi +} + +# Perform report lun scan +doreportlun() +{ + lun=0 + SCSISTR= + devnr="$host $channel $id $lun" + echo "Scanning for device $devnr ..." + printf "${yellow}OLD: $norm" + testexist + if test -z "$SCSISTR"; then + # Device does not exist, try to add + printf "\r${green}NEW: $norm" + if test -e /sys/class/scsi_host/host${host}/scan; then + echo "$channel $id $lun" > /sys/class/scsi_host/host${host}/scan 2> /dev/null + else + echo "scsi add-single-device $devnr" > /proc/scsi/scsi + fi + testexist + if test -z "$SCSISTR"; then + # Device not present + printf "\r\x1b[A"; + lunsearch= + return + fi + fi + lunsearch=`getluns` + lunremove= + # Check existing luns + for dev in /sys/class/scsi_device/$host\:$channel\:$id\:*; do + lun=${dev##*:} + newsearch= + oldsearch="$lunsearch" + for tmplun in $lunsearch; do + if test $tmplun -eq $lun ; then + # Optimization: don't scan lun 0 again + if [ $lun -ne 0 ]; then + dolunscan + fi + else + newsearch="$newsearch $tmplun" + fi + done + if [ "${#oldsearch}" = "${#newsearch}" ] ; then + # Stale lun + lunremove="$lunremove $lun" + fi + lunsearch="$newsearch" + done + # Add new ones and check stale ones + for lun in $lunsearch $lunremove; do + dolunscan + done +} + +# Perform search (scan $host) +dosearch () +{ + if test -z "$channelsearch" ; then + chanlist + fi + for channel in $channelsearch; do + if test -z "$idsearch" ; then + idlist + fi + for id in $idsearch; do + if test -z "$lunsearch"; then + doreportlun + else + for lun in $lunsearch; do + dolunscan + done + fi + done + done +} + +# main +if test @$1 = @--help -o @$1 = @-h -o @$1 = @-?; then + echo "Usage: rescan-scsi-bus.sh [options] [host [host ...]]" + echo "Options:" + echo " -l activates scanning for LUNs 0-7 [default: 0]" + echo " -L NUM activates scanning for LUNs 0--NUM [default: 0]" + echo " -w scan for target device IDs 0 .. 15 [default: 0-7]" + echo " -c enables scanning of channels 0 1 [default: 0]" + echo " -r enables removing of devices [default: disabled]" + echo " -i issue a FibreChannel LIP reset [default: disabled]" + echo "--remove: same as -r" + echo "--issue-lip: same as -i" + echo "--forceremove: Remove and readd every device (DANGEROUS)" + echo "--nooptscan: don't stop looking for LUNs is 0 is not found" + echo "--color: use coloured prefixes OLD/NEW/DEL" + echo "--hosts=LIST: Scan only host(s) in LIST" + echo "--channels=LIST: Scan only channel(s) in LIST" + echo "--ids=LIST: Scan only target ID(s) in LIST" + echo "--luns=LIST: Scan only lun(s) in LIST" + echo " Host numbers may thus be specified either directly on cmd line (deprecated) or" + echo " or with the --hosts=LIST parameter (recommended)." + echo "LIST: A[-B][,C[-D]]... is a comma separated list of single values and ranges" + echo " (No spaces allowed.)" + exit 0 +fi + +expandlist () +{ + list=$1 + result="" + first=${list%%,*} + rest=${list#*,} + while test ! -z "$first"; do + beg=${first%%-*}; + if test "$beg" = "$first"; then + result="$result $beg"; + else + end=${first#*-} + result="$result `seq $beg $end`" + fi + test "$rest" = "$first" && rest="" + first=${rest%%,*} + rest=${rest#*,} + done + echo $result +} + +if test ! -d /sys/class/scsi_host/ -a ! -d /proc/scsi/; then + echo "Error: SCSI subsystem not active" + exit 1 +fi + +# Make sure sg is there +modprobe sg >/dev/null 2>&1 + +sg_version=$(sg_inq -V 2>&1 | cut -d " " -f 3) +sg_version=${sg_version##0.} +if [ "$sg_version" -lt 70 ] ; then + sg_len_arg="-36" +else + sg_len_arg="--len=36" +fi + +# defaults +unsetcolor +lunsearch="" +idsearch=`seq 0 7` +channelsearch="0" +remove= +forceremove= +optscan=1 +if test -d /sys/class/scsi_host; then + findhosts_26 +else + findhosts +fi + +# Scan options +opt="$1" +while test ! -z "$opt" -a -z "${opt##-*}"; do + opt=${opt#-} + case "$opt" in + l) lunsearch=`seq 0 7` ;; + L) lunsearch=`seq 0 $2`; shift ;; + w) idsearch=`seq 0 15` ;; + c) channelsearch="0 1" ;; + r) remove=1 ;; + i) lipreset=1 ;; + -remove) remove=1 ;; + -forceremove) remove=1; forceremove=1 ;; + -hosts=*) arg=${opt#-hosts=}; hosts=`expandlist $arg` ;; + -channels=*) arg=${opt#-channels=};channelsearch=`expandlist $arg` ;; + -ids=*) arg=${opt#-ids=}; idsearch=`expandlist $arg` ;; + -luns=*) arg=${opt#-luns=}; lunsearch=`expandlist $arg` ;; + -color) setcolor ;; + -nooptscan) optscan=0 ;; + -issue-lip) lipreset=1 ;; + *) echo "Unknown option -$opt !" ;; + esac + shift + opt="$1" +done + +# Hosts given ? +if test "@$1" != "@"; then + hosts=$*; +fi + +echo "Scanning SCSI subsystem for new devices" +test -z "$remove" || echo " and remove devices that have disappeared" +declare -i found=0 +declare -i rmvd=0 +for host in $hosts; do + echo -n "Scanning host $host " + if test -e /sys/class/fc_host/host$host ; then + # It's pointless to do a target scan on FC + if test -n "$lipreset" ; then + echo 1 > /sys/class/fc_host/host$host/issue_lip 2> /dev/null; + echo "- - -" > /sys/class/scsi_host/host$host/scan 2> /dev/null; + fi + channelsearch="" + idsearch="" + fi + [ -n "$channelsearch" ] && echo -n "channels $channelsearch " + echo -n "for " + if [ -n "$idsearch" ] ; then + echo -n " SCSI target IDs " $idsearch + else + echo -n " all SCSI target IDs" + fi + if [ -n "$lunsearch" ] ; then + echo ", LUNs " $lunsearch + else + echo ", all LUNs" + fi + dosearch; +done +echo "$found new device(s) found. " +echo "$rmvd device(s) removed. " + |