diff --git a/Makefile b/Makefile index 71f2478..4abf8ff 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -DEPENDS = bash,dhclient,ifupdown,procps-ng,sysvinit +DEPENDS = bash,iftools,kmod,procps-ng,sysvinit ARCH = x86_64 URL = BRIEF = Base scripts for sysvinit @@ -17,7 +17,7 @@ DESC = This package supplies the base system init scripts for sysvinit ARCHIVE := '' SRCDIR := $(PWD)/SRC/initscripts PATCHDIR := $(PWD)/SRC/patches -VERSION := 0.4-2 +VERSION := 1.0-0 include /usr/share/snap/Makefile.snaplinux diff --git a/SNAP/usher b/SNAP/usher new file mode 100755 index 0000000..466be9b --- /dev/null +++ b/SNAP/usher @@ -0,0 +1,37 @@ +#!/bin/bash + +set -e + +case $1 in + preinst) + exit 0 + ;; + postinst) + if [[ ${TARGET} ]]; then + chroot ${TARGET} 'update-rc required' + else + update-rc required + fi + + if [ ! -f ${TARGET}/etc/modules.conf ]; then + cp ${TARGET}/usr/share/initscripts/modules.conf \ + ${TARGET}/etc/modules.conf + fi + + if [ ! -f ${TARGET}/etc/default/halt ]; then + cp ${TARGET}/usr/share/initscripts/halt.default \ + ${TARGET}/etc/default/halt + fi + + if [ ! -f ${TARGET}/etc/default/rcS ]; then + cp ${TARGET}/usr/share/initscripts/rcS.default \ + ${TARGET}/etc/default/rcS + fi + ;; + prerm) + exit 0 + ;; + postrm) + exit 0 + ;; +esac diff --git a/SRC/initscripts/Makefile b/SRC/initscripts/Makefile index 78ade62..f5e63ab 100644 --- a/SRC/initscripts/Makefile +++ b/SRC/initscripts/Makefile @@ -1,82 +1,33 @@ dirs: install -d -m 755 $(DESTDIR)/etc/default - install -d -m 755 $(DESTDIR)/etc/network.d install -d -m 755 $(DESTDIR)/etc/{rc{{0..6},S},init}.d install -d -m 755 $(DESTDIR)/lib/lsb + install -d -m 755 $(DESTDIR)/usr/share/initscripts install -d -m 755 $(DESTDIR)/usr/share/man/man8 + install -d -m 755 $(DESTDIR)/sbin files: - install -m 754 etc/default/console $(DESTDIR)/etc/default/console - install -m 644 etc/network.conf $(DESTDIR)/etc/network.conf - install -m 754 etc/init.d/checkfs $(DESTDIR)/etc/init.d/checkfs - install -m 754 etc/init.d/cleanfs $(DESTDIR)/etc/init.d/cleanfs - install -m 754 etc/init.d/console $(DESTDIR)/etc/init.d/console - install -m 754 etc/init.d/halt $(DESTDIR)/etc/init.d/halt - install -m 754 etc/init.d/localnet $(DESTDIR)/etc/init.d/localnet - install -m 754 etc/init.d/modules $(DESTDIR)/etc/init.d/modules - install -m 754 etc/init.d/mountfs $(DESTDIR)/etc/init.d/mountfs - install -m 754 etc/init.d/mountvirtfs $(DESTDIR)/etc/init.d/mountvirtfs - install -m 754 etc/init.d/network $(DESTDIR)/etc/init.d/network - install -m 754 etc/init.d/rc $(DESTDIR)/etc/init.d/rc - install -m 754 etc/init.d/reboot $(DESTDIR)/etc/init.d/reboot - install -m 754 etc/init.d/sendsignals $(DESTDIR)/etc/init.d/sendsignals - install -m 754 etc/init.d/setclock $(DESTDIR)/etc/init.d/setclock - install -m 754 etc/init.d/swap $(DESTDIR)/etc/init.d/swap - install -m 754 etc/init.d/sysctl $(DESTDIR)/etc/init.d/sysctl - install -m 754 etc/init.d/sysklogd $(DESTDIR)/etc/init.d/sysklogd - install -m 754 etc/init.d/template $(DESTDIR)/etc/init.d/template - install -m 754 etc/init.d/udev $(DESTDIR)/etc/init.d/udev - install -m 754 etc/modules.conf $(DESTDIR)/etc/modules.conf - install -m 754 lib/lsb/init-functions $(DESTDIR)/lib/lsb/init-functions + install -m 755 init.d/checkfs $(DESTDIR)/etc/init.d/checkfs + install -m 755 init.d/cleanfs $(DESTDIR)/etc/init.d/cleanfs + install -m 755 init.d/halt $(DESTDIR)/etc/init.d/halt + install -m 755 init.d/hostname $(DESTDIR)/etc/init.d/hostname + install -m 755 init.d/hwclock $(DESTDIR)/etc/init.d/hwclock + install -m 755 init.d/localnet $(DESTDIR)/etc/init.d/localnet + install -m 755 init.d/modules $(DESTDIR)/etc/init.d/modules + install -m 755 init.d/mountfs $(DESTDIR)/etc/init.d/mountfs + install -m 755 init.d/mountvirtfs $(DESTDIR)/etc/init.d/mountvirtfs + install -m 755 init.d/rc $(DESTDIR)/etc/init.d/rc + install -m 755 init.d/reboot $(DESTDIR)/etc/init.d/reboot + install -m 755 init.d/sendsignals $(DESTDIR)/etc/init.d/sendsignals + install -m 755 init.d/swap $(DESTDIR)/etc/init.d/swap + install -m 755 init.d/sysctl $(DESTDIR)/etc/init.d/sysctl + install -m 755 init-functions $(DESTDIR)/lib/lsb/init-functions + install -m 644 halt.default \ + $(DESTDIR)/usr/share/initscripts/halt.default + install -m 644 modules.conf \ + $(DESTDIR)/usr/share/initscripts/modules.conf + install -m 644 rcS.default \ + $(DESTDIR)/usr/share/initscripts/rcS.default + install -m 755 update-rc $(DESTDIR)/sbin -rc0: - ln -sfv ../init.d/network $(DESTDIR)/etc/rc0.d/K80network - ln -sfv ../init.d/sysklogd $(DESTDIR)/etc/rc0.d/K90sysklogd - ln -sfv ../init.d/sendsignals $(DESTDIR)/etc/rc0.d/S60sendsignals - ln -sfv ../init.d/swap $(DESTDIR)/etc/rc0.d/S65swap - ln -sfv ../init.d/mountfs $(DESTDIR)/etc/rc0.d/S70mountfs - ln -sfv ../init.d/localnet $(DESTDIR)/etc/rc0.d/S90localnet - ln -sfv ../init.d/halt $(DESTDIR)/etc/rc0.d/S99halt - -rc1: - ln -sfv ../init.d/network $(DESTDIR)/etc/rc1.d/K80network - ln -sfv ../init.d/sysklogd $(DESTDIR)/etc/rc1.d/K90sysklogd - -rc2: - ln -sfv ../init.d/network $(DESTDIR)/etc/rc2.d/K80network - ln -sfv ../init.d/sysklogd $(DESTDIR)/etc/rc2.d/K90sysklogd - -rc3: - ln -sfv ../init.d/sysklogd $(DESTDIR)/etc/rc3.d/S10sysklogd - ln -sfv ../init.d/network $(DESTDIR)/etc/rc3.d/S20network - -rc4: - ln -sfv ../init.d/sysklogd $(DESTDIR)/etc/rc4.d/S10sysklogd - ln -sfv ../init.d/network $(DESTDIR)/etc/rc4.d/S20network - -rc5: - ln -sfv ../init.d/sysklogd $(DESTDOR)/etc/rc5.d/S10sysklogd - ln -sfv ../init.d/network $(DESTDIR)/etc/rc5.d/S20network - -rc6: - ln -sfv ../init.d/network $(DESTDIR)/etc/rc6.d/K80network - ln -sfv ../init.d/sysklogd $(DESTDIR)/etc/rc6.d/K90sysklogd - ln -sfv ../init.d/sendsignals $(DESTDIR)/etc/rc6.d/S60sendsignals - ln -sfv ../init.d/swap $(DESTDIR)/etc/rc6.d/S65swap - ln -sfv ../init.d/mountfs $(DESTDIR)/etc/rc6.d/S70mountfs - ln -sfv ../init.d/localnet $(DESTDIR)/etc/rc6.d/S90localnet - ln -sfv ../init.d/reboot $(DESTDIR)/etc/rc6.d/S99reboot - -rcS: - ln -sfv ../init.d/mountvirtfs $(DESTDIR)/etc/rcS.d/S00mountvirtfs - ln -sfv ../init.d/sysctl $(DESTDIR)/etc/rcS.d/S02sysctl - ln -sfv ../init.d/modules $(DESTDIR)/etc/rcS.d/S05modules - ln -sfv ../init.d/localnet $(DESTDIR)/etc/rcS.d/S08localnet - ln -sfv ../init.d/udev $(DESTDIR)/etc/rcS.d/S10udev - ln -sfv ../init.d/swap $(DESTDIR)/etc/rcS.d/S20swap - ln -sfv ../init.d/checkfs $(DESTDIR)/etc/rcS.d/S30checkfs - ln -sfv ../init.d/mountfs $(DESTDIR)/etc/rcS.d/S40mountfs - ln -sfv ../init.d/cleanfs $(DESTDIR)/etc/rcS.d/S45cleanfs - ln -sfv ../init.d/console $(DESTDIR)/etc/rcS.d/S70console - -install: dirs files rc0 rc1 rc2 rc3 rc4 rc5 rc6 rcS +install: dirs files diff --git a/SRC/initscripts/etc/default/console b/SRC/initscripts/etc/default/console deleted file mode 100644 index d0fe15e..0000000 --- a/SRC/initscripts/etc/default/console +++ /dev/null @@ -1,77 +0,0 @@ -# Console configuration - -############################################################ -# -# The LOGLEVEL variable specifies the log level for kernel -# messages sent to the console as set by dmesg. Valid -# levels are from "1" (no messages) to "8". The default -# level is "7". -# -############################################################ - -LOGLEVEL="7" - -############################################################ -# -# The KEYMAP variable specifies the arguments for the -# loadkeys program, typically, the name of keymap to load, -# e.g., “es”. If this variable is not set, the bootscript -# will not run the loadkeys program, and the default kernel -# keymap will be used. -# -############################################################ - -KEYMAP="" - -############################################################ -# -# The KEYMAP_CORRECTIONS variable specifies the arguments -# for the second call to the loadkeys program. This is -# useful if the stock keymap is not completely satisfactory -# and a small adjustment has to be made. E.g., to include -# the Euro sign into a keymap that normally doesn't have it, -# set this variable to “euro2”. -# -############################################################ - -KEYMAP_CORRECTIONS="" - -############################################################ -# -# The FONT variable specifies the arguments for the setfont -# program. Typically, this includes the font name, “-m”, -# and the name of the application character map to load. -# E.g., in order to load the “lat1-16” font together with -# the “8859-1” application character map (as it is -# appropriate in the USA), set this variable to -# “lat1-16 -m 8859-1”. In UTF-8 mode, the kernel uses the -# application character map for conversion of composed 8-bit -# key codes in the keymap to UTF-8, and thus the argument of -# the "-m" parameter should be set to the encoding of the -# composed key codes in the keymap. -# -############################################################ - -FONT="" - -############################################################ -# -# Set the UNICODE variable to “1”, “yes” or “true” in order -# to put the console into UTF-8 mode. This is useful in -# UTF-8 based locales and harmful otherwise. -# -############################################################ - -UNICODE="" - -############################################################ -# -# For many keyboard layouts, there is no stock Unicode -# keymap in the Kbd package. The console bootscript will -# convert an available keymap to UTF-8 on the fly if the -# LEGACY_CHARSET variable is set to the encoding of the -# available non-UTF-8 keymap. -# -############################################################ - -LEGACY_CHARSET="" diff --git a/SRC/initscripts/etc/init.d/checkfs b/SRC/initscripts/etc/init.d/checkfs deleted file mode 100644 index c711e4a..0000000 --- a/SRC/initscripts/etc/init.d/checkfs +++ /dev/null @@ -1,149 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin checkfs -# -# Description : File System Check -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# A. Luebke - luebke@users.sourceforge.net -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -# Based on checkfs script from LFS-3.1 and earlier. -# -# From man fsck -# 0 - No errors -# 1 - File system errors corrected -# 2 - System should be rebooted -# 4 - File system errors left uncorrected -# 8 - Operational error -# 16 - Usage or syntax error -# 32 - Fsck canceled by user request -# 128 - Shared library error -# -######################################################################### - -### BEGIN INIT INFO -# Provides: checkfs -# Required-Start: udev swap $time -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Checks local filesystems before mounting. -# Description: Checks local filesystmes before mounting. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - if [ -f /fastboot ]; then - msg="/fastboot found, will omit " - msg="${msg} file system checks as requested.\n" - log_info_msg "${msg}" - exit 0 - fi - - log_info_msg "Mounting root file system in read-only mode... " - mount -n -o remount,ro / >/dev/null - - if [ ${?} != 0 ]; then - log_failure_msg2 - msg="\n\nCannot check root " - msg="${msg}filesystem because it could not be mounted " - msg="${msg}in read-only mode.\n\n" - msg="${msg}After you press Enter, this system will be " - msg="${msg}halted and powered off.\n\n" - log_failure_msg "${msg}" - - log_info_msg "Press Enter to continue..." - wait_for_user - /etc/rc.d/init.d/halt stop - else - log_success_msg2 - fi - - if [ -f /forcefsck ]; then - msg="\n/forcefsck found, forcing file" - msg="${msg} system checks as requested." - log_success_msg "$msg" - options="-f" - else - options="" - fi - - log_info_msg "Checking file systems..." - # Note: -a option used to be -p; but this fails e.g. on fsck.minix - if is_true "$VERBOSE_FSCK"; then - fsck ${options} -a -A -C -T - else - fsck ${options} -a -A -C -T >/dev/null - fi - - error_value=${?} - - if [ "${error_value}" = 0 ]; then - log_success_msg2 - fi - - if [ "${error_value}" = 1 ]; then - msg="\nWARNING:\n\nFile system errors " - msg="${msg}were found and have been corrected.\n" - msg="${msg}You may want to double-check that " - msg="${msg}everything was fixed properly." - log_warning_msg "$msg" - fi - - if [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then - msg="\nWARNING:\n\nFile system errors " - msg="${msg}were found and have been been " - msg="${msg}corrected, but the nature of the " - msg="${msg}errors require this system to be rebooted.\n\n" - msg="${msg}After you press enter, " - msg="${msg}this system will be rebooted\n\n" - log_failure_msg "$msg" - - log_info_msg "Press Enter to continue..." - wait_for_user - reboot -f - fi - - if [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then - msg="\nFAILURE:\n\nFile system errors " - msg="${msg}were encountered that could not be " - msg="${msg}fixed automatically. This system " - msg="${msg}cannot continue to boot and will " - msg="${msg}therefore be halted until those " - msg="${msg}errors are fixed manually by a " - msg="${msg}System Administrator.\n\n" - msg="${msg}After you press Enter, this system will be " - msg="${msg}halted and powered off.\n\n" - log_failure_msg "$msg" - - log_info_msg "Press Enter to continue..." - wait_for_user - /etc/rc.d/init.d/halt stop - fi - - if [ "${error_value}" -ge 16 ]; then - msg="\nFAILURE:\n\nUnexpected Failure " - msg="${msg}running fsck. Exited with error " - msg="${msg} code: ${error_value}." - log_failure_msg $msg - exit ${error_value} - fi - - exit 0 - ;; - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -# End checkfs diff --git a/SRC/initscripts/etc/init.d/cleanfs b/SRC/initscripts/etc/init.d/cleanfs deleted file mode 100644 index 3bae23f..0000000 --- a/SRC/initscripts/etc/init.d/cleanfs +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin cleanfs -# -# Description : Clean file system -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: cleanfs -# Required-Start: $local_fs -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Cleans temporary directories early in the boot process. -# Description: Cleans /var/lock, /var/run, and /tmp. Also creates -# /var/run/utmp -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - log_info_msg "Cleaning file systems:" - - if [ "${SKIPTMPCLEAN}" = "" ]; then - log_info_msg2 " /tmp" - cd /tmp && - find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1 - cd /var/lock && - find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1 - cd /var/run && - find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1 - fi - - > /var/run/utmp - - if grep -q '^utmp:' /etc/group ; then - chmod 664 /var/run/utmp - chgrp utmp /var/run/utmp - fi - - (exit ${failed}) - evaluate_retval - - exit $failed - ;; - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -# End cleanfs diff --git a/SRC/initscripts/etc/init.d/console b/SRC/initscripts/etc/init.d/console deleted file mode 100644 index bbfd8e7..0000000 --- a/SRC/initscripts/etc/init.d/console +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin console -# -# Description : Sets keymap and screen font -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# Alexander E. Patrakov -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: console -# Required-Start: -# Should-Start: $local_fs -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Sets up a localised console. -# Description: Sets up fonts and language settings for the user's -# local as defined by /etc/default/console. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -# Native English speakers probably don't have /etc/default/console at all -[ -r /etc/default/console ] && . /etc/default/console - -is_true() -{ - [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] -} - -failed=0 - -case "${1}" in - start) - # See if we need to do anything - if [ -z "${KEYMAP}" ] && [ -z "${KEYMAP_CORRECTIONS}" ] && - [ -z "${FONT}" ] && [ -z "${LEGACY_CHARSET}" ] && - ! is_true "${UNICODE}"; then - exit 0 - fi - - # There should be no bogus failures below this line! - log_info_msg "Setting up Linux console..." - - # Figure out if a framebuffer console is used - [ -d /sys/class/graphics/fb0 ] && use_fb=1 || use_fb=0 - - # Figure out the command to set the console into the - # desired mode - is_true "${UNICODE}" && - MODE_COMMAND="echo -en '\033%G' && kbd_mode -u" || - MODE_COMMAND="echo -en '\033%@\033(K' && kbd_mode -a" - - # On framebuffer consoles, font has to be set for each vt in - # UTF-8 mode. This doesn't hurt in non-UTF-8 mode also. - - ! is_true "${use_fb}" || [ -z "${FONT}" ] || - MODE_COMMAND="${MODE_COMMAND} && setfont ${FONT}" - - # Apply that command to all consoles mentioned in - # /etc/inittab. Important: in the UTF-8 mode this should - # happen before setfont, otherwise a kernel bug will - # show up and the unicode map of the font will not be - # used. - - for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab | - grep -o '\btty[[:digit:]]*\b'` - do - openvt -f -w -c ${TTY#tty} -- \ - /bin/sh -c "${MODE_COMMAND}" || failed=1 - done - - # Set the font (if not already set above) and the keymap - [ "${use_fb}" == "1" ] || [ -z "${FONT}" ] || setfont $FONT || failed=1 - - [ -z "${KEYMAP}" ] || - loadkeys ${KEYMAP} >/dev/null 2>&1 || - failed=1 - - [ -z "${KEYMAP_CORRECTIONS}" ] || - loadkeys ${KEYMAP_CORRECTIONS} >/dev/null 2>&1 || - failed=1 - - # Convert the keymap from $LEGACY_CHARSET to UTF-8 - [ -z "$LEGACY_CHARSET" ] || - dumpkeys -c "$LEGACY_CHARSET" | loadkeys -u >/dev/null 2>&1 || - failed=1 - - # If any of the commands above failed, the trap at the - # top would set $failed to 1 - ( exit $failed ) - evaluate_retval - - exit $failed - ;; - - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -# End console diff --git a/SRC/initscripts/etc/init.d/halt b/SRC/initscripts/etc/init.d/halt deleted file mode 100644 index f8bfc70..0000000 --- a/SRC/initscripts/etc/init.d/halt +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin halt -# -# Description : Halt Script -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: halt -# Required-Start: -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: 0 -# Default-Stop: -# Short-Description: Halts the system. -# Description: Halts the System. -# X-LFS-Provided-By: LFS -### END INIT INFO - -case "${1}" in - stop) - halt -d -f -i -p - ;; - - *) - echo "Usage: {stop}" - exit 1 - ;; -esac - -# End halt diff --git a/SRC/initscripts/etc/init.d/localnet b/SRC/initscripts/etc/init.d/localnet deleted file mode 100644 index aa1f6aa..0000000 --- a/SRC/initscripts/etc/init.d/localnet +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin localnet -# -# Description : Loopback device -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: localnet -# Required-Start: $local_fs -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Starts the local network. -# Description: Sets the hostname of the machine and starts the -# loopback interface. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions -[ -r /etc/hostname ] && HOSTNAME=`cat /etc/hostname` - -case "${1}" in - start) - log_info_msg "Bringing up the loopback interface..." - ip addr add 127.0.0.1/8 label lo dev lo - ip link set lo up - evaluate_retval - - log_info_msg "Setting hostname to ${HOSTNAME}..." - hostname ${HOSTNAME} - evaluate_retval - ;; - - stop) - log_info_msg "Bringing down the loopback interface..." - ip link set lo down - evaluate_retval - ;; - - restart) - ${0} stop - sleep 1 - ${0} start - ;; - - status) - echo "Hostname is: $(hostname)" - ip link show lo - ;; - - *) - echo "Usage: ${0} {start|stop|restart|status}" - exit 1 - ;; -esac - -exit 0 - -# End localnet diff --git a/SRC/initscripts/etc/init.d/modules b/SRC/initscripts/etc/init.d/modules deleted file mode 100644 index 7e61185..0000000 --- a/SRC/initscripts/etc/init.d/modules +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin modules -# -# Description : Module auto-loading script -# -# Authors : Zack Winkles -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: modules -# Required-Start: mountvirtfs sysctl -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Loads required modules. -# Description: Loads modules listed in /etc/modules.conf -# X-LFS-Provided-By: LFS -### END INIT INFO - -MODULES="/etc/modules.conf" - -# Assure that the kernel has module support. -[ -e /proc/modules ] || exit 0 - -. /lib/lsb/init-functions - -case "${1}" in - start) - # Exit if there's no modules file or there are no - # valid entries - [ -r ${MODULES} ] || exit 0 - egrep -qv '^($|#)' ${MODULES} || exit 0 - - log_info_msg "Loading modules:" - - # Only try to load modules if the user has actually given us - # some modules to load. - - while read module args; do - - # Ignore comments and blank lines. - case "$module" in - ""|"#"*) continue ;; - esac - - # Attempt to load the module, passing any arguments provided. - modprobe ${module} ${args} >/dev/null - - # Print the module name if successful, otherwise take note. - if [ $? -eq 0 ]; then - log_info_msg2 " ${module}" - else - failedmod="${failedmod} ${module}" - fi - done < ${MODULES} - - # Print a message about successfully loaded modules on the correct line. - log_success_msg2 - - # Print a failure message with a list of any modules that - # may have failed to load. - if [ -n "${failedmod}" ]; then - log_failure_msg "Failed to load modules:${failedmod}" - exit 1 - fi - ;; - - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -exit 0 - -# End modules diff --git a/SRC/initscripts/etc/init.d/mountfs b/SRC/initscripts/etc/init.d/mountfs deleted file mode 100644 index 4605d60..0000000 --- a/SRC/initscripts/etc/init.d/mountfs +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin mountfs -# -# Description : File System Mount Script -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: $local_fs -# Required-Start: udev checkfs -# Should-Start: -# Required-Stop: swap -# Should-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Mounts/unmounts local filesystems defined in /etc/fstab. -# Description: Remounts root filesystem read/write and mounts all -# remaining local filesystems defined in /etc/fstab on -# start. Remounts root filesystem read-only and unmounts -# remaining filesystems on stop. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - log_info_msg "Remounting root file system in read-write mode..." - mount -o remount,rw / >/dev/null - evaluate_retval - - # Remove fsck-related file system watermarks. - rm -f /fastboot /forcefsck - - # Make sure /dev/pts exists - mkdir -p /dev/pts - - # This will mount all filesystems that do not have _netdev in - # their option list. _netdev denotes a network filesystem. - - log_info_msg "Mounting remaining file systems..." - mount -a -O no_netdev >/dev/null - evaluate_retval - exit $failed - ;; - - stop) - # Don't unmount virtual file systems like /run - log_info_msg "Unmounting all other currently mounted file systems..." - umount -a -d -r -t notmpfs,nosysfs,nodevtmpfs,noproc,nodevpts >/dev/null - evaluate_retval - - # Make sure / is mounted read only (umount bug) - mount -o remount,ro / - - # Make all LVM volume groups unavailable, if appropriate - # This fails if swap or / are on an LVM partition - #if [ -x /sbin/vgchange ]; then /sbin/vgchange -an > /dev/null; fi - ;; - - *) - echo "Usage: ${0} {start|stop}" - exit 1 - ;; -esac - -# End mountfs diff --git a/SRC/initscripts/etc/init.d/mountvirtfs b/SRC/initscripts/etc/init.d/mountvirtfs deleted file mode 100644 index 4f34451..0000000 --- a/SRC/initscripts/etc/init.d/mountvirtfs +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin mountvirtfs -# -# Description : Mount proc, sysfs, and run -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: mountvirtfs -# Required-Start: -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Mounts /sys and /proc virtual (kernel) filesystems. -# Mounts /run (tmpfs) and /dev (devtmpfs). -# Description: Mounts /sys and /proc virtual (kernel) filesystems. -# Mounts /run (tmpfs) and /dev (devtmpfs). -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - # Make sure /run is available before logging any messages - if ! mountpoint /run >/dev/null; then - mount /run || failed=1 - fi - - mkdir -p /run/lock /run/shm - chmod 1777 /run/shm - - log_info_msg "Mounting virtual file systems: ${INFO}/run" - - if ! mountpoint /proc >/dev/null; then - log_info_msg2 " ${INFO}/proc" - mount -o nosuid,noexec,nodev /proc || failed=1 - fi - - if ! mountpoint /sys >/dev/null; then - log_info_msg2 " ${INFO}/sys" - mount -o nosuid,noexec,nodev /sys || failed=1 - fi - - if ! mountpoint /dev >/dev/null; then - log_info_msg2 " ${INFO}/dev" - mount -o mode=0755,nosuid /dev || failed=1 - fi - - ln -sfn /run/shm /dev/shm - - (exit ${failed}) - evaluate_retval - exit $failed - ;; - - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -# End mountvirtfs diff --git a/SRC/initscripts/etc/init.d/network b/SRC/initscripts/etc/init.d/network deleted file mode 100644 index 90a6d28..0000000 --- a/SRC/initscripts/etc/init.d/network +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin network -# -# Description : Network Control Script -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# Nathan Coulson - nathan@linuxfromscratch.org -# Kevin P. Fleming - kpfleming@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: $network -# Required-Start: $local_fs swap localnet -# Should-Start: $syslog -# Required-Stop: $local_fs swap localnet -# Should-Stop: $syslog -# Default-Start: 3 4 5 -# Default-Stop: 0 1 2 6 -# Short-Description: Starts and configures network interfaces. -# Description: Starts and configures network interfaces. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - # make sure /run/network is available - if [ ! -d /run/network ]; then - mkdir /run/network - fi - # Start all network interfaces - for file in `find /etc/network.d -type f|sort`; do - interface=${file##*/} - - log_info_msg "Bringing up interface ${interface}" - /sbin/ifup ${interface} 1>/dev/null - evaluate_retval - done - ;; - - stop) - # Reverse list - for file in `find /etc/network.d -type f|sort -r`; do - interface=${file##*/} - - log_info_msg "Bringing down interface ${interface}" - /sbin/ifdown ${interface} 1>/dev/null - evaluate_retval - done - ;; - - restart) - ${0} stop - sleep 1 - ${0} start - ;; - - *) - echo "Usage: ${0} {start|stop|restart}" - exit 1 - ;; -esac - -exit 0 - -# End network diff --git a/SRC/initscripts/etc/init.d/rc b/SRC/initscripts/etc/init.d/rc deleted file mode 100644 index 0ae4f5e..0000000 --- a/SRC/initscripts/etc/init.d/rc +++ /dev/null @@ -1,228 +0,0 @@ -#!/bin/bash -######################################################################## -# Begin rc -# -# Description : Main Run Level Control Script -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# : DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -. /lib/lsb/init-functions - -print_error_msg() -{ - log_failure_msg - # $i is set when called - MSG="FAILURE:\n\nYou should not be reading this error message.\n\n" - MSG="${MSG}It means that an unforeseen error took place in\n" - MSG="${MSG}${i},\n" - MSG="${MSG}which exited with a return value of ${error_value}.\n" - - MSG="${MSG}If you're able to track this error down to a bug in one of\n" - MSG="${MSG}the files provided by the files provided by\n" - MSG="${MSG}the ${DISTRO_MINI} book, please be so kind to inform us at\n" - MSG="${MSG}${DISTRO_CONTACT}.\n" - log_failure_msg "${MSG}" - - log_info_msg "Press Enter to continue..." - wait_for_user -} - -check_script_status() -{ - # $i is set when called - if [ ! -f ${i} ]; then - log_warning_msg "${i} is not a valid symlink." - continue - fi - - if [ ! -x ${i} ]; then - log_warning_msg "${i} is not executable, skipping." - continue - fi -} - -run() -{ - if [ -z $interactive ]; then - ${1} ${2} - return $? - fi - - while true; do - read -p "Run ${1} ${2} (Yes/no/continue)? " -n 1 runit - echo - - case ${runit} in - c | C) - interactive="" - ${i} ${2} - ret=${?} - break; - ;; - - n | N) - return 0 - ;; - - y | Y) - ${i} ${2} - ret=${?} - break - ;; - esac - done - - return $ret -} - -DISTRO=${DISTRO:-"Snaplinux"} -DISTRO_CONTACT=${DISTRO_CONTACT:-"jlarson@snaplinux.org"} -DISTRO_MINI=${DISTRO_MINI:-"Snap"} -IPROMPT=${IPROMPT:-"no"} - -echo "0 0 0 0" > /proc/sys/kernel/printk - -# These 3 signals will not cause our script to exit -trap "" INT QUIT TSTP - -[ "${1}" != "" ] && runlevel=${1} - -if [ "${runlevel}" == "" ]; then - echo "Usage: ${0} " >&2 - exit 1 -fi - -previous=${PREVLEVEL} -[ "${previous}" == "" ] && previous=N - -if [ ! -d /etc/rc${runlevel}.d ]; then - log_info_msg "/etc/rc${runlevel}.d does not exist.\n" - exit 1 -fi - -if [ "$runlevel" == "6" -o "$runlevel" == "0" ]; then IPROMPT="no"; fi - -# Note: In ${LOGLEVEL:-7}, it is ':' 'dash' '7', not minus 7 -if [ "$runlevel" == "S" ]; then - [ -r /etc/default/console ] && source /etc/default/console - dmesg -n "${LOGLEVEL:-7}" -fi - -if [ "${IPROMPT}" == "yes" -a "${runlevel}" == "S" ]; then - # The total length of the distro welcome string, without escape codes - wlen=${wlen:-$(echo "Welcome to ${DISTRO}" | wc -c )} - welcome_message=${welcome_message:-"Welcome to ${INFO}${DISTRO}${NORMAL}"} - - # The total length of the interactive string, without escape codes - ilen=${ilen:-$(echo "Press 'I' to enter interactive startup" | wc -c )} - i_message=${i_message:-"Press '${FAILURE}I${NORMAL}' to enter interactive startup"} - - - # dcol and icol are spaces before the message to center the message - # on screen. itime is the amount of wait time for the user to press a key - wcol=$(( ( ${COLUMNS} - ${wlen} ) / 2 )) - icol=$(( ( ${COLUMNS} - ${ilen} ) / 2 )) - itime=${itime:-"3"} - - echo -e "\n\n" - echo -e "\\033[${wcol}G${welcome_message}" - echo -e "\\033[${icol}G${i_message}${NORMAL}" - echo "" - read -t "${itime}" -n 1 interactive 2>&1 > /dev/null -fi - -# Make lower case -[ "${interactive}" == "I" ] && interactive="i" -[ "${interactive}" != "i" ] && interactive="" - -# Read the state file if it exists from runlevel S -[ -r /var/run/interactive ] && source /var/run/interactive - -# Attempt to stop all services started by the previous runlevel, -# and killed in this runlevel -if [ "${previous}" != "N" ]; then - for i in $(ls -v /etc/rc${runlevel}.d/K* 2> /dev/null) - do - check_script_status - - suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]} - prev_start=/etc/rc$previous.d/S[0-9][0-9]$suffix - sysinit_start=/etc/rcS.d/S[0-9][0-9]$suffix - - if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then - if [ ! -f ${prev_start} -a ! -f ${sysinit_start} ]; then - MSG="WARNING:\n\n${i} can't be " - MSG="${MSG}executed because it was not " - MSG="${MSG}not started in the previous " - MSG="${MSG}runlevel (${previous})." - log_warning_msg "$MSG" - continue - fi - fi - - run ${i} stop - error_value=${?} - - if [ "${error_value}" != "0" ]; then print_error_msg; fi - done -fi - -if [ "${previous}" == "N" ]; then export IN_BOOT=1; fi - -if [ "$runlevel" == "6" -a -n "${FASTBOOT}" ]; then - touch /fastboot -fi - - -# Start all functions in this runlevel -for i in $( ls -v /etc/rc${runlevel}.d/S* 2> /dev/null) -do - if [ "${previous}" != "N" ]; then - suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]} - stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix - prev_start=/etc/rc$previous.d/S[0-9][0-9]$suffix - - [ -f ${prev_start} -a ! -f ${stop} ] && continue - fi - - check_script_status - - case ${runlevel} in - 0|6) - run ${i} stop - ;; - *) - run ${i} start - ;; - esac - - error_value=${?} - - if [ "${error_value}" != "0" ]; then print_error_msg; fi -done - -# Store interactive variable on switch from runlevel S and remove if not -if [ "${runlevel}" == "S" -a "${interactive}" == "i" ]; then - echo "interactive=\"i\"" > /var/run/interactive -else - rm -f /var/run/interactive 2> /dev/null -fi - -# Copy the boot log on initial boot only -if [ "${previous}" == "N" -a "${runlevel}" != "S" ]; then - cat $BOOTLOG >> /var/log/boot.log - - # Mark the end of boot - echo "--------" >> /var/log/boot.log - - # Remove the temporary file - rm -f $BOOTLOG 2> /dev/null -fi - -# End rc diff --git a/SRC/initscripts/etc/init.d/reboot b/SRC/initscripts/etc/init.d/reboot deleted file mode 100644 index 9e4dd11..0000000 --- a/SRC/initscripts/etc/init.d/reboot +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin reboot -# -# Description : Reboot Scripts -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: reboot -# Required-Start: -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: 6 -# Default-Stop: -# Short-Description: Reboots the system. -# Description: Reboots the System. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - stop) - log_info_msg "Restarting system..." - reboot -d -f -i - ;; - - *) - echo "Usage: ${0} {stop}" - exit 1 - ;; - -esac - -# End reboot diff --git a/SRC/initscripts/etc/init.d/sendsignals b/SRC/initscripts/etc/init.d/sendsignals deleted file mode 100644 index 55de311..0000000 --- a/SRC/initscripts/etc/init.d/sendsignals +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin sendsignals -# -# Description : Sendsignals Script -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: sendsignals -# Required-Start: -# Should-Start: -# Required-Stop: $local_fs swap localnet -# Should-Stop: -# Default-Start: -# Default-Stop: 0 6 -# Short-Description: Attempts to kill remaining processes. -# Description: Attempts to kill remaining processes. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - stop) - log_info_msg "Sending all processes the TERM signal..." - killall5 -15 - error_value=${?} - - sleep ${KILLDELAY} - - if [ "${error_value}" = 0 -o "${error_value}" = 2 ]; then - log_success_msg - else - log_failure_msg - fi - - log_info_msg "Sending all processes the KILL signal..." - killall5 -9 - error_value=${?} - - sleep ${KILLDELAY} - - if [ "${error_value}" = 0 -o "${error_value}" = 2 ]; then - log_success_msg - else - log_failure_msg - fi - ;; - - *) - echo "Usage: ${0} {stop}" - exit 1 - ;; - -esac - -exit 0 - -# End sendsignals diff --git a/SRC/initscripts/etc/init.d/setclock b/SRC/initscripts/etc/init.d/setclock deleted file mode 100644 index d3faf9d..0000000 --- a/SRC/initscripts/etc/init.d/setclock +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin setclock -# -# Description : Setting Linux Clock -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: -# Required-Start: -# Should-Start: modules -# Required-Stop: -# Should-Stop: $syslog -# Default-Start: S -# Default-Stop: -# Short-Description: Stores and restores time from the hardware clock -# Description: On boot, system time is obtained from hwclock. The -# hardware clock can also be set on shutdown. -# X-LFS-Provided-By: LFS BLFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${UTC}" in - yes|true|1) - CLOCKPARAMS="${CLOCKPARAMS} --utc" - ;; - - no|false|0) - CLOCKPARAMS="${CLOCKPARAMS} --localtime" - ;; - -esac - -case ${1} in - start) - hwclock --hctosys ${CLOCKPARAMS} >/dev/null - ;; - - stop) - log_info_msg "Setting hardware clock..." - hwclock --systohc ${CLOCKPARAMS} >/dev/null - evaluate_retval - ;; - - *) - echo "Usage: ${0} {start|stop}" - exit 1 - ;; - -esac - -exit 0 diff --git a/SRC/initscripts/etc/init.d/swap b/SRC/initscripts/etc/init.d/swap deleted file mode 100644 index 1198ee4..0000000 --- a/SRC/initscripts/etc/init.d/swap +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin swap -# -# Description : Swap Control Script -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: swap -# Required-Start: udev -# Should-Start: modules -# Required-Stop: localnet -# Should-Stop: -# Default-Start: S -# Default-Stop: 0 6 -# Short-Description: Mounts and unmounts swap partitions. -# Description: Mounts and unmounts swap partitions defined in -# /etc/fstab. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - log_info_msg "Activating all swap files/partitions..." - swapon -a - evaluate_retval - ;; - - stop) - log_info_msg "Deactivating all swap files/partitions..." - swapoff -a - evaluate_retval - ;; - - restart) - ${0} stop - sleep 1 - ${0} start - ;; - - status) - log_success_msg "Retrieving swap status." - swapon -s - ;; - - *) - echo "Usage: ${0} {start|stop|restart|status}" - exit 1 - ;; -esac - -exit 0 - -# End swap diff --git a/SRC/initscripts/etc/init.d/sysctl b/SRC/initscripts/etc/init.d/sysctl deleted file mode 100644 index 3c3722c..0000000 --- a/SRC/initscripts/etc/init.d/sysctl +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin sysctl -# -# Description : File uses /etc/sysctl.conf to set kernel runtime -# parameters -# -# Authors : Nathan Coulson (nathan@linuxfromscratch.org) -# Matthew Burgress (matthew@linuxfromscratch.org) -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: sysctl -# Required-Start: mountvirtfs -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Makes changes to the proc filesystem -# Description: Makes changes to the proc filesystem as defined in -# /etc/sysctl.conf. See 'man sysctl(8)'. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - if [ -f "/etc/sysctl.conf" ]; then - log_info_msg "Setting kernel runtime parameters..." - sysctl -q -p - evaluate_retval - fi - ;; - - status) - sysctl -a - ;; - - *) - echo "Usage: ${0} {start|status}" - exit 1 - ;; -esac - -exit 0 - -# End sysctl diff --git a/SRC/initscripts/etc/init.d/sysklogd b/SRC/initscripts/etc/init.d/sysklogd deleted file mode 100644 index 5717c86..0000000 --- a/SRC/initscripts/etc/init.d/sysklogd +++ /dev/null @@ -1,79 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin sysklogd -# -# Description : Sysklogd loader -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: $syslog -# Required-Start: localnet -# Should-Start: -# Required-Stop: $local_fs sendsignals -# Should-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: Starts kernel and system log daemons. -# Description: Starts kernel and system log daemons. -# /etc/fstab. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - log_info_msg "Starting system log daemon..." - parms=${SYSKLOGD_PARMS-'-m 0'} - start_daemon /sbin/syslogd $parms - evaluate_retval - - log_info_msg "Starting kernel log daemon..." - start_daemon /sbin/klogd -c 1 - evaluate_retval - ;; - - stop) - log_info_msg "Stopping kernel log daemon..." - killproc /sbin/klogd - evaluate_retval - - log_info_msg "Stopping system log daemon..." - killproc /sbin/syslogd - evaluate_retval - ;; - - reload) - log_info_msg "Reloading system log daemon config file..." - pid=`pidofproc syslogd` - kill -HUP "${pid}" - evaluate_retval - ;; - - restart) - ${0} stop - sleep 1 - ${0} start - ;; - - status) - statusproc /sbin/syslogd - statusproc klogd - ;; - - *) - echo "Usage: ${0} {start|stop|reload|restart|status}" - exit 1 - ;; -esac - -exit 0 - -# End sysklogd diff --git a/SRC/initscripts/etc/init.d/template b/SRC/initscripts/etc/init.d/template deleted file mode 100644 index 59c5f3c..0000000 --- a/SRC/initscripts/etc/init.d/template +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin scriptname -# -# Description : -# -# Authors : -# -# Version : LFS x.x -# -# Notes : -# -######################################################################## - -### BEGIN INIT INFO -# Provides: template -# Required-Start: -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: -# Default-Stop: -# Short-Description: -# Description: -# X-LFS-Provided-By: -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - log_info_msg "Starting..." - start_daemon fully_qualified_path - ;; - - stop) - log_info_msg "Stopping..." - killproc fully_qualified_path - ;; - - restart) - ${0} stop - sleep 1 - ${0} start - ;; - - *) - echo "Usage: ${0} {start|stop|restart}" - exit 1 - ;; -esac - -exit 0 - -# End scriptname diff --git a/SRC/initscripts/etc/init.d/udev b/SRC/initscripts/etc/init.d/udev deleted file mode 100644 index ba0f7c8..0000000 --- a/SRC/initscripts/etc/init.d/udev +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin udev -# -# Description : Udev cold-plugging script -# -# Authors : Zack Winkles, Alexander E. Patrakov -# DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -######################################################################## - -### BEGIN INIT INFO -# Provides: udev $time -# Required-Start: -# Should-Start: modules -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Populates /dev with device nodes. -# Description: Mounts a tempfs on /dev and starts the udevd daemon. -# Device nodes are created as defined by udev. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - log_info_msg "Populating /dev with device nodes... " - if ! grep -q '[[:space:]]sysfs' /proc/mounts; then - log_failure_msg2 - msg="FAILURE:\n\nUnable to create " - msg="${msg}devices without a SysFS filesystem\n\n" - msg="${msg}After you press Enter, this system " - msg="${msg}will be halted and powered off.\n\n" - log_info_msg "$msg" - log_info_msg "Press Enter to continue..." - wait_for_user - /etc/rc.d/init.d/halt stop - fi - - # Start the udev daemon to continually watch for, and act on, - # uevents - /sbin/udevd --daemon - - # Now traverse /sys in order to "coldplug" devices that have - # already been discovered - /sbin/udevadm trigger --action=add --type=subsystems - /sbin/udevadm trigger --action=add --type=devices - /sbin/udevadm trigger --action=change --type=devices - - # Now wait for udevd to process the uevents we triggered - if ! is_true "$OMIT_UDEV_SETTLE"; then - /sbin/udevadm settle - fi - - # If any LVM based partitions are on the system, ensure they - # are activated so they can be used. - if [ -x /sbin/vgchange ]; then /sbin/vgchange -a y >/dev/null; fi - - log_success_msg2 - ;; - - *) - echo "Usage ${0} {start}" - exit 1 - ;; -esac - -exit 0 - -# End udev diff --git a/SRC/initscripts/etc/network.conf b/SRC/initscripts/etc/network.conf deleted file mode 100644 index d0ef15e..0000000 --- a/SRC/initscripts/etc/network.conf +++ /dev/null @@ -1,4 +0,0 @@ -source-directory network.d - -auto lo -iface lo inet loopback diff --git a/SRC/initscripts/halt.default b/SRC/initscripts/halt.default new file mode 100644 index 0000000..e84884b --- /dev/null +++ b/SRC/initscripts/halt.default @@ -0,0 +1,7 @@ +# Default configuration for halt + +# set to either halt or poweroff +HALT=poweroff + +# set to no to prevent shutting down network interfaces +NETDOWN=yes diff --git a/SRC/initscripts/init-functions b/SRC/initscripts/init-functions new file mode 100644 index 0000000..2f14f59 --- /dev/null +++ b/SRC/initscripts/init-functions @@ -0,0 +1,142 @@ +#!/bin/sh + +COL52="\\033[52G" + +# killproc() [-p pidfile] pathname [signal] +# send either the specified [signal] or SIGTERM to a process + +killproc() { + local pidfile pathname pids + local signal="-TERM" + + while true; do + case "$1" in + -p) + pidfile="$2" + shift 2 + ;; + *) + pathname="$1" + signal="$2" + break + ;; + esac + done + + [ -r "$pidfile" ] && pids=$(pidofproc -p "$pidfile" "$pathname") + [ -z "$pids" ] && pids=$(pidofproc "$pathname") + [ -z "$pids" ] && [ -n "$signal" ] && return 1 + [ -z "$pids" ] && return 0 + + for pid in $pids; do + kill -0 "$pid" 2>/dev/null || continue + kill "$signal" "$pid" 2>/dev/null || continue + + for i in {1..10}; do + sleep 0.1 + + kill -0 "$pid" 2>/dev/null || break + done + + if [ -z "$signal" ]; then + kill -0 "$pid" 2>/dev/null || return 0 + kill -KILL "$pid" + fi + done + + return $? +} + +log_init_msg() { + [ -z "$1" ] && return 1 + + echo -n "$1" +} + +log_failure_msg() { + echo -e "$COL52[ FAIL ]" + + return +} + +log_success_msg() { + echo -e "$COL52[ OK ]" + + return +} + +log_warning_msg() { + echo -e "$COL52[ WARN ]" + + return +} + +# pidofproc() [-p pidfile] pathname +# return one or more PIDs for the specified pathname + +pidofproc() { + local pidfile pathname pids pidlist + + while true; do + case "$1" in + -p) + pidfile="$2" + shift 2 + ;; + *) + pathname="$1" + break + ;; + esac + done + + [ -r "$pidfile" ] && pids=$(head -1 $pidfile) || pids=$(pidof $pathname) + + for pid in $pids; do + kill -0 "$pid" 2>/dev/null && pidlist="$pidlist $pid " + done + + [ -z "$pidlist" ] && return 1 || echo $pidlist && return 0 +} + +# start_daemon() [-f] [-n nicelevel] [-p pidfile] pathname [args...] +# start a daemon + +start_daemon() { + local force pidfile pathname args + local nicelevel=0 + + while true; do + case "$1" in + -f) + force=1 + ;; + -n) + nicelevel="$2" + shift 2 + ;; + -p) + pidfile="$2" + shift 2 + ;; + *) + pathname="$1" + shift 1 + args="$@" + break + ;; + esac + done + + if [ -n "$pidfile" ]; then + pidofproc -p "$pidfile" "$pathname" >/dev/null && return 0 + + [ -f "$pidfile" ] && rm "$pidfile" + else + pidofproc "$pathname" >/dev/null && return 0 + fi + + [ -n "$args" ] && nice -n "$nicelevel" "$pathname" "$args" || \ + nice -n "$nicelevel" "$pathname" +} + diff --git a/SRC/initscripts/init.d/checkfs b/SRC/initscripts/init.d/checkfs new file mode 100755 index 0000000..9fa2781 --- /dev/null +++ b/SRC/initscripts/init.d/checkfs @@ -0,0 +1,124 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: checkfs +# Required-Start: udev swap $time hostname hwclock +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Check filesystems for errors +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + start) + if [ -f /fastboot ] || grep -qwi 'fastboot' /proc/cmdline; then + log_init_msg "Fastboot enabled - skipping file system checks" + log_success_msg + + exit 0 + fi + + log_init_msg "Mounting root file system in read-only mode" + mount -n -o remount,ro / >/dev/null + + if [ $? != 0 ]; then + log_failure_msg + echo + echo "Failed to mount root filesystem in read-only mode." + echo + echo "Press Enter to halt" + read + /etc/init.d/halt stop + else + log_success_msg + fi + + if [ -f /forcefsck ] || grep -qwi 'forcefsck' /proc/cmdline; then + checking='Checking file systems with force' + force='-f' + else + checking='Checking file systems' + fi + + case "$FSCKFIX" in + 1|y|yes) + fix='-y' + ;; + *) + fix='-a' + ;; + esac + + case "$VERBOSE" in + 1|y|yes) + echo + echo "$checking" + fsck $force $fix -A -C -T + ;; + *) + log_init_msg "$checking" + fsck $force $fix -A -T >/dev/null + ;; + esac + + status=$? + + case "$VERBOSE" in + 1|y|yes) + echo + if [ $status == 0 ]; then + exit 0 + else + log_init_msg "Filesystem issues detected" + fi + ;; + esac + + if [ $status == 0 ]; then + log_success_msg + elif [ $status != 1 ]; then + log_warning_msg + + echo + echo "WARNING: File system errors were detected and repaired." + echo + elif [ $status == 2 -o $status == 3 ]; then + log_warning_msg + + echo + echo "WARNING: File system errors were detected and repaired." + echo "The repairs require the system to be rebooted." + echo + echo "Press enter to reboot" + read + reboot -f + elif [ $status -gt 3 -a $status -lt 16 ]; then + log_failure_msg + + echo + echo "File system errors were detected, but could not be" + echo "repaired automatically." + echo + echo "Press enter to halt" + read + /etc/init.d/halt stop + else + log_failure_msg + + echo + echo "fsck exited with unexpected status: $status" + echo + exit $status + fi + ;; + *) + echo "Usage: $0 [start]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/cleanfs b/SRC/initscripts/init.d/cleanfs new file mode 100755 index 0000000..72adddb --- /dev/null +++ b/SRC/initscripts/init.d/cleanfs @@ -0,0 +1,40 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: cleanfs +# Required-Start: $local_fs +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Clean temporary directories +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions +[ -z "$CLEANDIRS" ] && exit 0 + +clean() { + [ -d $1 ] || return 1 + cd $1 && find . -xdev -mindepth 1 ! -name lost+found -delete || return 1 + + return 0 +} + +case "$1" in + start) + log_init_msg "Cleaning temporary files" + + for dir in $CLEANDIRS; do + clean $dir || error=1 + done + + [ -z $error ] && log_success_msg || log_failure_msg + ;; + *) + echo "Usage: $0 [start]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/halt b/SRC/initscripts/init.d/halt new file mode 100755 index 0000000..a1596ca --- /dev/null +++ b/SRC/initscripts/init.d/halt @@ -0,0 +1,39 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: halt +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: +# Default-Stop: 0 +# Short-Description: Halt the system +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions +[ -r /etc/default/halt ] && . /etc/default/halt + +case "$1" in + stop) + poweroff='-p' + netdown='-i' + + if [ "$HALT" == "halt" ]; then + poweroff='' + fi + + if [ "$NETDOWN" == "no" ]; then + netdown='' + fi + + log_init_msg "Halting system" + halt -d -f $netdown $poweroff + ;; + *) + echo "Usage: [stop]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/hostname b/SRC/initscripts/init.d/hostname new file mode 100755 index 0000000..e1e801a --- /dev/null +++ b/SRC/initscripts/init.d/hostname @@ -0,0 +1,34 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: hostname +# Required-Start: $local_fs +# Required-Stop: $local_fs +# Should-Start: +# Should-Stop +# Default-Start: S +# Default-Stop: +# Short-Description: Set hostname to value in /etc/hostname +# Description: Set hostname to value in /etc/hostname if +# present, otherwise set hostname to localhost +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions +[ -r /etc/hostname ] && HOSTNAME=`cat /etc/hostname` +[ -z "$HOSTNAME" ] && HOSTNAME='localhost' + +case "$1" in + start|restart) + log_init_msg "Setting hostname to $HOSTNAME" + hostname $HOSTNAME && log_success_msg || log_failure_msg + ;; + status) + echo "Current hostname: $(hostname)" + ;; + *) + echo "Usage: $0 [start|restart|status]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/hwclock b/SRC/initscripts/init.d/hwclock new file mode 100755 index 0000000..9a0da51 --- /dev/null +++ b/SRC/initscripts/init.d/hwclock @@ -0,0 +1,57 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: hwclock +# Required-Start: $local_fs +# Required-Stop: +# Should-Start: modules +# Should-Stop: $syslog +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Synchronize the system and hardware clocks +# Description: During boot sync the hardware clock to the +# system clock if udev is not running. During +# shutdown do the reverse +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions + +case "$UTC" in + 0|n|no) + ZONE="--localtime" + ;; + *) + ZONE="--utc" + ;; +esac + +case "$1" in + start) + if [ ! -f /etc/adjtime ]; then + printf "0.0 0 0.0\n0\nUTC\n" > /etc/adjtime + fi + + if [ -d /run/udev ] || [ -d /dev/.udev ]; then + exit 0; + fi + + log_init_msg "Setting the system clock" + hwclock --hctosys $ZONE >/dev/null && log_success_msg || log_failure_msg + ;; + stop|restart) + log_init_msg "Setting hardware clock" + hwclock --systohc $ZONE >/dev/null && log_success_msg || log_failure_msg + ;; + status) + echo -n "System clock: " + date +'%Y-%m-%d %H:%M:%S' + echo -n "Hardware clock: " + hwclock --show $ZONE + ;; + *) + echo "Usage: $0 [start|stop|restart]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/localnet b/SRC/initscripts/init.d/localnet new file mode 100755 index 0000000..9bc72d3 --- /dev/null +++ b/SRC/initscripts/init.d/localnet @@ -0,0 +1,37 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: localnet +# Required-Start: $local_fs +# Required-Stop: $local_fs +# Should-Start: $syslog +# Should-Stop: $syslog +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Start and configure loopback interface +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + start) + log_init_msg "Bringing up loopback interface" + ifup lo && log_success_msg || log_failure_msg + ;; + stop) + log_init_msg "Bringing down loopback interface" + ifdown lo && log_success_msg || log_failure_msg + ;; + + reload|restart) + log_init_msg "Restarting loopback interface" + ifreload lo && log_success_msg || log_failure_msg + ;; + + *) + echo "Usage: $0 [start|stop|reload|restart]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/modules b/SRC/initscripts/init.d/modules new file mode 100755 index 0000000..13bd418 --- /dev/null +++ b/SRC/initscripts/init.d/modules @@ -0,0 +1,51 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: modules +# Required-Start: mountvirtfs sysctl +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Load modules listed in /etc/modules.conf +# X-Required: true +### END INIT INFO + +CONF=/etc/modules.conf + +[ -r $CONF ] || exit 0 +[ -e /proc/modules ] || exit 0 +egrep -qv '^(\s*#|$)' $CONF || exit 0 + +. /lib/lsb/init-functions + +isloaded () { + grep -q "^$1 " /proc/modules + return $? +} + +case "$1" in + start|restart) + log_init_msg "Loading modules" + + while read module args; do + echo $module | egrep -qv '^(\s*#|$)' || continue + modprobe -q ${module} ${args} || failed=1 + done < $CONF + + [ -z $failed ] && log_success_msg || log_failure_msg + ;; + status) + while read module args; do + echo $module | egrep -qv '^(\s*#|$)' || continue + log_init_msg "Checking $module" + isloaded $module && log_success_msg || log_failure_msg + done < $CONF + ;; + *) + echo "Usage: $0 [start|restart|status]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/mountfs b/SRC/initscripts/init.d/mountfs new file mode 100755 index 0000000..249e643 --- /dev/null +++ b/SRC/initscripts/init.d/mountfs @@ -0,0 +1,86 @@ +#!/bin/sh +######################################################################## +# Begin mountfs +# +# Description : File System Mount Script +# +# Authors : Gerard Beekmans - gerard@linuxfromscratch.org +# DJ Lucas - dj@linuxfromscratch.org +# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org +# +# Version : LFS 7.0 +# +######################################################################## + +### BEGIN INIT INFO +# Provides: $local_fs +# Required-Start: udev checkfs +# Should-Start: +# Required-Stop: swap +# Should-Stop: +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Mounts/unmounts local filesystems defined in /etc/fstab. +# Description: Remounts root filesystem read/write and mounts all +# remaining local filesystems defined in /etc/fstab on +# start. Remounts root filesystem read-only and unmounts +# remaining filesystems on stop. +# X-LFS-Provided-By: LFS +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions + +#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# +# needs work!! +# probably need to split up +# separate scripts for / and +# network filesystems +# +# Ok, so network filesystems +# init scripts should be included +# as part of the package. This +# script should only be for +# standard local filesystems +# +#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +case "$1" in + start) + log_init_msg "Remounting root file system in read-write mode" + mount -o remount,rw / >/dev/null && log_success_msg || log_failure_msg + + # Remove fsck-related file system watermarks. + rm -f /fastboot /forcefsck + + # Make sure /dev/pts exists +# mkdir -p /dev/pts + + # This will mount all filesystems that do not have _netdev in + # their option list. _netdev denotes a network filesystem. + + log_init_msg "Mounting remaining file systems" + mount -a -O no_netdev >/dev/null && log_success_msg || log_failure_msg + exit $failed + ;; + stop) + # Don't unmount virtual file systems like /run + log_init_msg "Unmounting all file systems" + umount -a -d -r -t notmpfs,nosysfs,nodevtmpfs,noproc,nodevpts >/dev/null && \ + log_success_msg || log_failure_msg + + # Make sure / is mounted read only (umount bug) + mount -o remount,ro / + + # Make all LVM volume groups unavailable, if appropriate + # This fails if swap or / are on an LVM partition + #if [ -x /sbin/vgchange ]; then /sbin/vgchange -an > /dev/null; fi + ;; + *) + echo "Usage: $0 [start|stop]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/mountvirtfs b/SRC/initscripts/init.d/mountvirtfs new file mode 100755 index 0000000..6524739 --- /dev/null +++ b/SRC/initscripts/init.d/mountvirtfs @@ -0,0 +1,128 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: mountvirtfs +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Mounts virtual file systems +# Description: Mount /sys and /proc kernel filesystems, also +# mount /run (tmpfs) and /dev (devtmpfs) +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions + +calcsize () { + RAM=$(($(grep MemTotal /proc/meminfo|grep -o '[0-9]*')+0)) + SWAP=$(($(grep SWAPTotal /proc/meminfo|grep -o '[0-9]*')+0)) + VM=$((RAM+SWAP)) + + case "$1" in + *%*) + SIZE=$(((VM/100) * ${1%\%})) + ;; + *) + SIZE=${1} + ;; + esac + + echo "$SIZE" +} + +mountdev () { + KB=$(calcsize ${DEVSIZE:-10240}) + + if ! mountpoint -q /run; then + mount -o rw,relatime,size=${KB}k,mode=755 -t devtmpfs devtmpfs /dev || \ + return 1 + else + mount -o remount,rw,relatime,size=${KB}k,mode=755 -t devtmpfs devtmpfs \ + /dev || return 1 + fi + + return 0 +} + +mountproc () { + if ! mountpoint -q /proc; then + mount -o nosuid,noexec,nodev -t proc proc /proc || return 1 + else + mount -o remount,nosuid,noexec,nodev -t proc proc /proc || return 1 + fi + + return 0 +} + +mountpts () { + if [ ! -d /dev/pts ]; then + mkdir /dev/pts || return 1 + fi + + if ! mountpoint -q /dev/pts; then + mount -o rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 \ + -t devpts devpts /dev/pts || return 1 + fi + + return 0 +} + +mountrun () { + KB=$(calcsize ${RUNSIZE:-10%}) + + if ! mountpoint -q /run; then + mount -o rw,nosuid,relatime,size=${KB}k,mode=755 -t tmpfs tmpfs /run || \ + return 1 + else + mount -o remount,rw,nosuid,relatime,size=${KB}k,mode=755 -t tmpfs tmpfs \ + /run || return 1 + fi + + mkdir -p /run/lock /run/shm || return 1 + chmod 1777 /run/shm || return 1 + + if grep -q '^utmp:' /etc/group; then + chmod 664 /run/utmp + chgrp utmp /run/utmp + fi + + return 0 +} + +mountsys () { + if ! mountpoint -q /sys; then + mount -o nosuid,noexec,nodev -t sysfs sys /sys || return 1 + else + mount -o remount,nosuid,noexec,nodev -t sysfs sys /sys || return 1 + fi + + return 0 +} + +case "$1" in + start|restart) + log_init_msg "Mounting virtual file systems" + + for dir in dev pts proc run sys; do + mount$dir || error=1 + done + + ln -sfn /run/shm /dev/shm + + [ -z $error ] && log_success_msg || log_failure_msg + ;; + status) + for dir in /dev /proc /run /sys; do + log_init_msg "Checking $dir" + mountpoint -q $dir && log_success_msg || log_failure_msg + done + ;; + *) + echo "Usage: $0 [start|restart|status]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/rc b/SRC/initscripts/init.d/rc new file mode 100755 index 0000000..120fcda --- /dev/null +++ b/SRC/initscripts/init.d/rc @@ -0,0 +1,58 @@ +#!/bin/sh + +. /lib/lsb/init-functions + +trap "" INT QUIT TSTP + +print_snap() { + echo " + _ _ + | (_) + ___ _ __ __ _ _ __ | |_ _ __ _ _ _ _ + / __| '_ \ / _' | '_ \| | | '_ \| | | \ \/ / + \__ \ | | | (_| | |_) | | | | | | |_| |> < + |___/_| |_|\__,_| .__/|_|_|_| |_|\__,_/_/\_\ + | | + |_| + + A GNU/Linux System + +" +} + +case "$1" in + S|1|2|3|4|5|6|0) + if [ "$RUNLEVEL" == "S" ]; then + set -a + [ -r /etc/default/rcS ] && . /etc/default/rcS + set +a + dmesg -n "${LOGLEVEL:-7}" + print_snap + fi + + if [ "$PREVLEVEL" != "N" ]; then + for script in $(ls /etc/rc${RUNLEVEL}.d/K* 2>/dev/null); do + name=${script#/etc/rc${RUNLEVEL}.d/S[0-9][0-9]} + prevscript="/etc/rc${PREVLEVEL}.d/S[0-9][0-9]$name" + + [ -f $prevscript ] && continue + + $script stop + done + fi + + for script in $(ls /etc/rc${RUNLEVEL}.d/S* 2>/dev/null); do + name=${script#/etc/rc${RUNLEVEL}.d/S[0-9][0-9]} + prevscript="/etc/rc${PREVLEVEL}.d/S[0-9][0-9]$name" + + [ -f $prevscript ] && continue + + $script start + done + ;; + *) + echo "Usage: $0 " + + exit 1 + ;; +esac diff --git a/SRC/initscripts/init.d/reboot b/SRC/initscripts/init.d/reboot new file mode 100755 index 0000000..5780a54 --- /dev/null +++ b/SRC/initscripts/init.d/reboot @@ -0,0 +1,29 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: reboot +# Required-Start: +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: +# Default-Stop: 6 +# Short-Description: Reboot the system +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + stop) + log_init_msg "Restarting system" + reboot -d -f -i + ;; + + *) + echo "Usage: $0 [start]" + exit 1 + ;; + +esac + +exit 0 diff --git a/SRC/initscripts/init.d/sendsignals b/SRC/initscripts/init.d/sendsignals new file mode 100755 index 0000000..194816e --- /dev/null +++ b/SRC/initscripts/init.d/sendsignals @@ -0,0 +1,45 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: sendsignals +# Required-Start: +# Required-Stop: $local_fs swap localnet +# Should-Start: +# Should-Stop: +# Default-Start: +# Default-Stop: 0 6 +# Short-Description: Kill remaining processes +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + stop) + log_init_msg "Sending all processes the TERM signal" + killall5 -15 + + for i in 1 2 3 4 5 6 7 8 9 10; do + if ! killall5 -18; then + success=1 + break; + fi + done + + if [ -z "$success" ]; then + log_init_msg "Sending all processes the KILL signal" + killall5 -9 + + if [ "$?" == 0 -o "$?" == 2 ]; then + success=1 + fi + fi + + [ -z "$success" ] && log_failure_msg || log_success_msg + ;; + *) + echo "Usage: $0 [stop]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/swap b/SRC/initscripts/init.d/swap new file mode 100755 index 0000000..7409bc9 --- /dev/null +++ b/SRC/initscripts/init.d/swap @@ -0,0 +1,39 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: swap +# Required-Start: udev +# Required-Stop: +# Should-Start: modules +# Should-Stop: +# Default-Start: S +# Default-Stop: 0 6 +# Short-Description: Mount and unmount swap partitions +# X-Required: true +### END INIT INFO + +. /lib/lsb/init-functions + +case "$1" in + start) + log_init_msg "Activating swap files/partitions" + swapon -a && log_success_msg || log_failure_msg + ;; + stop) + log_init_msg "Deactivating swap files/partitions" + swapoff -a && log_success_msg || log_failure_msg + ;; + restart) + ${0} stop + sleep 1 + ${0} start + ;; + status) + swapon --show + ;; + *) + echo "Usage: $0 [start|stop|restart|status]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/init.d/sysctl b/SRC/initscripts/init.d/sysctl new file mode 100755 index 0000000..0fc29e3 --- /dev/null +++ b/SRC/initscripts/init.d/sysctl @@ -0,0 +1,38 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: sysctl +# Required-Start: mountvirtfs +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Load kernel parameters listed in /etc/sysctl.conf +# X-Required: true +### END INIT INFO + +CONF=/etc/sysctl.conf +[ -r $CONF ] || exit 0 + +. /lib/lsb/init-functions + +case "$1" in + start|restart) + log_init_msg "Setting kernel parameters" + sysctl -q -p && log_success_msg || log_failed_msg + ;; + status) + grep -v '^#' $CONF | while IFS= read -r line; do + param=`echo -n $line|sed 's/\s\+=.*//'` + realval=`sysctl $param|sed 's/.*=\s\+//'` + + echo "$param = $realval" + done + ;; + *) + echo "Usage: $0 [start|restart|status]" + exit 1 + ;; +esac + +exit 0 diff --git a/SRC/initscripts/lib/lsb/init-functions b/SRC/initscripts/lib/lsb/init-functions deleted file mode 100644 index dd7a0a4..0000000 --- a/SRC/initscripts/lib/lsb/init-functions +++ /dev/null @@ -1,786 +0,0 @@ -#!/bin/sh -######################################################################## -# -# Begin /lib/lsb/init-funtions -# -# Description : Run Level Control Functions -# -# Authors : Gerard Beekmans - gerard@linuxfromscratch.org -# : DJ Lucas - dj@linuxfromscratch.org -# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org -# -# Version : LFS 7.0 -# -# Notes : With code based on Matthias Benkmann's simpleinit-msb -# http://winterdrache.de/linux/newboot/index.html -# -# The file should be located in /lib/lsb -# -######################################################################## - -## Environmental setup -# Setup default values for environment -umask 022 -export PATH="/bin:/usr/bin:/sbin:/usr/sbin" - -## Screen Dimensions -# Find current screen size -if [ -z "${COLUMNS}" ]; then - COLUMNS=$(stty size) - COLUMNS=${COLUMNS##* } -fi - -# When using remote connections, such as a serial port, stty size returns 0 -if [ "${COLUMNS}" = "0" ]; then - COLUMNS=80 -fi - -## Measurements for positioning result messages -COL=$((${COLUMNS} - 8)) -WCOL=$((${COL} - 2)) - -## Set Cursor Position Commands, used via echo -SET_COL="\\033[${COL}G" # at the $COL char -SET_WCOL="\\033[${WCOL}G" # at the $WCOL char -CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char -CURS_ZERO="\\033[0G" - -## Set color commands, used via echo -# Please consult `man console_codes for more information -# under the "ECMA-48 Set Graphics Rendition" section -# -# Warning: when switching from a 8bit to a 9bit font, -# the linux console will reinterpret the bold (1;) to -# the top 256 glyphs of the 9bit font. This does -# not affect framebuffer consoles - -NORMAL="\\033[0;39m" # Standard console grey -SUCCESS="\\033[1;32m" # Success is green -WARNING="\\033[1;33m" # Warnings are yellow -FAILURE="\\033[1;31m" # Failures are red -INFO="\\033[1;36m" # Information is light cyan -BRACKET="\\033[1;34m" # Brackets are blue - -# Use a colored prefix -BMPREFIX=" " -SUCCESS_PREFIX="${SUCCESS} * ${NORMAL}" -FAILURE_PREFIX="${FAILURE}*****${NORMAL}" -WARNING_PREFIX="${WARNING} *** ${NORMAL}" - -SUCCESS_SUFFIX="${BRACKET}[${SUCCESS} OK ${BRACKET}]${NORMAL}" -FAILURE_SUFFIX="${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}" -WARNING_SUFFIX="${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}" - -BOOTLOG=/run/bootlog -KILLDELAY=3 - -################################################################################ -# start_daemon() # -# Usage: start_daemon [-f] [-n nicelevel] [-p pidfile] pathname [args...] # -# # -# Purpose: This runs the specified program as a daemon # -# # -# Inputs: -f: (force) run the program even if it is already running. # -# -n nicelevel: specify a nice level. See 'man nice(1)'. # -# -p pidfile: use the specified file to determine PIDs. # -# pathname: the complete path to the specified program # -# args: additional arguments passed to the program (pathname) # -# # -# Return values (as defined by LSB exit codes): # -# 0 - program is running or service is OK # -# 1 - generic or unspecified error # -# 2 - invalid or excessive argument(s) # -# 5 - program is not installed # -################################################################################ -start_daemon() -{ - local force="" - local nice="0" - local pidfile="" - local pidlist="" - local retval="" - - # Process arguments - while true - do - case "${1}" in - - -f) - force="1" - shift 1 - ;; - - -n) - nice="${2}" - shift 2 - ;; - - -p) - pidfile="${2}" - shift 2 - ;; - - -*) - return 2 - ;; - - *) - program="${1}" - break - ;; - esac - done - - # Check for a valid program - if [ ! -e "${program}" ]; then return 5; fi - - # Execute - if [ -z "${force}" ]; then - if [ -z "${pidfile}" ]; then - # Determine the pid by discovery - pidlist=`pidofproc "${1}"` - retval="${?}" - else - # The PID file contains the needed PIDs - # Note that by LSB requirement, the path must be given to pidofproc, - # however, it is not used by the current implementation or standard. - pidlist=`pidofproc -p "${pidfile}" "${1}"` - retval="${?}" - fi - - # Return a value ONLY - # It is the init script's (or distribution's functions) responsibilty - # to log messages! - case "${retval}" in - - 0) - # Program is already running correctly, this is a - # successful start. - return 0 - ;; - - 1) - # Program is not running, but an invalid pid file exists - # remove the pid file and continue - rm -f "${pidfile}" - ;; - - 3) - # Program is not running and no pidfile exists - # do nothing here, let start_deamon continue. - ;; - - *) - # Others as returned by status values shall not be interpreted - # and returned as an unspecified error. - return 1 - ;; - esac - fi - - # Do the start! - nice -n "${nice}" "${@}" -} - -################################################################################ -# killproc() # -# Usage: killproc [-p pidfile] pathname [signal] # -# # -# Purpose: Send control signals to running processes # -# # -# Inputs: -p pidfile, uses the specified pidfile # -# pathname, pathname to the specified program # -# signal, send this signal to pathname # -# # -# Return values (as defined by LSB exit codes): # -# 0 - program (pathname) has stopped/is already stopped or a # -# running program has been sent specified signal and stopped # -# successfully # -# 1 - generic or unspecified error # -# 2 - invalid or excessive argument(s) # -# 5 - program is not installed # -# 7 - program is not running and a signal was supplied # -################################################################################ -killproc() -{ - local pidfile - local program - local prefix - local progname - local signal="-TERM" - local fallback="-KILL" - local nosig - local pidlist - local retval - local pid - local delay="30" - local piddead - local dtime - - # Process arguments - while true; do - case "${1}" in - -p) - pidfile="${2}" - shift 2 - ;; - - *) - program="${1}" - if [ -n "${2}" ]; then - signal="${2}" - fallback="" - else - nosig=1 - fi - - # Error on additional arguments - if [ -n "${3}" ]; then - return 2 - else - break - fi - ;; - esac - done - - # Check for a valid program - if [ ! -e "${program}" ]; then return 5; fi - - # Check for a valid signal - check_signal "${signal}" - if [ "${?}" -ne "0" ]; then return 2; fi - - # Get a list of pids - if [ -z "${pidfile}" ]; then - # determine the pid by discovery - pidlist=`pidofproc "${1}"` - retval="${?}" - else - # The PID file contains the needed PIDs - # Note that by LSB requirement, the path must be given to pidofproc, - # however, it is not used by the current implementation or standard. - pidlist=`pidofproc -p "${pidfile}" "${1}"` - retval="${?}" - fi - - # Return a value ONLY - # It is the init script's (or distribution's functions) responsibilty - # to log messages! - case "${retval}" in - - 0) - # Program is running correctly - # Do nothing here, let killproc continue. - ;; - - 1) - # Program is not running, but an invalid pid file exists - # Remove the pid file. - rm -f "${pidfile}" - - # This is only a success if no signal was passed. - if [ -n "${nosig}" ]; then - return 0 - else - return 7 - fi - ;; - - 3) - # Program is not running and no pidfile exists - # This is only a success if no signal was passed. - if [ -n "${nosig}" ]; then - return 0 - else - return 7 - fi - ;; - - *) - # Others as returned by status values shall not be interpreted - # and returned as an unspecified error. - return 1 - ;; - esac - - # Perform different actions for exit signals and control signals - check_sig_type "${signal}" - - if [ "${?}" -eq "0" ]; then # Signal is used to terminate the program - - # Account for empty pidlist (pid file still exists and no - # signal was given) - if [ "${pidlist}" != "" ]; then - - # Kill the list of pids - for pid in ${pidlist}; do - - kill -0 "${pid}" 2> /dev/null - - if [ "${?}" -ne "0" ]; then - # Process is dead, continue to next and assume all is well - continue - else - kill "${signal}" "${pid}" 2> /dev/null - - # Wait up to ${delay}/10 seconds to for "${pid}" to - # terminate in 10ths of a second - - while [ "${delay}" -ne "0" ]; do - kill -0 "${pid}" 2> /dev/null || piddead="1" - if [ "${piddead}" = "1" ]; then break; fi - sleep 0.1 - delay="$(( ${delay} - 1 ))" - done - - # If a fallback is set, and program is still running, then - # use the fallback - if [ -n "${fallback}" -a "${piddead}" != "1" ]; then - kill "${fallback}" "${pid}" 2> /dev/null - sleep 1 - # Check again, and fail if still running - kill -0 "${pid}" 2> /dev/null && return 1 - fi - fi - done - fi - - # Check for and remove stale PID files. - if [ -z "${pidfile}" ]; then - # Find the basename of $program - prefix=`echo "${program}" | sed 's/[^/]*$//'` - progname=`echo "${program}" | sed "s@${prefix}@@"` - - if [ -e "/var/run/${progname}.pid" ]; then - rm -f "/var/run/${progname}.pid" 2> /dev/null - fi - else - if [ -e "${pidfile}" ]; then rm -f "${pidfile}" 2> /dev/null; fi - fi - - # For signals that do not expect a program to exit, simply - # let kill do its job, and evaluate kill's return for value - - else # check_sig_type - signal is not used to terminate program - for pid in ${pidlist}; do - kill "${signal}" "${pid}" - if [ "${?}" -ne "0" ]; then return 1; fi - done - fi -} - -################################################################################ -# pidofproc() # -# Usage: pidofproc [-p pidfile] pathname # -# # -# Purpose: This function returns one or more pid(s) for a particular daemon # -# # -# Inputs: -p pidfile, use the specified pidfile instead of pidof # -# pathname, path to the specified program # -# # -# Return values (as defined by LSB status codes): # -# 0 - Success (PIDs to stdout) # -# 1 - Program is dead, PID file still exists (remaining PIDs output) # -# 3 - Program is not running (no output) # -################################################################################ -pidofproc() -{ - local pidfile - local program - local prefix - local progname - local pidlist - local lpids - local exitstatus="0" - - # Process arguments - while true; do - case "${1}" in - - -p) - pidfile="${2}" - shift 2 - ;; - - *) - program="${1}" - if [ -n "${2}" ]; then - # Too many arguments - # Since this is status, return unknown - return 4 - else - break - fi - ;; - esac - done - - # If a PID file is not specified, try and find one. - if [ -z "${pidfile}" ]; then - # Get the program's basename - prefix=`echo "${program}" | sed 's/[^/]*$//'` - - if [ -z "${prefix}" ]; then - progname="${program}" - else - progname=`echo "${program}" | sed "s@${prefix}@@"` - fi - - # If a PID file exists with that name, assume that is it. - if [ -e "/var/run/${progname}.pid" ]; then - pidfile="/var/run/${progname}.pid" - fi - fi - - # If a PID file is set and exists, use it. - if [ -n "${pidfile}" -a -e "${pidfile}" ]; then - - # Use the value in the first line of the pidfile - pidlist=`/bin/head -n1 "${pidfile}"` - # This can optionally be written as 'sed 1q' to repalce 'head -n1' - # should LFS move /bin/head to /usr/bin/head - else - # Use pidof - pidlist=`pidof "${program}"` - fi - - # Figure out if all listed PIDs are running. - for pid in ${pidlist}; do - kill -0 ${pid} 2> /dev/null - - if [ "${?}" -eq "0" ]; then - lpids="${lpids}${pid} " - else - exitstatus="1" - fi - done - - if [ -z "${lpids}" -a ! -f "${pidfile}" ]; then - return 3 - else - echo "${lpids}" - return "${exitstatus}" - fi -} - -################################################################################ -# statusproc() # -# Usage: statusproc [-p pidfile] pathname # -# # -# Purpose: This function prints the status of a particular daemon to stdout # -# # -# Inputs: -p pidfile, use the specified pidfile instead of pidof # -# pathname, path to the specified program # -# # -# Return values: # -# 0 - Status printed # -# 1 - Input error. The daemon to check was not specified. # -################################################################################ -statusproc() -{ - local pidfile - local pidlist - - if [ "${#}" = "0" ]; then - echo "Usage: statusproc [-p pidfle] {program}" - exit 1 - fi - - # Process arguments - while true; do - case "${1}" in - - -p) - pidfile="${2}" - shift 2 - ;; - - *) - if [ -n "${2}" ]; then - echo "Too many arguments" - return 1 - else - break - fi - ;; - esac - done - - if [ -n "${pidfile}" ]; then - pidlist=`pidofproc -p "${pidfile}" $@` - else - pidlist=`pidofproc $@` - fi - - # Trim trailing blanks - pidlist=`echo "${pidlist}" | sed -r 's/ +$//'` - - base="${1##*/}" - - if [ -n "${pidlist}" ]; then - /bin/echo -e "${INFO}${base} is running with Process" \ - "ID(s) ${pidlist}.${NORMAL}" - else - if [ -n "${base}" -a -e "/var/run/${base}.pid" ]; then - /bin/echo -e "${WARNING}${1} is not running but" \ - "/var/run/${base}.pid exists.${NORMAL}" - else - if [ -n "${pidfile}" -a -e "${pidfile}" ]; then - /bin/echo -e "${WARNING}${1} is not running" \ - "but ${pidfile} exists.${NORMAL}" - else - /bin/echo -e "${INFO}${1} is not running.${NORMAL}" - fi - fi - fi -} - -################################################################################ -# timespec() # -# # -# Purpose: An internal utility function to format a timestamp # -# a boot log file. Sets the STAMP variable. # -# # -# Return value: Not used # -################################################################################ -timespec() -{ - STAMP="$(echo `date +"%b %d %T %:z"` `hostname`) " - return 0 -} - -################################################################################ -# log_success_msg() # -# Usage: log_success_msg ["message"] # -# # -# Purpose: Print a successful status message to the screen and # -# a boot log file. # -# # -# Inputs: $@ - Message # -# # -# Return values: Not used # -################################################################################ -log_success_msg() -{ - /bin/echo -n -e "${BMPREFIX}${@}" - /bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}" - - # Strip non-printable characters from log file - logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` - - timespec - /bin/echo -e "${STAMP} ${logmessage} OK" >> ${BOOTLOG} - - return 0 -} - -log_success_msg2() -{ - /bin/echo -n -e "${BMPREFIX}${@}" - /bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}" - - echo " OK" >> ${BOOTLOG} - - return 0 -} - -################################################################################ -# log_failure_msg() # -# Usage: log_failure_msg ["message"] # -# # -# Purpose: Print a failure status message to the screen and # -# a boot log file. # -# # -# Inputs: $@ - Message # -# # -# Return values: Not used # -################################################################################ -log_failure_msg() -{ - /bin/echo -n -e "${BMPREFIX}${@}" - /bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}" - - # Strip non-printable characters from log file - - timespec - logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` - /bin/echo -e "${STAMP} ${logmessage} FAIL" >> ${BOOTLOG} - - return 0 -} - -log_failure_msg2() -{ - /bin/echo -n -e "${BMPREFIX}${@}" - /bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}" - - echo "FAIL" >> ${BOOTLOG} - - return 0 -} - -################################################################################ -# log_warning_msg() # -# Usage: log_warning_msg ["message"] # -# # -# Purpose: Print a warning status message to the screen and # -# a boot log file. # -# # -# Return values: Not used # -################################################################################ -log_warning_msg() -{ - /bin/echo -n -e "${BMPREFIX}${@}" - /bin/echo -e "${CURS_ZERO}${WARNING_PREFIX}${SET_COL}${WARNING_SUFFIX}" - - # Strip non-printable characters from log file - logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` - timespec - /bin/echo -e "${STAMP} ${logmessage} WARN" >> ${BOOTLOG} - - return 0 -} - -################################################################################ -# log_info_msg() # -# Usage: log_info_msg message # -# # -# Purpose: Print an information message to the screen and # -# a boot log file. Does not print a trailing newline character. # -# # -# Return values: Not used # -################################################################################ -log_info_msg() -{ - /bin/echo -n -e "${BMPREFIX}${@}" - - # Strip non-printable characters from log file - logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` - timespec - /bin/echo -n -e "${STAMP} ${logmessage}" >> ${BOOTLOG} - - return 0 -} - -log_info_msg2() -{ - /bin/echo -n -e "${@}" - - # Strip non-printable characters from log file - logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'` - /bin/echo -n -e "${logmessage}" >> ${BOOTLOG} - - return 0 -} - -################################################################################ -# evaluate_retval() # -# Usage: Evaluate a return value and print success or failyure as appropriate # -# # -# Purpose: Convenience function to terminate an info message # -# # -# Return values: Not used # -################################################################################ -evaluate_retval() -{ - local error_value="${?}" - - if [ ${error_value} = 0 ]; then - log_success_msg2 - else - log_failure_msg2 - fi -} - -################################################################################ -# check_signal() # -# Usage: check_signal [ -{signal} | {signal} ] # -# # -# Purpose: Check for a valid signal. This is not defined by any LSB draft, # -# however, it is required to check the signals to determine if the # -# signals chosen are invalid arguments to the other functions. # -# # -# Inputs: Accepts a single string value in the form or -{signal} or {signal} # -# # -# Return values: # -# 0 - Success (signal is valid # -# 1 - Signal is not valid # -################################################################################ -check_signal() -{ - local valsig - - # Add error handling for invalid signals - valsig="-ALRM -HUP -INT -KILL -PIPE -POLL -PROF -TERM -USR1 -USR2" - valsig="${valsig} -VTALRM -STKFLT -PWR -WINCH -CHLD -URG -TSTP -TTIN" - valsig="${valsig} -TTOU -STOP -CONT -ABRT -FPE -ILL -QUIT -SEGV -TRAP" - valsig="${valsig} -SYS -EMT -BUS -XCPU -XFSZ -0 -1 -2 -3 -4 -5 -6 -8 -9" - valsig="${valsig} -11 -13 -14 -15" - - echo "${valsig}" | grep -- " ${1} " > /dev/null - - if [ "${?}" -eq "0" ]; then - return 0 - else - return 1 - fi -} - -################################################################################ -# check_sig_type() # -# Usage: check_signal [ -{signal} | {signal} ] # -# # -# Purpose: Check if signal is a program termination signal or a control signal # -# This is not defined by any LSB draft, however, it is required to # -# check the signals to determine if they are intended to end a # -# program or simply to control it. # -# # -# Inputs: Accepts a single string value in the form or -{signal} or {signal} # -# # -# Return values: # -# 0 - Signal is used for program termination # -# 1 - Signal is used for program control # -################################################################################ -check_sig_type() -{ - local valsig - - # The list of termination signals (limited to generally used items) - valsig="-ALRM -INT -KILL -TERM -PWR -STOP -ABRT -QUIT -2 -3 -6 -9 -14 -15" - - echo "${valsig}" | grep -- " ${1} " > /dev/null - - if [ "${?}" -eq "0" ]; then - return 0 - else - return 1 - fi -} - -################################################################################ -# wait_for_user() # -# # -# Purpose: Wait for the user to respond if not a headless system # -# # -################################################################################ -wait_for_user() -{ - # Wait for the user by default - [ "${HEADLESS=0}" = "0" ] && read ENTER - return 0 -} - -################################################################################ -# is_true() # -# # -# Purpose: Utility to test if a variable is true | yes | 1 # -# # -################################################################################ -is_true() -{ - [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] || [ "$1" = "y" ] || - [ "$1" = "t" ] -} - -# End /lib/lsb/init-functions diff --git a/SRC/initscripts/etc/modules.conf b/SRC/initscripts/modules.conf similarity index 100% rename from SRC/initscripts/etc/modules.conf rename to SRC/initscripts/modules.conf diff --git a/SRC/initscripts/rcS.default b/SRC/initscripts/rcS.default new file mode 100644 index 0000000..a24ee79 --- /dev/null +++ b/SRC/initscripts/rcS.default @@ -0,0 +1,23 @@ +# Default settings for early boot (sourced for scripts in /etc/rcS.d) + +# Valid LOGLEVEL values range from 1 to 8. 1 will limit kernel +# messages on the console to emergencies only while 8 enables +# full verbosity +LOGLEVEL=1 + +# Set to yes to enable more verbose output for scripts that support it +# VERBOSE=no + +# checkfs - set to yes to pass -y to fsck and automatically repair all errors +# FSCKFIX=no + +# cleanfs - space separated list of temp directories to be cleaned on boot +CLEANDIRS="/tmp" + +# hwclock - set to no if the hardware clock is not UTC (default is yes) +# UTC=yes + +# mountvirtfs - These values determine the sizes of temporary filesystems +# Values can be in kilobytes or as a percentage +# DEVSIZE=10240 +# RUNZISE=10% diff --git a/SRC/initscripts/update-rc b/SRC/initscripts/update-rc new file mode 100755 index 0000000..96b6413 --- /dev/null +++ b/SRC/initscripts/update-rc @@ -0,0 +1,355 @@ +#!/usr/bin/perl + +use warnings; +use strict; + +use Data::Dumper; + +use constant INITDIR => '/etc/init.d'; +use constant RUNLEVELS => qw( S 1 2 3 4 5 6 0 ); +use constant SVCKEYS => qw( Provides Required-Start Required-Stop Should-Start + Should-Stop Default-Start Default-Stop Short-Description Description ); +use constant VERBOSE => eval { + for ( my $i = 0; $i <= $#ARGV; $i++ ) { + if ( $ARGV[$i] eq '-v' || $ARGV[$i] eq '--verbose' ) { + splice( @ARGV, $i, 1 ); + + return( 1 ); + } + } + + return( 0 ); + }; + +sub chkstatus { + my $svcname = shift; + my $status = {}; + + foreach my $rlvl ( RUNLEVELS ) { + my $dir = "/etc/rc$rlvl.d"; + + opendir( DIR, $dir ); + + while ( readdir( DIR ) ) { + if ( $_ =~ /^([KS])(\d+)$svcname$/ ) { + $status->{$rlvl} = $1; + } + } + + close( DIR ); + } + + return( $status ); + } + +sub error { + my $status = shift; + my $errstr = shift; + my $level = 1; + my @stack = (); + + chomp( $errstr ); + + print "\n"; + + print STDERR ( caller() )[1] .":\n $errstr at line " + . ( caller() )[2] . "\n"; + + if ( VERBOSE ) { + if ( caller( $level ) ) { + print "\n=== Stack Trace ===\n"; + } + + while ( my @trace = caller( $level++ ) ) { + print STDERR " $trace[1]:\n" + . " $trace[3]() called at line $trace[2]\n"; + } + } + + print "\n"; + + if ( $status ) { + exit( $status ); + } + } + +sub kdepends { + my $services = shift; + my $service = shift; + my $kdepends = shift || []; + my $stack = shift || []; + + if ( @$stack > 99 ) { + return; + } + + push( @$stack, $service->{'name'} ); + + foreach my $svcname ( sort( keys( %{$services} ) ) ) { + my $provides = $services->{$svcname}{'Provides'}; + + if ( $stack->[0] && grep( $_ eq $svcname, @$stack ) ) { + next; + } + + foreach my $required ( @{$service->{'Required-Stop'}} ) { + if ( grep( $_ eq $required, @$provides ) ) { + kdepends( $services, $services->{$svcname}, + $kdepends, $stack ); + + if ( ! grep( $_ eq $svcname, @$kdepends ) ) { + unshift( @$kdepends, $svcname ); + } + } + } + foreach my $required ( @{$service->{'Should-Stop'}} ) { + if ( grep( $_ eq $required, @$provides ) ) { + kdepends( $services, $services->{$svcname}, + $kdepends ); + + if ( ! grep( $_ eq $svcname, @$kdepends ) ) { + unshift( @$kdepends, $svcname ); + } + } + } + } + + return( $kdepends ); + } + +sub readinfo { + my $file = shift; + my $begin = 0; + my $prev; + my $service = { + 'Provides' => [], + 'Required-Start' => [], + 'Required-Stop' => [], + 'Should-Start' => [], + 'Should-Stop' => [], + 'Default-Start' => [], + 'Default-Stop' => [], + 'Short-Description' => '', + 'Description' => '' + }; + + open( FILE, "<$file" ) || error( int( $! ), "open(): $file: $!" ); + + while ( ) { + chomp(); + + if ( substr( $_, 0, 19 ) eq '### BEGIN INIT INFO' ) { + $begin++; + + next; + } + elsif ( substr( $_, 0, 17 ) eq '### END INIT INFO' ) { + last; + } + elsif ( ! $begin ) { + next; + } + + if ( $_ =~ /^#\s*((Short\-|)Description):\s*(.*)/ ) { + $service->{$1} = $3; + $prev = $1; + } + elsif ( $_ =~ /^#\s*(\S+):\s*(.*)/ ) { + $service->{$1} = []; + $prev = $1; + + push( @{$service->{$1}}, split( /\s+/, $2 ) ); + } + elsif ( $prev && $prev =~ /Description/ && $_ =~ /^#\s*(.*)/ ) { + $service->{$prev} .= " $1"; + } + elsif ( $prev && $_ =~ /^#\s*(.*)/ ) { + push( @{$service->{$prev}}, split( /\s+/, $1 ) ); + } + } + + close( FILE ); + + return( $service ); + } + +sub readsvcs { + my $services = {}; + + opendir( DIR, INITDIR ) || + error( int( $! ), "opendir(): " . INITDIR . ": $!" ); + + foreach my $svcname ( sort( readdir( DIR ) ) ) { + if ( ! -X INITDIR . "/$svcname" ) { + next; + } + + $services->{$svcname} = readinfo( INITDIR . "/$svcname" ); + + if ( ! @{$services->{$svcname}{'Provides'}} ) { + undef( $services->{$svcname} ); + + next; + } + + $services->{$svcname}{'name'} = $svcname; + $services->{$svcname}{'status'} = chkstatus( $svcname ); + } + + close( DIR ); + + return( $services ); + } + +sub sdepends { + my $services = shift; + my $service = shift; + my $sdepends = shift || []; + my $stack = shift || []; + + if ( @$stack > 99 ) { + return; + } + + push( @$stack, $service->{'name'} ); + + foreach my $svcname ( sort( keys( %{$services} ) ) ) { + my $provides = $services->{$svcname}{'Provides'}; + + if ( $stack->[0] && grep( $_ eq $svcname, @$stack ) ) { + next; + } + + foreach my $required ( @{$service->{'Required-Start'}} ) { + if ( grep( $_ eq $required, @$provides ) ) { + sdepends( $services, $services->{$svcname}, + $sdepends, $stack ); + + if ( ! grep( $_ eq $svcname, @$sdepends ) ) { + push( @$sdepends, $svcname ); + } + } + } + foreach my $required ( @{$service->{'Should-Start'}} ) { + if ( grep( $_ eq $required, @$provides ) ) { + sdepends( $services, $services->{$svcname}, + $sdepends, $stack ); + + if ( ! grep( $_ eq $svcname, @$sdepends ) ) { + push( @$sdepends, $svcname ); + } + } + } + } + + return( $sdepends ); + } + +my $command = shift( @ARGV ); +my $services = readsvcs(); +my $kserv = []; +my $sserv = []; + +if ( $command !~ /disable|enable|required/ ) { + error( -1, "$command: invalid command" ); + } + +if ( $command eq 'disable' ) { + foreach ( @ARGV ) { + if ( $services->{$_}{'X-Required'} ) { + print STDERR "Not disabling required service '$_'\n"; + + next; + } + + undef( $services->{$_} ); + } + } + +foreach my $svcname ( sort( keys( %$services ) ) ) { + if ( keys( %{$services->{$svcname}{'status'}} ) || + $services->{$svcname}{'X-Required'} ) { + push( @ARGV, $svcname ); + } + } + +foreach my $svcname ( sort( @ARGV ) ) { + my $service = $services->{$svcname}; + + if ( ! $service ) { + error( -1, "$svcname: invalid service name" ); + } + + sdepends( $services, $services->{$svcname}, $sserv ); + + if ( ! grep( $_ eq $svcname, @$sserv ) ) { + push( @$sserv, $svcname ); + } + + kdepends( $services, $services->{$svcname}, $kserv ); + + if ( ! grep( $_ eq $svcname, @$kserv ) ) { + if ( $svcname !~ /halt|reboot/ ) { + unshift( @$kserv, $svcname ); + } + else { + push( @$kserv, $svcname ); + } + } + } + +foreach my $rlvl ( RUNLEVELS ) { + my $dir = "/etc/rc$rlvl.d"; + my $startcnt = 0; + my $stopcnt = 0; + my $cnt = 0; + + if ( VERBOSE ) { + print "[Runlevel $rlvl]\n"; + } + + opendir( DIR, $dir ) || + error( int( $! ), "opendir(): $dir: $!" ); + + foreach ( sort( readdir( DIR ) ) ) { + if ( $_ =~ /^(K|S)\d{2}/ ) { + unlink( "$dir/$_" ) || + error( int( $! ), "unlink(): $dir/$_: $!" ); + } + } + + close( DIR ); + + foreach my $kdepend ( @$kserv ) { + if ( grep( $_ eq $rlvl, + @{$services->{$kdepend}{'Default-Stop'}} ) ) { + my $link = sprintf( "K%02d%s", $stopcnt, $kdepend ); + symlink( "../init.d/$kdepend", "$dir/$link" ) || + error( int( $! ), "symlink(): $dir/$link: $!" ); + + if ( VERBOSE ) { + print "$dir/$link -> ../init.d/$kdepend\n"; + } + + $stopcnt++; + } + } + foreach my $sdepend ( @$sserv ) { + if ( grep( $_ eq $rlvl, + @{$services->{$sdepend}{'Default-Start'}} ) ) { + my $link = sprintf( "S%02d%s", $startcnt, $sdepend ); + symlink( "../init.d/$sdepend", "$dir/$link" ) || + error( int( $! ), "symlink(): $dir/$link: $!" ); + + if ( VERBOSE ) { + print "$dir/$link -> ../init.d/$sdepend\n"; + } + + $startcnt++; + } + } + + if ( VERBOSE ) { + print "\n"; + } + }