From cb95d5f23b3c5b803f83a38f09d654bd9924f421 Mon Sep 17 00:00:00 2001 From: DJ Lucas Date: Sat, 14 May 2011 19:41:18 +0000 Subject: Changed distribution directory structure. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9530 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- bootscripts/contrib/lsb-v3/Makefile | 109 ++-- bootscripts/contrib/lsb-v3/etc/default/createfiles | 28 + bootscripts/contrib/lsb-v3/etc/default/modules | 18 + bootscripts/contrib/lsb-v3/etc/default/rc | 52 ++ bootscripts/contrib/lsb-v3/etc/default/rc.site | 81 +++ bootscripts/contrib/lsb-v3/etc/init.d/checkfs | 103 ++++ bootscripts/contrib/lsb-v3/etc/init.d/cleanfs | 106 ++++ bootscripts/contrib/lsb-v3/etc/init.d/console | 96 ++++ bootscripts/contrib/lsb-v3/etc/init.d/halt | 30 ++ .../contrib/lsb-v3/etc/init.d/lfs-functions | 214 ++++++++ bootscripts/contrib/lsb-v3/etc/init.d/localnet | 81 +++ bootscripts/contrib/lsb-v3/etc/init.d/modules | 97 ++++ bootscripts/contrib/lsb-v3/etc/init.d/mountfs | 59 +++ bootscripts/contrib/lsb-v3/etc/init.d/mountvirtfs | 49 ++ bootscripts/contrib/lsb-v3/etc/init.d/network | 71 +++ bootscripts/contrib/lsb-v3/etc/init.d/rc | 196 +++++++ bootscripts/contrib/lsb-v3/etc/init.d/reboot | 32 ++ bootscripts/contrib/lsb-v3/etc/init.d/sendsignals | 54 ++ bootscripts/contrib/lsb-v3/etc/init.d/setclock | 54 ++ bootscripts/contrib/lsb-v3/etc/init.d/swap | 55 ++ bootscripts/contrib/lsb-v3/etc/init.d/sysctl | 39 ++ bootscripts/contrib/lsb-v3/etc/init.d/sysklogd | 69 +++ bootscripts/contrib/lsb-v3/etc/init.d/template | 90 ++++ bootscripts/contrib/lsb-v3/etc/init.d/udev | 85 +++ bootscripts/contrib/lsb-v3/etc/init.d/udev_retry | 49 ++ bootscripts/contrib/lsb-v3/init.d/checkfs | 103 ---- bootscripts/contrib/lsb-v3/init.d/cleanfs | 106 ---- bootscripts/contrib/lsb-v3/init.d/console | 96 ---- bootscripts/contrib/lsb-v3/init.d/halt | 30 -- bootscripts/contrib/lsb-v3/init.d/lfs-functions | 214 -------- bootscripts/contrib/lsb-v3/init.d/localnet | 81 --- bootscripts/contrib/lsb-v3/init.d/modules | 97 ---- bootscripts/contrib/lsb-v3/init.d/mountfs | 59 --- bootscripts/contrib/lsb-v3/init.d/mountvirtfs | 49 -- bootscripts/contrib/lsb-v3/init.d/network | 71 --- bootscripts/contrib/lsb-v3/init.d/rc | 196 ------- bootscripts/contrib/lsb-v3/init.d/reboot | 32 -- bootscripts/contrib/lsb-v3/init.d/sendsignals | 54 -- bootscripts/contrib/lsb-v3/init.d/setclock | 54 -- bootscripts/contrib/lsb-v3/init.d/swap | 55 -- bootscripts/contrib/lsb-v3/init.d/sysctl | 39 -- bootscripts/contrib/lsb-v3/init.d/sysklogd | 69 --- bootscripts/contrib/lsb-v3/init.d/template | 90 ---- bootscripts/contrib/lsb-v3/init.d/udev | 85 --- bootscripts/contrib/lsb-v3/init.d/udev_retry | 49 -- bootscripts/contrib/lsb-v3/lib/lsb/init-functions | 577 +++++++++++++++++++++ .../contrib/lsb-v3/lib/lsb/manage-functions | 306 +++++++++++ .../lsb-v3/lib/network-services/ipv4-static | 80 +++ .../lsb-v3/lib/network-services/ipv4-static-route | 92 ++++ bootscripts/contrib/lsb-v3/lsb/init-functions | 577 --------------------- bootscripts/contrib/lsb-v3/lsb/manage-functions | 306 ----------- bootscripts/contrib/lsb-v3/sbin/ifdown | 93 ++++ bootscripts/contrib/lsb-v3/sbin/ifup | 87 ++++ bootscripts/contrib/lsb-v3/sysconfig/createfiles | 28 - bootscripts/contrib/lsb-v3/sysconfig/modules | 18 - .../lsb-v3/sysconfig/network-devices/ifdown | 93 ---- .../contrib/lsb-v3/sysconfig/network-devices/ifup | 87 ---- .../sysconfig/network-devices/services/ipv4-static | 80 --- .../network-devices/services/ipv4-static-route | 92 ---- bootscripts/contrib/lsb-v3/sysconfig/rc | 52 -- bootscripts/contrib/lsb-v3/sysconfig/rc.site | 81 --- 61 files changed, 3094 insertions(+), 3101 deletions(-) create mode 100644 bootscripts/contrib/lsb-v3/etc/default/createfiles create mode 100644 bootscripts/contrib/lsb-v3/etc/default/modules create mode 100644 bootscripts/contrib/lsb-v3/etc/default/rc create mode 100644 bootscripts/contrib/lsb-v3/etc/default/rc.site create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/checkfs create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/cleanfs create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/console create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/halt create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/lfs-functions create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/localnet create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/modules create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/mountfs create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/mountvirtfs create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/network create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/rc create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/reboot create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/sendsignals create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/setclock create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/swap create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/sysctl create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/sysklogd create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/template create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/udev create mode 100644 bootscripts/contrib/lsb-v3/etc/init.d/udev_retry delete mode 100644 bootscripts/contrib/lsb-v3/init.d/checkfs delete mode 100644 bootscripts/contrib/lsb-v3/init.d/cleanfs delete mode 100644 bootscripts/contrib/lsb-v3/init.d/console delete mode 100644 bootscripts/contrib/lsb-v3/init.d/halt delete mode 100644 bootscripts/contrib/lsb-v3/init.d/lfs-functions delete mode 100644 bootscripts/contrib/lsb-v3/init.d/localnet delete mode 100644 bootscripts/contrib/lsb-v3/init.d/modules delete mode 100644 bootscripts/contrib/lsb-v3/init.d/mountfs delete mode 100644 bootscripts/contrib/lsb-v3/init.d/mountvirtfs delete mode 100644 bootscripts/contrib/lsb-v3/init.d/network delete mode 100644 bootscripts/contrib/lsb-v3/init.d/rc delete mode 100644 bootscripts/contrib/lsb-v3/init.d/reboot delete mode 100644 bootscripts/contrib/lsb-v3/init.d/sendsignals delete mode 100644 bootscripts/contrib/lsb-v3/init.d/setclock delete mode 100644 bootscripts/contrib/lsb-v3/init.d/swap delete mode 100644 bootscripts/contrib/lsb-v3/init.d/sysctl delete mode 100644 bootscripts/contrib/lsb-v3/init.d/sysklogd delete mode 100644 bootscripts/contrib/lsb-v3/init.d/template delete mode 100644 bootscripts/contrib/lsb-v3/init.d/udev delete mode 100644 bootscripts/contrib/lsb-v3/init.d/udev_retry create mode 100644 bootscripts/contrib/lsb-v3/lib/lsb/init-functions create mode 100644 bootscripts/contrib/lsb-v3/lib/lsb/manage-functions create mode 100644 bootscripts/contrib/lsb-v3/lib/network-services/ipv4-static create mode 100644 bootscripts/contrib/lsb-v3/lib/network-services/ipv4-static-route delete mode 100644 bootscripts/contrib/lsb-v3/lsb/init-functions delete mode 100644 bootscripts/contrib/lsb-v3/lsb/manage-functions create mode 100644 bootscripts/contrib/lsb-v3/sbin/ifdown create mode 100644 bootscripts/contrib/lsb-v3/sbin/ifup delete mode 100644 bootscripts/contrib/lsb-v3/sysconfig/createfiles delete mode 100644 bootscripts/contrib/lsb-v3/sysconfig/modules delete mode 100644 bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifdown delete mode 100644 bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifup delete mode 100644 bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static delete mode 100644 bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static-route delete mode 100644 bootscripts/contrib/lsb-v3/sysconfig/rc delete mode 100644 bootscripts/contrib/lsb-v3/sysconfig/rc.site (limited to 'bootscripts') diff --git a/bootscripts/contrib/lsb-v3/Makefile b/bootscripts/contrib/lsb-v3/Makefile index a6cef78ba..c07d4eb5b 100644 --- a/bootscripts/contrib/lsb-v3/Makefile +++ b/bootscripts/contrib/lsb-v3/Makefile @@ -16,50 +16,45 @@ create-dirs: install -d -m ${DIRMODE} ${EXTDIR}/rc6.d install -d -m ${DIRMODE} ${EXTDIR}/rcS.d install -d -m ${DIRMODE} ${EXTDIR}/init.d - install -d -m ${DIRMODE} ${EXTDIR}/sysconfig + install -d -m ${DIRMODE} ${EXTDIR}/default install -d -m ${DIRMODE} ${DESTDIR}/lib/lsb install -d -m ${DIRMODE} ${EXTDIR}/lsb/state + install -d -m ${DIRMODE} ${DESTDIR}/lib/network-services -create-service-dir: - install -d -m ${DIRMODE} ${EXTDIR}/sysconfig/network-devices/services - -create-boottemp-dir: - install -d -m ${DIRMODE} ${EXTDIR}/init.d/boottemp - -install: create-dirs create-service-dir create-boottemp-dir - install -m ${MODE} init.d/checkfs ${EXTDIR}/init.d/ - install -m ${MODE} init.d/cleanfs ${EXTDIR}/init.d/ - install -m ${CONFMODE} init.d/lfs-functions ${EXTDIR}/init.d/ - install -m ${MODE} init.d/halt ${EXTDIR}/init.d/ - install -m ${MODE} init.d/console ${EXTDIR}/init.d/ - install -m ${MODE} init.d/localnet ${EXTDIR}/init.d/ - install -m ${MODE} init.d/modules ${EXTDIR}/init.d/ - install -m ${MODE} init.d/mountfs ${EXTDIR}/init.d/ - install -m ${MODE} init.d/mountvirtfs ${EXTDIR}/init.d/ - install -m ${MODE} init.d/network ${EXTDIR}/init.d/ - install -m ${MODE} init.d/rc ${EXTDIR}/init.d/ - install -m ${MODE} init.d/reboot ${EXTDIR}/init.d/ - install -m ${MODE} init.d/sendsignals ${EXTDIR}/init.d/ - install -m ${MODE} init.d/setclock ${EXTDIR}/init.d/ - install -m ${MODE} init.d/sysklogd ${EXTDIR}/init.d/ - install -m ${MODE} init.d/swap ${EXTDIR}/init.d/ - install -m ${MODE} init.d/sysctl ${EXTDIR}/init.d/ - install -m ${MODE} init.d/template ${EXTDIR}/init.d/ - install -m ${MODE} init.d/udev ${EXTDIR}/init.d/ - install -m ${MODE} init.d/udev_retry ${EXTDIR}/init.d/ - install -m ${CONFMODE} lsb/init-functions ${DESTDIR}/lib/lsb/ - install -m ${CONFMODE} lsb/manage-functions ${DESTDIR}/lib/lsb/ +install: create-dirs + install -m ${MODE} etc/init.d/checkfs ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/cleanfs ${EXTDIR}/init.d/ + install -m ${CONFMODE} etc/init.d/lfs-functions ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/halt ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/console ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/localnet ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/modules ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/mountfs ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/mountvirtfs ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/network ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/rc ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/reboot ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/sendsignals ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/setclock ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/sysklogd ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/swap ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/sysctl ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/template ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/udev ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/udev_retry ${EXTDIR}/init.d/ + install -m ${CONFMODE} lib/lsb/init-functions ${DESTDIR}/lib/lsb/ + install -m ${CONFMODE} lib/lsb/manage-functions ${DESTDIR}/lib/lsb/ install -m ${CONFMODE} etc/lsb-config ${EXTDIR}/lsb/ - if [ ! -f ${EXTDIR}/sysconfig/createfiles ]; then install -m ${CONFMODE} sysconfig/createfiles ${EXTDIR}/sysconfig/; fi - if [ ! -f ${EXTDIR}/sysconfig/modules ]; then install -m ${CONFMODE} sysconfig/modules ${EXTDIR}/sysconfig/; fi - if [ ! -f ${EXTDIR}/sysconfig/rc ]; then install -m ${CONFMODE} sysconfig/rc ${EXTDIR}/sysconfig/; fi - if [ ! -f ${EXTDIR}/sysconfig/rc.site ]; then install -m ${CONFMODE} sysconfig/rc.site ${EXTDIR}/sysconfig/; fi + if [ ! -f ${EXTDIR}/default/createfiles ]; then install -m ${CONFMODE} etc/default/createfiles ${EXTDIR}/default/; fi + if [ ! -f ${EXTDIR}/default/modules ]; then install -m ${CONFMODE} etc/default/modules ${EXTDIR}/default/; fi + if [ ! -f ${EXTDIR}/default/rc ]; then install -m ${CONFMODE} etc/default/rc ${EXTDIR}/default/; fi + if [ ! -f ${EXTDIR}/default/rc.site ]; then install -m ${CONFMODE} etc/default/rc.site ${EXTDIR}/default/; fi if [ -f ${EXTDIR}/inittab ]; then install -m ${CONFMODE} ${EXTDIR}/inittab ${EXTDIR}/inittab.bak; fi install -m ${CONFMODE} etc/inittab ${EXTDIR}/ - install -m ${MODE} sysconfig/network-devices/ifup ${EXTDIR}/sysconfig/network-devices/ - install -m ${MODE} sysconfig/network-devices/ifdown ${EXTDIR}/sysconfig/network-devices/ - install -m ${MODE} sysconfig/network-devices/services/ipv4-static ${EXTDIR}/sysconfig/network-devices/services/ - install -m ${MODE} sysconfig/network-devices/services/ipv4-static-route ${EXTDIR}/sysconfig/network-devices/services/ + install -m ${MODE} sbin/ifup ${DESTDIR}/sbin/ + install -m ${MODE} sbin/ifdown ${DESTDIR}/sbin/ + install -m ${MODE} lib/network-services/ipv4-static ${DESTDIR}/lib/network-services/ + install -m ${MODE} lib/network-services/ipv4-static-route ${DESTDIR}/lib/network-services/ /usr/lib/lsb/install_initd ${EXTDIR}/init.d/checkfs /usr/lib/lsb/install_initd ${EXTDIR}/init.d/cleanfs /usr/lib/lsb/install_initd ${EXTDIR}/init.d/halt @@ -77,24 +72,24 @@ install: create-dirs create-service-dir create-boottemp-dir /usr/lib/lsb/install_initd ${EXTDIR}/init.d/udev /usr/lib/lsb/install_initd ${EXTDIR}/init.d/udev_retry -minimal: create-dirs create-service-dir create-boottemp-dir - install -m ${MODE} init.d/checkfs ${EXTDIR}/init.d/ - install -m ${MODE} init.d/cleanfs ${EXTDIR}/init.d/ - install -m ${CONFMODE} init.d/lfs-functions ${EXTDIR}/init.d/ - install -m ${MODE} init.d/halt ${EXTDIR}/init.d/ - install -m ${MODE} init.d/localnet ${EXTDIR}/init.d/ - install -m ${MODE} init.d/mountfs ${EXTDIR}/init.d/ - install -m ${MODE} init.d/mountvirtfs ${EXTDIR}/init.d/ - install -m ${MODE} init.d/rc ${EXTDIR}/init.d/ - install -m ${MODE} init.d/reboot ${EXTDIR}/init.d/ - install -m ${MODE} init.d/sendsignals ${EXTDIR}/init.d/ - install -m ${MODE} init.d/setclock ${EXTDIR}/init.d/ - install -m ${MODE} init.d/swap ${EXTDIR}/init.d/ - install -m ${MODE} init.d/udev ${EXTDIR}/init.d/ - install -m ${CONFMODE} lsb/init-functions ${DESTDIR}/lib/lsb/ - install -m ${CONFMODE} lsb/manage-functions ${DESTDIR}/lib/lsb/ +minimal: create-dirs + install -m ${MODE} etc/init.d/checkfs ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/cleanfs ${EXTDIR}/init.d/ + install -m ${CONFMODE} etc/init.d/lfs-functions ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/halt ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/localnet ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/mountfs ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/mountvirtfs ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/rc ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/reboot ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/sendsignals ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/detclock ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/swap ${EXTDIR}/init.d/ + install -m ${MODE} etc/init.d/udev ${EXTDIR}/init.d/ + install -m ${CONFMODE} lib/lsb/init-functions ${DESTDIR}/lib/lsb/ + install -m ${CONFMODE} lib/lsb/manage-functions ${DESTDIR}/lib/lsb/ install -m ${CONFMODE} etc/lsb-config ${EXTDIR}/lsb/ - if [ ! -f ${EXTDIR}/sysconfig/rc ]; then install -m ${CONFMODE} sysconfig/rc ${EXTDIR}/sysconfig/; fi + if [ ! -f ${EXTDIR}/default/rc ]; then install -m ${CONFMODE} default/rc ${EXTDIR}/default/; fi if [ -f ${EXTDIR}/inittab ]; then install -m ${CONFMODE} ${EXTDIR}/inittab ${EXTDIR}/inittab.bak; fi install -m ${CONFMODE} etc/inittab ${EXTDIR}/ /usr/lib/lsb/install_initd ${EXTDIR}/init.d/checkfs @@ -105,10 +100,8 @@ minimal: create-dirs create-service-dir create-boottemp-dir /usr/lib/lsb/install_initd ${EXTDIR}/init.d/mountvirtfs /usr/lib/lsb/install_initd ${EXTDIR}/init.d/reboot /usr/lib/lsb/install_initd ${EXTDIR}/init.d/sendsignals - /usr/lib/lsb/install_initd ${EXTDIR}/init.d/setclock /usr/lib/lsb/install_initd ${EXTDIR}/init.d/swap /usr/lib/lsb/install_initd ${EXTDIR}/init.d/udev -.PHONY: all create-dirs create-service-dir create-boottemp-dir \ - install minimal +.PHONY: all create-dirs install minimal diff --git a/bootscripts/contrib/lsb-v3/etc/default/createfiles b/bootscripts/contrib/lsb-v3/etc/default/createfiles new file mode 100644 index 000000000..8d1f89dc6 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/default/createfiles @@ -0,0 +1,28 @@ +######################################################################## +# Begin /etc/sysconfig/createfiles +# +# Description : Createfiles script config file +# +# Authors : +# +# Version : 00.00 +# +# Notes : The syntax of this file is as follows: +# if type is equal to "file" or "dir" +# +# if type is equal to "dev" +# +# +# is the name of the file which is to be created +# is either file, dir, or dev. +# file creates a new file +# dir creates a new directory +# dev creates a new device +# is either block, char or pipe +# block creates a block device +# char creates a character deivce +# pipe creates a pipe, this will ignore the and fields +# and are the major and minor numbers used for the device. +######################################################################## + +# End /etc/sysconfig/createfiles diff --git a/bootscripts/contrib/lsb-v3/etc/default/modules b/bootscripts/contrib/lsb-v3/etc/default/modules new file mode 100644 index 000000000..1c8493d45 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/default/modules @@ -0,0 +1,18 @@ +######################################################################## +# Begin /etc/sysconfig/modules +# +# Description : Module auto-loading configuration +# +# Authors : +# +# Version : 00.00 +# +# Notes : The syntax of this file is as follows: +# [ ...] +# +# Each module should be on it's own line, and any options that you want +# passed to the module should follow it. The line deliminator is either +# a space or a tab. +######################################################################## + +# End /etc/sysconfig/modules diff --git a/bootscripts/contrib/lsb-v3/etc/default/rc b/bootscripts/contrib/lsb-v3/etc/default/rc new file mode 100644 index 000000000..ffb70d98c --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/default/rc @@ -0,0 +1,52 @@ +# Begin /etc/sysconfig/rc + +# Author: DJ Lucas - dj@linuxfromscratch.org +# Version: 1.0 LSB V.3.1 + +# Global variable inherited by initscripts are in caps +# Local variables for the rc script are in lowercase + +# Source site specific rc configuration +. /etc/sysconfig/rc.site + +# This sets default terminal options. +# stty sane - this has been removed as nobody recalls +# the reason for it in the first place - if no problems arize, +# then it will be removed completely at a later date. + +# Setup default values for the environment +umask 022 +PATH="/bin:/sbin" + +# 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 Cursur Position Commands, used via echo -e +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 + +# Bootlogging and interactive startup require a valid tempfs mount +# if this mount is not present, disable them +if [ "${TEMPFS_MOUNT}" = "" -o ! -d "${TEMPFS_MOUNT}" ]; then + TEMPFS_MOUNT="" + iprompt="" + BOOTLOG_ENAB="" +fi + +# Export the environment variables so they are inherited by the scripts +export PATH SET_COL SET_WCOL CURS_UP TEMPFS_MOUNT BOOTLOG_ENAB RUNLEVEL + +# End /etc/sysconfig/rc diff --git a/bootscripts/contrib/lsb-v3/etc/default/rc.site b/bootscripts/contrib/lsb-v3/etc/default/rc.site new file mode 100644 index 000000000..f3369db58 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/default/rc.site @@ -0,0 +1,81 @@ +# Set base directory information +RC_BASE="/etc" +RC_FUNCTIONS="${RC_BASE}/init.d/lfs-functions" + +# Location of network device scripts and config files +NETWORK_DEVICES="/etc/sysconfig/network-devices" + +# Directory to store boot process accounting information +# Used for boot logging and interactive flag when rootfs +# is not writable +TEMPFS_MOUNT="${RC_BASE}/init.d/boottemp" + +# Bootlogging (requires a tempfs mount) +BOOTLOG_ENAB="yes" + +# Hostname +HOSTNAME= + +# System time variables +UTC=1 +CLOCKPARAMS= + +# Manual input is not appropriate on remote systems. Define what happens when +# an error is encountered that interupts the boot/shutdown proceess +FAILURE_ACTION="read ENTER" + +# Distro Information +DISTRO="Linux From Scratch" # The distro name +DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address +DISTRO_MINI="lfs" # Short name used in filenames for distro config + +# Define custom colors used in messages printed to the screen +BRACKET="\\033[1;34m" # Blue +FAILURE="\\033[1;31m" # Red +INFO="\\033[1;36m" # Cyan +NORMAL="\\033[0;39m" # Grey +SUCCESS="\\033[1;32m" # Green +WARNING="\\033[1;33m" # Yellow + +# Prefix boot messages for easier reading on framebuffer consoles +PREFIX_SUCCESS=" ${SUCCESS}*${NORMAL} " +PREFIX_WARNING="${WARNING}**${NORMAL} " +PREFIX_FAILURE="${FAILURE}***${NORMAL}" + +# Export varialbles so that they are inherited by the initscripts +export RC_BASE RC_FUNCTIONS NETWORK_DEVICES TEMPFS_MOUNT BOOTLOG_ENAB +export HOSTNAME UTC CLOCKPARAMS FAILURE_ACTION +export DISTRO DISTRO_CONTACT DISTRO_MINI +export BRACKET FAILURE INFO NORMAL SUCCESS WARNING +export PREFIX_SUCCESS PREFIX_WARNING PREFIX_FAILURE + +# Interactive startup +iprompt="yes" # Wether to display the interactive boot promp +itime="2" # The ammount of time (in seconds) to display the prompt +dlen="29" # The total length of the distro welcome string +ilen="38" # The total length of the interactive message +welcome_message="Welcome to ${INFO}${DISTRO}${NORMAL}" +i_message="Press '${FAILURE}I${NORMAL}' to enter interactive startup" + +# Error message displayed when a script's exit value is not zero +print_error_msg() +{ + # ${link} and ${error_value} are defined by the rc script + echo -e "${FAILURE}FAILURE: You should not be reading this error message." + echo -e "" + echo -e -n "${FAILURE}It means that an unforseen error took place in" + echo -e -n "${INFO} ${link}" + echo -e "${FAILURE}," + echo -e "${FAILURE}which exited with a return value of ${error_value}." + echo -e "" + echo -e -n "${FAILURE}If you are able to track this error down to a bug" + echo -e "${FAILURE}in one of the files" + echo -e -n "provided by ${INFO}${DISTRO}${FAILURE}, " + echo -e -n "${FAILURE}please be so kind to inform us at " + echo -e "${INFO}${DISTRO_CONTACT}${FAILURE}.${NORMAL}" + echo -e "" + echo -e "${INFO}Press Enter to continue..." + echo -e "${NORMAL}" + $FAILURE_ACTION +} + diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/checkfs b/bootscripts/contrib/lsb-v3/etc/init.d/checkfs new file mode 100644 index 000000000..1e3efed9b --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/checkfs @@ -0,0 +1,103 @@ +#!/bin/sh +# Begin /etc/init.d/checkfs + +### BEGIN INIT INFO +# Provides: checkfs +# Required-Start: udev swap +# 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 + echo "${INFO}/fastboot found!" + log_success_msg "Will not perform file system checks as requested." + exit 0 + fi + + mount -n -o remount,ro / >/dev/null + if [ ${?} -ne 0 ] + then + log_failure_msg "Mounting root file system in read-only mode" + echo -e "${FAILURE}FAILURE:\n" + echo -e -n "${FAILURE}Cannot check root filesystem because it " + echo -e "${FAILURE}could not be mounted" + echo -e "${FAILURE}in read-only mode.\n\n" + echo -e -n "${FAILURE}After you press Enter, this system will be " + echo -e "${FAILURE}halted and powered off.\n" + echo -e "${INFO}Press enter to continue...${NORMAL}" + $FAILURE_ACTION + /etc/rc.d/init.d/halt stop + fi + + if [ -f /forcefsck ] + then + echo "${INFO}/forcefsck found!" + log_success_msg "${INFO}Forcing file system checks as requested." + options="-f" + else + options="" + fi + + # Note: -a option used to be -p; but this fails e.g. + # on fsck.minix + fsck ${options} -a -A -C -T + error_value=${?} + + if [ "${error_value}" -eq 0 ] + then + log_success_msg "Checking file systems..." + elif [ "${error_value}" -eq 1 ] + then + log_warning_msg "Checking file systems..." + echo -e "${WARNING}WARNING:\n" + echo -e "${WARNING}File system errors were found and have been" + echo -e "${WARNING}corrected. You may want to double-check that" + echo -e "${WARNING}everything was fixed properly.${NORMAL}" + elif [ "${error_value}" -eq 2 -o "${error_value}" -eq 3 ]; then + log_warning_msg "Checking file systems..." + echo -e "${WARNING}WARNING:\n" + echo -e "${WARNING}File system errors were found and have been been" + echo -e "${WARNING}corrected, but the nature of the errors require" + echo -e "${WARNING}this system to be rebooted.\n" + echo -e "After you press enter, this system will be rebooted.\n" + echo -e "${INFO}Press Enter to continue...${NORMAL}" + $FAILURE_ACTION + reboot -f + elif [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then + log_failure_msg "Checking file systems..." + echo -e "${FAILURE}FAILURE:\n" + echo -e "${FAILURE}File system errors were encountered that could" + echo -e "${FAILURE}not be fixed automatically. This system cannot" + echo -e "${FAILURE}continue to boot and will therefore be halted" + echo -e "${FAILURE}until those errors are fixed manually by a" + echo -e "${FAILURE}System Administrator.\n" + echo -e "${FAILURE}After you press Enter, this system will be" + echo -e "${FAILURE}halted and powered off.\n" + echo -e "${INFO}Press Enter to continue...${NORMAL}" + $FAILURE_ACTION + /etc/rc.d/init.d/halt stop + elif [ "${error_value}" -ge 16 ]; then + log_failure_msg "Checking file systems..." + echo -e "${FAILURE}FAILURE:\n" + echo -e "${FAILURE}Unexpected Failure running fsck. Exited with error" + echo -e "${FAILURE}code: ${error_value}.${NORMAL}" + exit ${error_value} + fi + ;; + *) + echo "Usage: ${0} {start}" + exit 1 + ;; +esac + +# End /etc/init.d/checkfs diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/cleanfs b/bootscripts/contrib/lsb-v3/etc/init.d/cleanfs new file mode 100644 index 000000000..96582c28c --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/cleanfs @@ -0,0 +1,106 @@ +#!/bin/sh +# Begin /etc/init.d/cleanfs + +### 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 temporary directories /var/run, /var/lock, and +# /tmp. cleanfs also creates /var/run/utmp and any files +# defined in /etc/sysconfig/createfiles. +# X-LFS-Provided-By: LFS +### END INIT INFO + +. /lib/lsb/init-functions + +# Function to create files/directory on boot. +create_files() +{ + # Read in the configuration file. + exec 9>&0 < /etc/sysconfig/createfiles + while read name type perm usr grp dtype maj min junk + do + # Ignore comments and blank lines. + case "${name}" in + ""|\#*) continue ;; + esac + + # Ignore existing files. + if [ ! -e "${name}" ] + then + # Create stuff based on its type. + case "${type}" in + dir) + mkdir "${name}" + ;; + file) + :> "${name}" + ;; + dev) + case "${dtype}" in + char) + mknod "${name}" c ${maj} ${min} + ;; + block) + mknod "${name}" b ${maj} ${min} + ;; + pipe) + mknod "${name}" p + ;; + *) + echo -e -n "\n${WARNING}Unknown device type: ${dtype}" + echo -e "${NORMAL}" + ;; + esac + ;; + *) + echo -e "\n${WARNING}Unknown type: ${type}${NORMAL}" + continue + ;; + esac + + # Set up the permissions, too. + chown ${usr}:${grp} "${name}" + chmod ${perm} "${name}" + fi + done + exec 0>&9 9>&- +} + +case "${1}" in + start) + message="Cleaning file systems: " + + message="${message}${INFO} /tmp" + find /tmp -xdev -mindepth 1 ! -name lost+found \ + -delete || failed=1 + + > /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 standard + + if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null + then + message="Creating files and directories..." + create_files + evaluate_retval standard + fi + ;; + *) + echo "Usage: ${0} {start}" + exit 1 + ;; +esac + +# End /etc/init.d/cleanfs + diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/console b/bootscripts/contrib/lsb-v3/etc/init.d/console new file mode 100644 index 000000000..8b26f57d5 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/console @@ -0,0 +1,96 @@ +#!/bin/sh +# Begin $rc_base/init.d/console + +### 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/sysconfig/console. +# X-LFS-Provided-By: LFS +### END INIT INFO + +. /lib/lsb/init-functions + +MESSAGE="Setting up Linux console..." + +# Native English speakers probably don't have /etc/sysconfig/console at all +if [ -f /etc/sysconfig/console ] +then + . /etc/sysconfig/console +fi + +is_true() { + [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] +} + +failed=0 + +case "${1}" in + start) + # There should be no bogus failures below this line! + + # 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. + # FIXME: Fedora Core also initializes two spare consoles + # - do we want that? + + 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 + is_true "${USE_FB}" || [ -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 standard + ;; + *) + echo $"Usage:" "${0} {start}" + exit 1 + ;; +esac + +# End $rc_base/init.d/console diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/halt b/bootscripts/contrib/lsb-v3/etc/init.d/halt new file mode 100644 index 000000000..cdcd90778 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/halt @@ -0,0 +1,30 @@ +#!/bin/sh +# Begin $RC_BASE/init.d/halt + +### 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 + +. /lib/lsb/init-functions + +case "${1}" in + stop) + log_success_msg "Halting System..." + halt -d -f -i -p + ;; + *) + echo "Usage: {stop}" + exit 1 + ;; +esac + +# End /etc/init.d/halt diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/lfs-functions b/bootscripts/contrib/lsb-v3/etc/init.d/lfs-functions new file mode 100644 index 000000000..b0fef4c29 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/lfs-functions @@ -0,0 +1,214 @@ +# Begin /etc/init.d/lfs-functions +# Provides LFS specific functions for LSB style bootscripts + +################################# chkstat() ################################### +# chk_stat checks the status of a script by checking for both a binary file # +# to execute, and if set, a config file that may be needed for the program # +# to run successfully. The calling script will exit with a return value of 5 # +# if the binary does not exist, and a value of 6 if the needed config file is # +# unavailable as per LSB requirements. This function accepts zero, one, or # +# two string arguments. If arguments are passed, the first must be a bin # +# file. If a second argument is passed, it is interpreted as the config # +# file. Optionally, zero arguments can be passed if BIN_FILE, and optinally # +# CONFIG_FILE are set in the calling script. # +############################################################################### +chk_stat() +{ + if [ "${#}" -gt "0" -a "${#}" -lt "3" ]; then + BIN_FILE="${1}" + if [ -z "${2}" ]; then + CONFIG_FILE="" + else + CONFIG_FILE="${2}" + fi + elif [ -z "${BIN_FILE}" ]; then + echo "Usage: 'chk_stat BIN_FILE CONFIG_FILE'" + exit 1 # Generic Error + fi + + if [ ! -e "${BIN_FILE}" ]; then + log_failure_msg "${BIN_FILE} not installed" && + exit 5 + fi + + if [ ! -z "${CONFIG_FILE}" ]; then + if [ ! -e "${CONFIG_FILE}" ]; then + log_failure_msg "${CONFIG_FILE} does not exist" && + exit 6 + fi + fi +} + +################################ loadproc() ################################### +# loadproc is just a wraper to start_daemon for simple scripts, which will # +# require no arguments if $BIN_FILE is set. # +############################################################################### +loadproc() +{ + start_daemon "${BIN_FILE}" "${@}" +} + +################################ endproc() #################################### +# endproc, like loadproc, is just a wraper to killproc for simplicity and is # +# dependent on $BIN_FILE being set. # +############################################################################### +endproc() +{ + killproc "${BIN_FILE}" "${@}" +} + +############################### statusproc() ################################## +# statusproc checks the status of a particular binary and displays the # +# appropriate message (running or not running) and exits on the return value # +# of pidofproc. This function accepts two string arguments or zero arguments # +# if BIN_FILE and MESSAGE are set, else it requires the bin file as the first # +# argument, and the message as the second. Both must be enclosed in quotes. # +############################################################################### +statusproc() +{ + if [ "${#}" -gt "0" -a "${#}" -lt "3" ]; then + BIN_FILE="${1}" + MESSAGE="${2}" + elif [ -z "${BIN_FILE}" -o -z "${MESSAGE}" ]; then + echo "Usage: 'statusproc BIN_FILE MESSAGE'" + exit 1 # Generic Error + fi + + pidlist=`pidofproc "${BIN_FILE}"` + STATUS=$? + echo "Checking ${MESSAGE} status:" + if [ "${STATUS}" -eq "0" ]; then + log_success_msg "Running with PID(s) ${pidlist}" + else + log_warning_msg "Not running!" + fi + + return "${STATUS}" +} + +############################### reloadproc() ################################## +# reloadproc sends a HUP signal to the running program (relaod configuration) # +# It optionally, using the -force switch, checks the status of a particular # +# program and starts it if it is not already running. This function accepts # +# one optional switch (must be the first argument), and either two, or zero # +# string arguments. If BIN_FILE and MESSAGE are set in the script's # +# environment, it will use those values, else it requires the bin file as # +# the first argument (following -force if used), and the message as the # +# second. Both must be enclosed in quotes. If the force option is used, it # +# follows the LSB definition of 'force-reload' - the program is started if # +# not already running. # +############################################################################### +reloadproc() +{ + local force="0" + if [ "${#}" -gt "0" -a "${1}" = "-force" ]; then + force="1" + shift 1 + fi + + if [ "${#}" -gt "0" -a "${#}" -lt "3" ]; then + BIN_FILE="${1}" + MESSAGE="${2}" + elif [ -z "${BIN_FILE}" -o -z "${MESSAGE}" ]; then + echo "Usage: 'reloadproc BIN_FILE MESSAGE'" + exit 1 # Generic Error + fi + + + +} + +############################## evaluate_retval() ############################### +# evaluate_retval requires that you pass exactly one evaluation parameter of # +# (start, stop, other) based on the previous action that is being evaluated. # +# This function is intended for use with start_daemon and killproc to # +# interpret the LSB exit codes properly, othewise the checks only for success # +# or failure. # +################################################################################ +evaluate_retval() +{ + local error_value="${?}" + + # Handle LSB defined return values + case "${1}" in + + start) + case "${error_value}" in + 0) + log_success_msg "Starting ${MESSAGE} " + return "${error_value}" + ;; + 2) + log_failure_msg "Starting ${MESSAGE} Error: Invalid argument!" + return "${error_value}" + ;; + 5) + log_failure_msg "Starting ${MESSAGE} Error: Not available!" + return "${error_value}" + ;; + *) + log_failure_msg "Starting ${MESSAGE} Error: General failure!" + return "${error_value}" + ;; + esac + ;; + + stop) + case "${error_value}" in + 0) + log_success_msg "Stopping ${MESSAGE} " + return "${error_value}" + ;; + 2) + log_failure_msg "Stopping ${MESSAGE} Error: Invalid argument!" + return "${error_value}" + ;; + 5) + log_failure_msg "Stopping ${MESSAGE} Error: Not available!" + return "${error_value}" + ;; + 7) + log_warning_msg "Stopping ${MESSAGE} Warning: Not running!" + return "${error_value}" + ;; + *) + log_failure_msg "Stopping ${MESSAGE} Error: General failure!" + return "${error_value}" + ;; + esac + ;; + + force-reload) + message="Forcefully reloading " + ;; + + reload) + message="Reloading " + ;; + + restart) + message="Restarting " + ;; + + try-restart) + message="Trying restart " + ;; + + standard) + # $message or $MESSAGE must be set, but not both in order + # to use the 'standard' target. + ;; + esac + + # Print messages for the generic force-reload, reload, restart, + # and try-restart targets + if [ "${error_value}" -eq "0" ] + then + log_success_msg "${message}${MESSAGE} " + return "${error_value}" + else + log_failure_msg "${message}${MESSAGE} " + return "${error_value}" + fi +} + diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/localnet b/bootscripts/contrib/lsb-v3/etc/init.d/localnet new file mode 100644 index 000000000..322bb8749 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/localnet @@ -0,0 +1,81 @@ +#!/bin/sh +# Begin /etc/init.d/localnet + +### 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 + +case "${1}" in + start) + ip addr add 127.0.0.1/8 label lo dev lo + ip link set lo up + if [ "${?}" -eq "0" ] + then + log_success_msg "Bringing up the loopback interface..." + else + log_failure_msg "Bringing up the loopback interface..." + fi + + hostname "${HOSTNAME}" + if [ "${?}" -eq "0" ] + then + log_success_msg "Setting hostname to ${HOSTNAME}..." + else + log_failure_msg "Setting hostname to ${HOSTNAME}..." + fi + + ;; + + stop) + ip link set lo down + if [ "${?}" -eq "0" ] + then + log_success_msg "Bringing down the loopback interface..." + else + log_failure_msg "Bringing down the loopback interface..." + fi + + ;; + + restart) + ip link set lo down + retval="${?}" + sleep 1 + ip addr add 127.0.0.1/8 label lo dev lo + retval=$(( "${retval}" + "${?}" )) + ip link set lo up + retval=$(( "${retval}" + "${?}" )) + hostname "${HOSTNAME}" + retval=$(( "${retval}" + "${?}" )) + if [ "${retval}" -eq "0" ] + then + log_success_msg "Restarting local network..." + else + log_failure_msg "Restarting local network..." + fi + ;; + + status) + log_success_msg "Hostname is: ${INFO}$(hostname)${NORMAL}" + ip link show lo + ;; + + *) + echo "Usage: ${0} {start|stop|restart|status}" + exit 1 + ;; +esac + +# End /etc/init.d/localnet diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/modules b/bootscripts/contrib/lsb-v3/etc/init.d/modules new file mode 100644 index 000000000..2dd1d7212 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/modules @@ -0,0 +1,97 @@ +#!/bin/sh +# Begin /etc/init.d/modules + +### 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/sysconfig/modules. +# X-LFS-Provided-By: LFS +### END INIT INFO + +. /lib/lsb/init-functions + +# Assure that the kernel has module support. +[ -e /proc/ksyms -o -e /proc/modules ] || exit 0 + +case "${1}" in + start) + + # Exit if there's no modules file or there are no + # valid entries + [ -r /etc/sysconfig/modules ] && + egrep -qv '^($|#)' /etc/sysconfig/modules || + exit 0 + + # If proc is mounted, find the current kernel + # message level + if [ -f /proc/sys/kernel/printk ]; then + prev_msg=`cat /proc/sys/kernel/printk | \ + sed 'l 1' | sed -n '2~0p' | \ + sed 's/\\\//'` + else + prev_msg="6" + fi + + # Now set the message level to 1 so not to make too + # much noise when loading modules + dmesg -n 1 + + # Only try to load modules if the user has actually given us + # some modules to load. + if egrep -qv '^(#|$)' /etc/sysconfig/modules 2>/dev/null + then + + # Read in the configuration file. + exec 9>&0 < /etc/sysconfig/modules + + message="${INFO}Loading modules:" + + while read module args + do + # Ignore comments and blank lines. + case "${module}" in + ""|\#*) continue ;; + esac + + # Attempt to load the module, making + # sure to pass any arguments provided. + modprobe ${module} ${args} > /dev/null + + # Print the module name if successful, + # otherwise take note. + if [ ${?} -eq 0 ]; then + message="${message}${NORMAL} ${module}" + else + failedmod="${failedmod} ${module}" + fi + done + + # Print a message about successfully loaded + # modules on the correct line. + log_success_msg "${message}" + + # Print a failure message with a list of any + # modules that may have failed to load. + if [ "${failedmod}" ]; then + log_failure_msg "${FAILURE}Failed to load modules:${failedmod}" + fi + + exec 0>&9 9>&- + + fi + # Set the kernel message level back to it's previous value. + dmesg -n "${prev_msg}" + ;; + *) + echo "Usage: ${0} {start}" + exit 1 + ;; +esac + +# End /etc/init.d/modules diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/mountfs b/bootscripts/contrib/lsb-v3/etc/init.d/mountfs new file mode 100644 index 000000000..562db546a --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/mountfs @@ -0,0 +1,59 @@ +#!/bin/sh +# Begin /etc/init.d/mountfs + +### 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) + message="Remounting root file system in read-write mode..." + mount -n -o remount,rw / >/dev/null + evaluate_retval standard + + # Remove fsck-related file system watermarks. + rm -f /fastboot /forcefsck + + message="Recording existing mounts in /etc/mtab..." + > /etc/mtab + mount -f / || failed=1 + mount -f /proc || failed=1 + mount -f /sys || failed=1 + mount -f /run || failed=1 + (exit ${failed}) + evaluate_retval standard + + # This will mount all filesystems that do not have _netdev in + # their option list. _netdev denotes a network filesystem. + message="Mounting remaining file systems..." + mount -a -O no_netdev >/dev/null + evaluate_retval standard + ;; + + stop) + message="Unmounting all other currently mounted file systems..." + umount -a -d -r >/dev/null + evaluate_retval standard + ;; + + *) + echo "Usage: ${0} {start|stop}" + exit 1 + ;; +esac + +# End /etc/init.d/mountfs diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/mountvirtfs b/bootscripts/contrib/lsb-v3/etc/init.d/mountvirtfs new file mode 100644 index 000000000..e458f9c7f --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/mountvirtfs @@ -0,0 +1,49 @@ +#!/bin/sh +# Begin /etc/init.d/mountvirtfs + +### BEGIN INIT INFO +# Provides: mountvirtfs +# Required-Start: +# Should-Start: +# Required-Stop: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Mounts /sys, /proc, and /run virtual (virtel) filesystems. +# Description: Mounts /sys, /proc, and run virtual (virtel) filesystems. +# X-LFS-Provided-By: LFS +### END INIT INFO + +. /lib/lsb/init-functions + +case "${1}" in + start) + message="Mounting virtel-based file systems:" + + if ! mountpoint /proc > /dev/null; then + message="${message}${INFO} /proc${NORMAL}" + mount -n /proc || failed=1 + fi + + if ! mountpoint /sys > /dev/null; then + message="${message}${INFO} /sys${NORMAL}" + mount -n /sys || failed=1 + fi + + if ! mountpoint /run > /dev/null; then + message="${message}${INFO} /run${NORMAL}" + mount -n /run || failed=1 + mkdir /run/{var,lock,shm} || failed=1 + fi + + (exit ${failed}) + evaluate_retval standard + ;; + + *) + echo "Usage: ${0} {start}" + exit 1 + ;; +esac + +# End /etc/init.d/mountvirtfs diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/network b/bootscripts/contrib/lsb-v3/etc/init.d/network new file mode 100644 index 000000000..29d4d54c8 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/network @@ -0,0 +1,71 @@ +#!/bin/sh +# Begin /etc/init.d/network + +### 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 +. /etc/sysconfig/network + +case "${1}" in + start) + # Start all network interfaces + for file in ${NETWORK_DEVICES}/ifconfig.* + do + interface=${file##*/ifconfig.} + + # skip if $file is * (because nothing was found) + if [ "${interface}" = "*" ] + then + continue + fi + IN_BOOT=1 ${NETWORK_DEVICES}/ifup ${interface} + done + ;; + + stop) + # Reverse list + FILES="" + for file in ${NETWORK_DEVICES}/ifconfig.* + do + FILES="${file} ${FILES}" + done + + # Stop all network interfaces + for file in ${FILES} + do + interface=${file##*/ifconfig.} + + # skip if $file is * (because nothing was found) + if [ "${interface}" = "*" ] + then + continue + fi + + IN_BOOT=1 ${NETWORK_DEVICES}/ifdown ${interface} + done + ;; + + restart) + ${0} stop + sleep 1 + ${0} start + ;; + + *) + echo "Usage: ${0} {start|stop|restart}" + exit 1 + ;; +esac + +# End /etc/init.d/network diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/rc b/bootscripts/contrib/lsb-v3/etc/init.d/rc new file mode 100644 index 000000000..24e26ee07 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/rc @@ -0,0 +1,196 @@ +#!/bin/sh +# Begin $RC_BASE/init.d/rc + +# Get the configuration file +# All changes are to occur in the config file +. /etc/sysconfig/rc + +# These 3 signals will not cause our script to exit +trap "" INT QUIT TSTP + +# Simple sanity check - rc only takes one argument +if [ "${#}" -ne 1 ]; then + echo "Usage: ${0} " >&2 + exit 1 +fi + +# Do not use the RUNLEVEL and PREVLEVEL variables provided by init so +# that they can be modified and alternate directories (S) can +# be used without affecting init +runlevel="${1}" +prevlevel="${PREVLEVEL}" + +# Just in case - some flavors of init don't set PREVLEVEL to 'N' +if [ "${prevlevel}" = "" ]; then + prevlevel="N" +fi + +# Mount a tmpfs to store boot accounting information +if [ "${runlevel}" = "S" -a "${TEMPFS_MOUNT}" != "" ]; then + mount -n -t tmpfs tmpfs "${TEMPFS_MOUNT}" -o mode=600 +fi + +# Provide an interactive prompt (if requested) +if [ "${runlevel}" = "S" -a "${iprompt}" = "yes" ]; then + # ash does not accept t and n flags for read + ls -l /bin/sh | grep "/ash" + if [ "${?}" -eq "0" ]; then + # We are using ash + echo -e -n "${WARNING}WARNING: Either bash or zsh is required" + echo -e "${WARNING} for interactive startup.\n" + sleep 3 + else + echo "" + # dcol and icol are spaces before the message to center the + # message on screen. + dcol=$(( $(( ${COLUMNS} - ${dlen} )) / 2 )) + icol=$(( $(( ${COLUMNS} - ${ilen} )) / 2 )) + echo -e "\\033[${dcol}G${welcome_message}" + echo -e "\\033[${icol}G${i_message}${NORMAL}" + echo "" + read -t "${itime}" -n 1 interactive 2>&1 > /dev/null + if [ "${interactive}" = "I" -o "${interactive}" = "i" ]; then + echo -n -e "${CURS_UP}" + echo -e "${INFO}Interactive boot selected...${NORMAL}" + echo "interactive=I" > "${TEMPFS_MOUNT}/.interactive-start" + fi + fi +fi + + +# Verify that the directory exists +if [ ! -d "${RC_BASE}/rc${runlevel}.d" ]; then + echo -n -e "${WARNING}${RC_BASE}/rc${runlevel}.d does not exist." + echo -e "${NORMAL}" + exit 1 +fi + +# Source the interactive state file if it exists +if [ "${runlevel}" != "S" -a -f "${TEMPFS_MOUNT}/.interactive-start" ]; then + . "${TEMPFS_MOUNT}/.interactive-start" +fi + +# Prompt for interactive startup after completing S +if [ "${interactive}" = "I" -a "${runlevel}" != "S" -a \ + "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then + echo -n -e "Proceed with interactive starup of runlevel " + echo -n -e "${INFO}${runlevel}${NORMAL}?" + echo -n -e "(${FAILURE}y${NORMAL})es/(${FAILURE}n${NORMAL})o " + read -n 1 go_on + echo "" + if [ "${go_on}" = "n" ]; then + # don't continue + exit 0 + fi +fi + + +# Attempt to stop all services started in the previous runlevel, +# that are stopped in this runlevel +if [ "${prevlevel}" != "N" ]; then + for link in $(ls -v ${RC_BASE}/rc${runlevel}.d/K* 2> /dev/null) + do + # Check to see if link is a valid symlink + if [ ! -f ${link} ]; then + echo -e "${WARNING}${link} is not a valid symlink." + continue # go on to the next K* link + fi + + # Check to see if link is executable + if [ ! -x ${link} ]; then + echo -e "${WARNING}${link} is not executable, skipping." + continue # go on to the next K* link + fi + + script=${link#$RC_BASE/rc$runlevel.d/K[0-9][0-9]} + prev_start=$RC_BASE/rc$prevlevel.d/S[0-9][0-9]$script + S_start=$RC_BASE/rcS.d/S[0-9][0-9]$script + + if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then + if [ ! -f ${prev_start} ] && [ ! -f ${S_start} ]; then + echo -e -n "${WARNING}WARNING:\n\n${link} can't be" + echo -e "${WARNING} executed because it was not" + echo -e -n "${WARNING} not started in the previous" + echo -e "${WARNING} runlevel (${prevlevel})." + echo -e "${NORMAL}" + continue + fi + fi + ${link} stop + error_value=${?} + + if [ "${error_value}" -ne "0" ]; then + print_error_msg + fi + done +fi + +# Start all functions in this runlevel if they weren't started in +# the previous runlevel +for link in $(ls -v ${RC_BASE}/rc${runlevel}.d/S* 2> /dev/null) +do + if [ "${prevlevel}" != "N" ]; then + script=${link#$RC_BASE/rc$runlevel.d/S[0-9][0-9]} + stop=$RC_BASE/rc$runlevel.d/K[0-9][0-9]$script + prev_start=$RC_BASE/rc$prevlevel.d/S[0-9][0-9]$script + + [ -f ${prev_start} ] && [ ! -f ${stop} ] && continue + fi + + # Check to see if link is a valid symlink + if [ ! -f ${link} ]; then + echo -e "${WARNING}${link} is not a valid symlink." + continue # go on to the next K* link + fi + + # Check to see if link is executable + if [ ! -x ${link} ]; then + echo -e "${WARNING}${link} is not executable, skipping." + continue # go on to the next K* link + fi + + case ${runlevel} in + 0|6) + ${link} stop + ;; + + *) + if [ "${interactive}" = "I" -o "${interactive}" = "i" ]; then + echo -e -n "${WARNING}Start ${INFO}${link} ${WARNING}?" + echo -e -n "${NORMAL}(${FAILURE}y${NORMAL})es/(${FAILURE}n${NORMAL})o " + read -n 1 startit 2>&1 > /dev/null + echo "" + if [ "${startit}" = "y" -o "${startit}" = "Y" ]; then + ${link} start + else + echo -e -n "${WARNING}Not starting ${INFO}${link}" + echo -e "${WARNING}.${NORMAL}\n" + fi + else + ${link} start + fi + ;; + esac + error_value=${?} + + if [ "${error_value}" -gt "1" ]; then + print_error_msg + fi +done + +# Strip apply time to the logs, strip out any color codes and dump +# the log to /var/log/boot.log +if [ -f "${TEMPFS_MOUNT}/.bootlog" -a "${runlevel}" != "S" ]; then + # Remove any color codes from the temp log file + sed -i 's@\\033\[[0-9];[0-9][0-9]m@@g' "${TEMPFS_MOUNT}/.bootlog" + #Fix the time and hostname + BTIMESPEC=$(echo `date +"%b %d %T"` `hostname`) + sed -i "s@^bootlog:@${BTIMESPEC} bootlog:@" "${TEMPFS_MOUNT}/.bootlog" + # Don't try and write in 0 and 6, this is a 'boot' log + if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then + cat "${TEMPFS_MOUNT}/.bootlog" >> /var/log/boot.log + rm -f "${TEMPFS_MOUNT}/.bootlog" + fi +fi + +# End $RC_BASE/init.d/rc diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/reboot b/bootscripts/contrib/lsb-v3/etc/init.d/reboot new file mode 100644 index 000000000..56e948a3f --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/reboot @@ -0,0 +1,32 @@ +#!/bin/sh +# Begin /etc/init.d/reboot + +### 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_success_msg "Restarting system..." + reboot -d -f -i + ;; + + *) + echo "Usage: ${0} {stop}" + exit 1 + ;; + +esac + +# End /etc/init.d/reboot diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/sendsignals b/bootscripts/contrib/lsb-v3/etc/init.d/sendsignals new file mode 100644 index 000000000..2cd9df84a --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/sendsignals @@ -0,0 +1,54 @@ +#!/bin/sh +# Begin /etc/init.d/sendsignals + +### 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) + message="Sending all processes the TERM signal..." + killall5 -15 + error_value=${?} + # Account for successful return value of 2 + if [ ${error_value} -eq 2 ]; then + error_value=0 + fi + sleep 3 + + (exit ${error_value}) + evaluate_retval standard + + message="Sending all processes the KILL signal..." + killall5 -9 + error_value=${?} + # Account for successful return value of 2 + if [ ${error_value} -eq 2 ]; then + error_value=0 + fi + + sleep 3 + + (exit ${error_value}) + evaluate_retval standard + ;; + + *) + echo "Usage: ${0} {stop}" + exit 1 + ;; + +esac + +# End /etc/init.d/sendsignals diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/setclock b/bootscripts/contrib/lsb-v3/etc/init.d/setclock new file mode 100644 index 000000000..5d47b8dc8 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/setclock @@ -0,0 +1,54 @@ +#!/bin/sh +# Begin /etc/init.d/setclock + +### BEGIN INIT INFO +# Provides: hwclock +# Required-Start: +# Should-Start: modules +# Required-Stop: +# Should-Stop: $syslog +# Default-Start: +# 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 + +BIN_FILE="/sbin/hwclock" + +chk_stat + +case "${UTC}" in + yes|true|1) + CLOCKPARAMS="${CLOCKPARAMS} --utc" + ;; + + no|false|0) + CLOCKPARAMS="${CLOCKPARAMS} --localtime" + ;; + +esac + +case ${1} in + start) + message="Setting system clock..." + ${BIN_FILE} --hctosys ${CLOCKPARAMS} >/dev/null + evaluate_retval standard + ;; + + stop) + message="Setting hardware clock..." + ${BIN_FILE} --systohc ${CLOCKPARAMS} >/dev/null + evaluate_retval standard + ;; + + *) + echo "Usage: ${0} {start|stop}" + ;; + +esac + +# End /etc/init.d/setclock diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/swap b/bootscripts/contrib/lsb-v3/etc/init.d/swap new file mode 100644 index 000000000..31e5591e5 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/swap @@ -0,0 +1,55 @@ +#!/bin/sh +# Begin /etc/init.d/swap + +### 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) + message="Activating all swap files/partitions..." + swapon -a + evaluate_retval standard + ;; + + stop) + message="Deactivating all swap files/partitions..." + swapoff -a + evaluate_retval standard + ;; + + restart) + swapoff -a + error_level="${?}" + sleep 1 + swapon -a + error_level="$(( ${error_level} + ${?} ))" + (exit "${error_level}") + evaluate_retval restart + ;; + + status) + log_success_msg "Retrieving swap status..." + echo + swapon -s + ;; + + *) + echo "Usage: ${0} {start|stop|restart|status}" + exit 1 + ;; +esac + +# End /etc/init.d/swap diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/sysctl b/bootscripts/contrib/lsb-v3/etc/init.d/sysctl new file mode 100644 index 000000000..cccff126e --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/sysctl @@ -0,0 +1,39 @@ +#!/bin/sh +# Begin /etc/init.d/sysctl + +### 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 + message="Setting kernel runtime parameters..." + sysctl -q -p + evaluate_retval standard + fi + ;; + + status) + sysctl -a + ;; + + *) + echo "Usage: ${0} {start|status}" + exit 1 + ;; +esac + +# End /etc/init.d/sysctl diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/sysklogd b/bootscripts/contrib/lsb-v3/etc/init.d/sysklogd new file mode 100644 index 000000000..dc8829f07 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/sysklogd @@ -0,0 +1,69 @@ +#!/bin/sh +# Begin /etc/init.d/sysklogd + +### 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) + MESSAGE="system log daemon..." + start_daemon /sbin/syslogd -m 0 + evaluate_retval start + + MESSAGE="kernel log daemon..." + start_daemon /sbin/klogd + evaluate_retval start + ;; + + stop) + MESSAGE="kernel log daemon..." + killproc /sbin/klogd + evaluate_retval stop + + MESSAGE="system log daemon..." + killproc /sbin/syslogd + evaluate_retval stop + ;; + + force-reload) + MESSAGE="system log daemon config file..." + killproc -HUP `/sbin/syslogd` + evaluate_retval reload + ;; + + restart) + MESSAGE="system and kernel log deamons..." + failed=0 + killproc /sbin/klogd || failed=1 + killproc /sbin/syslogd || failed=1 + start_daemon /sbin/syslogd -m 0 || failed=1 + start_daemon /sbin/klogd || failed=1 + (exit ${failed}) + evaluate_retval restart + ;; + + status) + statusproc /sbin/syslogd + statusproc /sbin/klogd + ;; + + *) + echo "Usage: ${0} {start|stop|force-reload|restart|status}" + exit 1 + ;; +esac + +# End /etc/init.d/sysklogd diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/template b/bootscripts/contrib/lsb-v3/etc/init.d/template new file mode 100644 index 000000000..cb3222a35 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/template @@ -0,0 +1,90 @@ +#!/bin/sh +# Begin /etc/init.d/template + +### 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 + +# Source the LSB init-functions, ours are pulled in from there. +. /lib/lsb/init-functions + +# These are optional, but required for chk_stat. They will be used in +# the rest of the functions if defined, else you must provide a program +# name to control, and a message ('Starting Template Service...' +# or 'Stoping Template Service...') to evauate_retval. See the +# documentaion in the lfs-fucntions file for more information. +MESSAGE="Template Service" +BIN_FILE="/some/path/to/template" +CONFIGFILE="/etc/sysconfig/template.conf" + +# check that $BIN_FILE exists and is executable, and $CONFIGFILE exists. +chk_stat + +# LSB Defined functions require that at least $BIN_FILE be passed to them, +# where as lfs-functions will use the $BIN_FILE environment variable. +# loadproc() and endproc() are just wrappers that pass everything on to +# the LSB defined functions. + +case "${1}" in + start) + #start_daemon "${BIN_FILE}" -arg1 -arg2 #... or: + loadproc -arg1 -arg2 -arg3 #... + evaluate_retval start + ;; + + stop) + #killproc -TERM "${BIN_FILE}" or: + endproc + evaluate_retval stop + ;; + + force-reload) + reloadproc -force + evaluate_retval force-reload + ;; + + restart) + $0 stop + $0 start + ;; + + status) + statusproc + ;; + +# reload and try-restart are optional per LSB requirements + reload) + reloadproc + evaluate_retval reload + ;; + + try-restart) + # Since this is optional there is no lfs-function for this one... + # might be at a later time if used enough, but I doubt it usefullness. + pidofproc "${BIN_FILE}" > /dev/null + if [ "${?}" -ne "0" ]; then + MESSAGE="${MESSAGE}: Not Running" + else + $0 stop + $0 start + exit 0 + fi + evaluate_retval try-restart + ;; + + *) + echo "Usage: ${0} {start|stop|{force-}reload|{try-}restart|status}" + exit 1 + ;; +esac + +# End /etc/init.d/template diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/udev b/bootscripts/contrib/lsb-v3/etc/init.d/udev new file mode 100644 index 000000000..ac91fccf3 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/udev @@ -0,0 +1,85 @@ +#!/bin/sh +# Begin $rc_base/init.d/udev + +### BEGIN INIT INFO +# Provides: udev +# Required-Start: +# Should-Start: modules +# Required-Stop: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Populated /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 + +MESSAGE="Populating /dev with device nodes..." + +case "${1}" in + start) + if ! grep -q '[[:space:]]sysfs' /proc/mounts; then + echo_failure + boot_mesg -n "FAILURE:\n\nUnable to create" ${FAILURE} + boot_mesg -n " devices without a SysFS filesystem" + boot_mesg -n "\n\nAfter you press Enter, this system" + boot_mesg -n " will be halted and powered off." + boot_mesg -n "\n\nPress Enter to continue..." ${INFO} + boot_mesg "" ${NORMAL} + $FAILURE_ACTION + /etc/rc.d/init.d/halt stop + fi + + # Mount a temporary file system over /dev, so that any devices + # made or removed during this boot don't affect the next one. + # The reason we don't write to mtab is because we don't ever + # want /dev to be unavailable (such as by `umount -a'). + if ! mountpoint /dev > /dev/null; then + mount -n -t tmpfs tmpfs /dev -o mode=755 + fi + if [ ${?} -ne 0 ]; then + echo_failure + boot_mesg -n "FAILURE:\n\nCannot mount a tmpfs" ${FAILURE} + boot_mesg -n " onto /dev, this system will be halted." + boot_mesg -n "\n\nAfter you press Enter, this system" + boot_mesg -n " will be halted and powered off." + boot_mesg -n "\n\nPress Enter to continue..." ${INFO} + boot_mesg "" ${NORMAL} + $FAILURE_ACTION + /etc/rc.d/init.d/halt stop + fi + + # Create a symlink for POSIX shared memory + ln -s /run/shm /dev/shm + + # Udev handles uevents itself, so we don't need to have + # the kernel call out to any binary in response to them + echo > /proc/sys/kernel/hotplug + + # Copy the only static device node that Udev >= 155 doesn't + # handle to /dev + cp -a /lib/udev/devices/null /dev + + # 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 + + # Now wait for udevd to process the uevents we triggered + /sbin/udevadm settle + evaluate_retval standard + ;; + + *) + echo "Usage ${0} {start}" + exit 1 + ;; +esac + +# End $rc_base/init.d/udev diff --git a/bootscripts/contrib/lsb-v3/etc/init.d/udev_retry b/bootscripts/contrib/lsb-v3/etc/init.d/udev_retry new file mode 100644 index 000000000..24b956ae0 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/etc/init.d/udev_retry @@ -0,0 +1,49 @@ +#!/bin/sh +# Begin $rc_base/init.d/udev_retry + +### BEGIN INIT INFO +# Provides: udev_retry +# Required-Start: udev +# Should-Start: $local_fs +# Required-Stop: +# Should-Stop: +# Default-Start: S +# Default-Stop: +# Short-Description: Replays failed uevents and creates additonal devices. +# Description: Replays any failed uevents that were skipped due to +# slow hardware initialization, and creates those needed +# device nodes +# X-LFS-Provided-By: LFS +### END INIT INFO + +. /lib/lsb/init-functions + +MESSAGE="Retrying failed uevents, if any..." + +case "${1}" in + start) + + # From Debian: "copy the rules generated before / was mounted + # read-write": + for file in /dev/.udev/tmp-rules--*; do + dest=${file##*tmp-rules--} + [ "$dest" = '*' ] && break + cat $file >> /etc/udev/rules.d/$dest + rm -f $file + done + + # Re-trigger the failed uevents in hope they will succeed now + /sbin/udevadm trigger --type=failed --action=add + + # Now wait for udevd to process the uevents we triggered + /sbin/udevadm settle + evaluate_retval standard + ;; + + *) + echo "Usage ${0} {start}" + exit 1 + ;; +esac + +# End $rc_base/init.d/udev_retry diff --git a/bootscripts/contrib/lsb-v3/init.d/checkfs b/bootscripts/contrib/lsb-v3/init.d/checkfs deleted file mode 100644 index 1e3efed9b..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/checkfs +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/checkfs - -### BEGIN INIT INFO -# Provides: checkfs -# Required-Start: udev swap -# 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 - echo "${INFO}/fastboot found!" - log_success_msg "Will not perform file system checks as requested." - exit 0 - fi - - mount -n -o remount,ro / >/dev/null - if [ ${?} -ne 0 ] - then - log_failure_msg "Mounting root file system in read-only mode" - echo -e "${FAILURE}FAILURE:\n" - echo -e -n "${FAILURE}Cannot check root filesystem because it " - echo -e "${FAILURE}could not be mounted" - echo -e "${FAILURE}in read-only mode.\n\n" - echo -e -n "${FAILURE}After you press Enter, this system will be " - echo -e "${FAILURE}halted and powered off.\n" - echo -e "${INFO}Press enter to continue...${NORMAL}" - $FAILURE_ACTION - /etc/rc.d/init.d/halt stop - fi - - if [ -f /forcefsck ] - then - echo "${INFO}/forcefsck found!" - log_success_msg "${INFO}Forcing file system checks as requested." - options="-f" - else - options="" - fi - - # Note: -a option used to be -p; but this fails e.g. - # on fsck.minix - fsck ${options} -a -A -C -T - error_value=${?} - - if [ "${error_value}" -eq 0 ] - then - log_success_msg "Checking file systems..." - elif [ "${error_value}" -eq 1 ] - then - log_warning_msg "Checking file systems..." - echo -e "${WARNING}WARNING:\n" - echo -e "${WARNING}File system errors were found and have been" - echo -e "${WARNING}corrected. You may want to double-check that" - echo -e "${WARNING}everything was fixed properly.${NORMAL}" - elif [ "${error_value}" -eq 2 -o "${error_value}" -eq 3 ]; then - log_warning_msg "Checking file systems..." - echo -e "${WARNING}WARNING:\n" - echo -e "${WARNING}File system errors were found and have been been" - echo -e "${WARNING}corrected, but the nature of the errors require" - echo -e "${WARNING}this system to be rebooted.\n" - echo -e "After you press enter, this system will be rebooted.\n" - echo -e "${INFO}Press Enter to continue...${NORMAL}" - $FAILURE_ACTION - reboot -f - elif [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then - log_failure_msg "Checking file systems..." - echo -e "${FAILURE}FAILURE:\n" - echo -e "${FAILURE}File system errors were encountered that could" - echo -e "${FAILURE}not be fixed automatically. This system cannot" - echo -e "${FAILURE}continue to boot and will therefore be halted" - echo -e "${FAILURE}until those errors are fixed manually by a" - echo -e "${FAILURE}System Administrator.\n" - echo -e "${FAILURE}After you press Enter, this system will be" - echo -e "${FAILURE}halted and powered off.\n" - echo -e "${INFO}Press Enter to continue...${NORMAL}" - $FAILURE_ACTION - /etc/rc.d/init.d/halt stop - elif [ "${error_value}" -ge 16 ]; then - log_failure_msg "Checking file systems..." - echo -e "${FAILURE}FAILURE:\n" - echo -e "${FAILURE}Unexpected Failure running fsck. Exited with error" - echo -e "${FAILURE}code: ${error_value}.${NORMAL}" - exit ${error_value} - fi - ;; - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -# End /etc/init.d/checkfs diff --git a/bootscripts/contrib/lsb-v3/init.d/cleanfs b/bootscripts/contrib/lsb-v3/init.d/cleanfs deleted file mode 100644 index 96582c28c..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/cleanfs +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/cleanfs - -### 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 temporary directories /var/run, /var/lock, and -# /tmp. cleanfs also creates /var/run/utmp and any files -# defined in /etc/sysconfig/createfiles. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -# Function to create files/directory on boot. -create_files() -{ - # Read in the configuration file. - exec 9>&0 < /etc/sysconfig/createfiles - while read name type perm usr grp dtype maj min junk - do - # Ignore comments and blank lines. - case "${name}" in - ""|\#*) continue ;; - esac - - # Ignore existing files. - if [ ! -e "${name}" ] - then - # Create stuff based on its type. - case "${type}" in - dir) - mkdir "${name}" - ;; - file) - :> "${name}" - ;; - dev) - case "${dtype}" in - char) - mknod "${name}" c ${maj} ${min} - ;; - block) - mknod "${name}" b ${maj} ${min} - ;; - pipe) - mknod "${name}" p - ;; - *) - echo -e -n "\n${WARNING}Unknown device type: ${dtype}" - echo -e "${NORMAL}" - ;; - esac - ;; - *) - echo -e "\n${WARNING}Unknown type: ${type}${NORMAL}" - continue - ;; - esac - - # Set up the permissions, too. - chown ${usr}:${grp} "${name}" - chmod ${perm} "${name}" - fi - done - exec 0>&9 9>&- -} - -case "${1}" in - start) - message="Cleaning file systems: " - - message="${message}${INFO} /tmp" - find /tmp -xdev -mindepth 1 ! -name lost+found \ - -delete || failed=1 - - > /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 standard - - if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null - then - message="Creating files and directories..." - create_files - evaluate_retval standard - fi - ;; - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -# End /etc/init.d/cleanfs - diff --git a/bootscripts/contrib/lsb-v3/init.d/console b/bootscripts/contrib/lsb-v3/init.d/console deleted file mode 100644 index 8b26f57d5..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/console +++ /dev/null @@ -1,96 +0,0 @@ -#!/bin/sh -# Begin $rc_base/init.d/console - -### 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/sysconfig/console. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -MESSAGE="Setting up Linux console..." - -# Native English speakers probably don't have /etc/sysconfig/console at all -if [ -f /etc/sysconfig/console ] -then - . /etc/sysconfig/console -fi - -is_true() { - [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] -} - -failed=0 - -case "${1}" in - start) - # There should be no bogus failures below this line! - - # 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. - # FIXME: Fedora Core also initializes two spare consoles - # - do we want that? - - 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 - is_true "${USE_FB}" || [ -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 standard - ;; - *) - echo $"Usage:" "${0} {start}" - exit 1 - ;; -esac - -# End $rc_base/init.d/console diff --git a/bootscripts/contrib/lsb-v3/init.d/halt b/bootscripts/contrib/lsb-v3/init.d/halt deleted file mode 100644 index cdcd90778..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/halt +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -# Begin $RC_BASE/init.d/halt - -### 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 - -. /lib/lsb/init-functions - -case "${1}" in - stop) - log_success_msg "Halting System..." - halt -d -f -i -p - ;; - *) - echo "Usage: {stop}" - exit 1 - ;; -esac - -# End /etc/init.d/halt diff --git a/bootscripts/contrib/lsb-v3/init.d/lfs-functions b/bootscripts/contrib/lsb-v3/init.d/lfs-functions deleted file mode 100644 index b0fef4c29..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/lfs-functions +++ /dev/null @@ -1,214 +0,0 @@ -# Begin /etc/init.d/lfs-functions -# Provides LFS specific functions for LSB style bootscripts - -################################# chkstat() ################################### -# chk_stat checks the status of a script by checking for both a binary file # -# to execute, and if set, a config file that may be needed for the program # -# to run successfully. The calling script will exit with a return value of 5 # -# if the binary does not exist, and a value of 6 if the needed config file is # -# unavailable as per LSB requirements. This function accepts zero, one, or # -# two string arguments. If arguments are passed, the first must be a bin # -# file. If a second argument is passed, it is interpreted as the config # -# file. Optionally, zero arguments can be passed if BIN_FILE, and optinally # -# CONFIG_FILE are set in the calling script. # -############################################################################### -chk_stat() -{ - if [ "${#}" -gt "0" -a "${#}" -lt "3" ]; then - BIN_FILE="${1}" - if [ -z "${2}" ]; then - CONFIG_FILE="" - else - CONFIG_FILE="${2}" - fi - elif [ -z "${BIN_FILE}" ]; then - echo "Usage: 'chk_stat BIN_FILE CONFIG_FILE'" - exit 1 # Generic Error - fi - - if [ ! -e "${BIN_FILE}" ]; then - log_failure_msg "${BIN_FILE} not installed" && - exit 5 - fi - - if [ ! -z "${CONFIG_FILE}" ]; then - if [ ! -e "${CONFIG_FILE}" ]; then - log_failure_msg "${CONFIG_FILE} does not exist" && - exit 6 - fi - fi -} - -################################ loadproc() ################################### -# loadproc is just a wraper to start_daemon for simple scripts, which will # -# require no arguments if $BIN_FILE is set. # -############################################################################### -loadproc() -{ - start_daemon "${BIN_FILE}" "${@}" -} - -################################ endproc() #################################### -# endproc, like loadproc, is just a wraper to killproc for simplicity and is # -# dependent on $BIN_FILE being set. # -############################################################################### -endproc() -{ - killproc "${BIN_FILE}" "${@}" -} - -############################### statusproc() ################################## -# statusproc checks the status of a particular binary and displays the # -# appropriate message (running or not running) and exits on the return value # -# of pidofproc. This function accepts two string arguments or zero arguments # -# if BIN_FILE and MESSAGE are set, else it requires the bin file as the first # -# argument, and the message as the second. Both must be enclosed in quotes. # -############################################################################### -statusproc() -{ - if [ "${#}" -gt "0" -a "${#}" -lt "3" ]; then - BIN_FILE="${1}" - MESSAGE="${2}" - elif [ -z "${BIN_FILE}" -o -z "${MESSAGE}" ]; then - echo "Usage: 'statusproc BIN_FILE MESSAGE'" - exit 1 # Generic Error - fi - - pidlist=`pidofproc "${BIN_FILE}"` - STATUS=$? - echo "Checking ${MESSAGE} status:" - if [ "${STATUS}" -eq "0" ]; then - log_success_msg "Running with PID(s) ${pidlist}" - else - log_warning_msg "Not running!" - fi - - return "${STATUS}" -} - -############################### reloadproc() ################################## -# reloadproc sends a HUP signal to the running program (relaod configuration) # -# It optionally, using the -force switch, checks the status of a particular # -# program and starts it if it is not already running. This function accepts # -# one optional switch (must be the first argument), and either two, or zero # -# string arguments. If BIN_FILE and MESSAGE are set in the script's # -# environment, it will use those values, else it requires the bin file as # -# the first argument (following -force if used), and the message as the # -# second. Both must be enclosed in quotes. If the force option is used, it # -# follows the LSB definition of 'force-reload' - the program is started if # -# not already running. # -############################################################################### -reloadproc() -{ - local force="0" - if [ "${#}" -gt "0" -a "${1}" = "-force" ]; then - force="1" - shift 1 - fi - - if [ "${#}" -gt "0" -a "${#}" -lt "3" ]; then - BIN_FILE="${1}" - MESSAGE="${2}" - elif [ -z "${BIN_FILE}" -o -z "${MESSAGE}" ]; then - echo "Usage: 'reloadproc BIN_FILE MESSAGE'" - exit 1 # Generic Error - fi - - - -} - -############################## evaluate_retval() ############################### -# evaluate_retval requires that you pass exactly one evaluation parameter of # -# (start, stop, other) based on the previous action that is being evaluated. # -# This function is intended for use with start_daemon and killproc to # -# interpret the LSB exit codes properly, othewise the checks only for success # -# or failure. # -################################################################################ -evaluate_retval() -{ - local error_value="${?}" - - # Handle LSB defined return values - case "${1}" in - - start) - case "${error_value}" in - 0) - log_success_msg "Starting ${MESSAGE} " - return "${error_value}" - ;; - 2) - log_failure_msg "Starting ${MESSAGE} Error: Invalid argument!" - return "${error_value}" - ;; - 5) - log_failure_msg "Starting ${MESSAGE} Error: Not available!" - return "${error_value}" - ;; - *) - log_failure_msg "Starting ${MESSAGE} Error: General failure!" - return "${error_value}" - ;; - esac - ;; - - stop) - case "${error_value}" in - 0) - log_success_msg "Stopping ${MESSAGE} " - return "${error_value}" - ;; - 2) - log_failure_msg "Stopping ${MESSAGE} Error: Invalid argument!" - return "${error_value}" - ;; - 5) - log_failure_msg "Stopping ${MESSAGE} Error: Not available!" - return "${error_value}" - ;; - 7) - log_warning_msg "Stopping ${MESSAGE} Warning: Not running!" - return "${error_value}" - ;; - *) - log_failure_msg "Stopping ${MESSAGE} Error: General failure!" - return "${error_value}" - ;; - esac - ;; - - force-reload) - message="Forcefully reloading " - ;; - - reload) - message="Reloading " - ;; - - restart) - message="Restarting " - ;; - - try-restart) - message="Trying restart " - ;; - - standard) - # $message or $MESSAGE must be set, but not both in order - # to use the 'standard' target. - ;; - esac - - # Print messages for the generic force-reload, reload, restart, - # and try-restart targets - if [ "${error_value}" -eq "0" ] - then - log_success_msg "${message}${MESSAGE} " - return "${error_value}" - else - log_failure_msg "${message}${MESSAGE} " - return "${error_value}" - fi -} - diff --git a/bootscripts/contrib/lsb-v3/init.d/localnet b/bootscripts/contrib/lsb-v3/init.d/localnet deleted file mode 100644 index 322bb8749..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/localnet +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/localnet - -### 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 - -case "${1}" in - start) - ip addr add 127.0.0.1/8 label lo dev lo - ip link set lo up - if [ "${?}" -eq "0" ] - then - log_success_msg "Bringing up the loopback interface..." - else - log_failure_msg "Bringing up the loopback interface..." - fi - - hostname "${HOSTNAME}" - if [ "${?}" -eq "0" ] - then - log_success_msg "Setting hostname to ${HOSTNAME}..." - else - log_failure_msg "Setting hostname to ${HOSTNAME}..." - fi - - ;; - - stop) - ip link set lo down - if [ "${?}" -eq "0" ] - then - log_success_msg "Bringing down the loopback interface..." - else - log_failure_msg "Bringing down the loopback interface..." - fi - - ;; - - restart) - ip link set lo down - retval="${?}" - sleep 1 - ip addr add 127.0.0.1/8 label lo dev lo - retval=$(( "${retval}" + "${?}" )) - ip link set lo up - retval=$(( "${retval}" + "${?}" )) - hostname "${HOSTNAME}" - retval=$(( "${retval}" + "${?}" )) - if [ "${retval}" -eq "0" ] - then - log_success_msg "Restarting local network..." - else - log_failure_msg "Restarting local network..." - fi - ;; - - status) - log_success_msg "Hostname is: ${INFO}$(hostname)${NORMAL}" - ip link show lo - ;; - - *) - echo "Usage: ${0} {start|stop|restart|status}" - exit 1 - ;; -esac - -# End /etc/init.d/localnet diff --git a/bootscripts/contrib/lsb-v3/init.d/modules b/bootscripts/contrib/lsb-v3/init.d/modules deleted file mode 100644 index 2dd1d7212..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/modules +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/modules - -### 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/sysconfig/modules. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -# Assure that the kernel has module support. -[ -e /proc/ksyms -o -e /proc/modules ] || exit 0 - -case "${1}" in - start) - - # Exit if there's no modules file or there are no - # valid entries - [ -r /etc/sysconfig/modules ] && - egrep -qv '^($|#)' /etc/sysconfig/modules || - exit 0 - - # If proc is mounted, find the current kernel - # message level - if [ -f /proc/sys/kernel/printk ]; then - prev_msg=`cat /proc/sys/kernel/printk | \ - sed 'l 1' | sed -n '2~0p' | \ - sed 's/\\\//'` - else - prev_msg="6" - fi - - # Now set the message level to 1 so not to make too - # much noise when loading modules - dmesg -n 1 - - # Only try to load modules if the user has actually given us - # some modules to load. - if egrep -qv '^(#|$)' /etc/sysconfig/modules 2>/dev/null - then - - # Read in the configuration file. - exec 9>&0 < /etc/sysconfig/modules - - message="${INFO}Loading modules:" - - while read module args - do - # Ignore comments and blank lines. - case "${module}" in - ""|\#*) continue ;; - esac - - # Attempt to load the module, making - # sure to pass any arguments provided. - modprobe ${module} ${args} > /dev/null - - # Print the module name if successful, - # otherwise take note. - if [ ${?} -eq 0 ]; then - message="${message}${NORMAL} ${module}" - else - failedmod="${failedmod} ${module}" - fi - done - - # Print a message about successfully loaded - # modules on the correct line. - log_success_msg "${message}" - - # Print a failure message with a list of any - # modules that may have failed to load. - if [ "${failedmod}" ]; then - log_failure_msg "${FAILURE}Failed to load modules:${failedmod}" - fi - - exec 0>&9 9>&- - - fi - # Set the kernel message level back to it's previous value. - dmesg -n "${prev_msg}" - ;; - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -# End /etc/init.d/modules diff --git a/bootscripts/contrib/lsb-v3/init.d/mountfs b/bootscripts/contrib/lsb-v3/init.d/mountfs deleted file mode 100644 index 562db546a..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/mountfs +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/mountfs - -### 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) - message="Remounting root file system in read-write mode..." - mount -n -o remount,rw / >/dev/null - evaluate_retval standard - - # Remove fsck-related file system watermarks. - rm -f /fastboot /forcefsck - - message="Recording existing mounts in /etc/mtab..." - > /etc/mtab - mount -f / || failed=1 - mount -f /proc || failed=1 - mount -f /sys || failed=1 - mount -f /run || failed=1 - (exit ${failed}) - evaluate_retval standard - - # This will mount all filesystems that do not have _netdev in - # their option list. _netdev denotes a network filesystem. - message="Mounting remaining file systems..." - mount -a -O no_netdev >/dev/null - evaluate_retval standard - ;; - - stop) - message="Unmounting all other currently mounted file systems..." - umount -a -d -r >/dev/null - evaluate_retval standard - ;; - - *) - echo "Usage: ${0} {start|stop}" - exit 1 - ;; -esac - -# End /etc/init.d/mountfs diff --git a/bootscripts/contrib/lsb-v3/init.d/mountvirtfs b/bootscripts/contrib/lsb-v3/init.d/mountvirtfs deleted file mode 100644 index e458f9c7f..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/mountvirtfs +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/mountvirtfs - -### BEGIN INIT INFO -# Provides: mountvirtfs -# Required-Start: -# Should-Start: -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Mounts /sys, /proc, and /run virtual (virtel) filesystems. -# Description: Mounts /sys, /proc, and run virtual (virtel) filesystems. -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -case "${1}" in - start) - message="Mounting virtel-based file systems:" - - if ! mountpoint /proc > /dev/null; then - message="${message}${INFO} /proc${NORMAL}" - mount -n /proc || failed=1 - fi - - if ! mountpoint /sys > /dev/null; then - message="${message}${INFO} /sys${NORMAL}" - mount -n /sys || failed=1 - fi - - if ! mountpoint /run > /dev/null; then - message="${message}${INFO} /run${NORMAL}" - mount -n /run || failed=1 - mkdir /run/{var,lock,shm} || failed=1 - fi - - (exit ${failed}) - evaluate_retval standard - ;; - - *) - echo "Usage: ${0} {start}" - exit 1 - ;; -esac - -# End /etc/init.d/mountvirtfs diff --git a/bootscripts/contrib/lsb-v3/init.d/network b/bootscripts/contrib/lsb-v3/init.d/network deleted file mode 100644 index 29d4d54c8..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/network +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/network - -### 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 -. /etc/sysconfig/network - -case "${1}" in - start) - # Start all network interfaces - for file in ${NETWORK_DEVICES}/ifconfig.* - do - interface=${file##*/ifconfig.} - - # skip if $file is * (because nothing was found) - if [ "${interface}" = "*" ] - then - continue - fi - IN_BOOT=1 ${NETWORK_DEVICES}/ifup ${interface} - done - ;; - - stop) - # Reverse list - FILES="" - for file in ${NETWORK_DEVICES}/ifconfig.* - do - FILES="${file} ${FILES}" - done - - # Stop all network interfaces - for file in ${FILES} - do - interface=${file##*/ifconfig.} - - # skip if $file is * (because nothing was found) - if [ "${interface}" = "*" ] - then - continue - fi - - IN_BOOT=1 ${NETWORK_DEVICES}/ifdown ${interface} - done - ;; - - restart) - ${0} stop - sleep 1 - ${0} start - ;; - - *) - echo "Usage: ${0} {start|stop|restart}" - exit 1 - ;; -esac - -# End /etc/init.d/network diff --git a/bootscripts/contrib/lsb-v3/init.d/rc b/bootscripts/contrib/lsb-v3/init.d/rc deleted file mode 100644 index 24e26ee07..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/rc +++ /dev/null @@ -1,196 +0,0 @@ -#!/bin/sh -# Begin $RC_BASE/init.d/rc - -# Get the configuration file -# All changes are to occur in the config file -. /etc/sysconfig/rc - -# These 3 signals will not cause our script to exit -trap "" INT QUIT TSTP - -# Simple sanity check - rc only takes one argument -if [ "${#}" -ne 1 ]; then - echo "Usage: ${0} " >&2 - exit 1 -fi - -# Do not use the RUNLEVEL and PREVLEVEL variables provided by init so -# that they can be modified and alternate directories (S) can -# be used without affecting init -runlevel="${1}" -prevlevel="${PREVLEVEL}" - -# Just in case - some flavors of init don't set PREVLEVEL to 'N' -if [ "${prevlevel}" = "" ]; then - prevlevel="N" -fi - -# Mount a tmpfs to store boot accounting information -if [ "${runlevel}" = "S" -a "${TEMPFS_MOUNT}" != "" ]; then - mount -n -t tmpfs tmpfs "${TEMPFS_MOUNT}" -o mode=600 -fi - -# Provide an interactive prompt (if requested) -if [ "${runlevel}" = "S" -a "${iprompt}" = "yes" ]; then - # ash does not accept t and n flags for read - ls -l /bin/sh | grep "/ash" - if [ "${?}" -eq "0" ]; then - # We are using ash - echo -e -n "${WARNING}WARNING: Either bash or zsh is required" - echo -e "${WARNING} for interactive startup.\n" - sleep 3 - else - echo "" - # dcol and icol are spaces before the message to center the - # message on screen. - dcol=$(( $(( ${COLUMNS} - ${dlen} )) / 2 )) - icol=$(( $(( ${COLUMNS} - ${ilen} )) / 2 )) - echo -e "\\033[${dcol}G${welcome_message}" - echo -e "\\033[${icol}G${i_message}${NORMAL}" - echo "" - read -t "${itime}" -n 1 interactive 2>&1 > /dev/null - if [ "${interactive}" = "I" -o "${interactive}" = "i" ]; then - echo -n -e "${CURS_UP}" - echo -e "${INFO}Interactive boot selected...${NORMAL}" - echo "interactive=I" > "${TEMPFS_MOUNT}/.interactive-start" - fi - fi -fi - - -# Verify that the directory exists -if [ ! -d "${RC_BASE}/rc${runlevel}.d" ]; then - echo -n -e "${WARNING}${RC_BASE}/rc${runlevel}.d does not exist." - echo -e "${NORMAL}" - exit 1 -fi - -# Source the interactive state file if it exists -if [ "${runlevel}" != "S" -a -f "${TEMPFS_MOUNT}/.interactive-start" ]; then - . "${TEMPFS_MOUNT}/.interactive-start" -fi - -# Prompt for interactive startup after completing S -if [ "${interactive}" = "I" -a "${runlevel}" != "S" -a \ - "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then - echo -n -e "Proceed with interactive starup of runlevel " - echo -n -e "${INFO}${runlevel}${NORMAL}?" - echo -n -e "(${FAILURE}y${NORMAL})es/(${FAILURE}n${NORMAL})o " - read -n 1 go_on - echo "" - if [ "${go_on}" = "n" ]; then - # don't continue - exit 0 - fi -fi - - -# Attempt to stop all services started in the previous runlevel, -# that are stopped in this runlevel -if [ "${prevlevel}" != "N" ]; then - for link in $(ls -v ${RC_BASE}/rc${runlevel}.d/K* 2> /dev/null) - do - # Check to see if link is a valid symlink - if [ ! -f ${link} ]; then - echo -e "${WARNING}${link} is not a valid symlink." - continue # go on to the next K* link - fi - - # Check to see if link is executable - if [ ! -x ${link} ]; then - echo -e "${WARNING}${link} is not executable, skipping." - continue # go on to the next K* link - fi - - script=${link#$RC_BASE/rc$runlevel.d/K[0-9][0-9]} - prev_start=$RC_BASE/rc$prevlevel.d/S[0-9][0-9]$script - S_start=$RC_BASE/rcS.d/S[0-9][0-9]$script - - if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then - if [ ! -f ${prev_start} ] && [ ! -f ${S_start} ]; then - echo -e -n "${WARNING}WARNING:\n\n${link} can't be" - echo -e "${WARNING} executed because it was not" - echo -e -n "${WARNING} not started in the previous" - echo -e "${WARNING} runlevel (${prevlevel})." - echo -e "${NORMAL}" - continue - fi - fi - ${link} stop - error_value=${?} - - if [ "${error_value}" -ne "0" ]; then - print_error_msg - fi - done -fi - -# Start all functions in this runlevel if they weren't started in -# the previous runlevel -for link in $(ls -v ${RC_BASE}/rc${runlevel}.d/S* 2> /dev/null) -do - if [ "${prevlevel}" != "N" ]; then - script=${link#$RC_BASE/rc$runlevel.d/S[0-9][0-9]} - stop=$RC_BASE/rc$runlevel.d/K[0-9][0-9]$script - prev_start=$RC_BASE/rc$prevlevel.d/S[0-9][0-9]$script - - [ -f ${prev_start} ] && [ ! -f ${stop} ] && continue - fi - - # Check to see if link is a valid symlink - if [ ! -f ${link} ]; then - echo -e "${WARNING}${link} is not a valid symlink." - continue # go on to the next K* link - fi - - # Check to see if link is executable - if [ ! -x ${link} ]; then - echo -e "${WARNING}${link} is not executable, skipping." - continue # go on to the next K* link - fi - - case ${runlevel} in - 0|6) - ${link} stop - ;; - - *) - if [ "${interactive}" = "I" -o "${interactive}" = "i" ]; then - echo -e -n "${WARNING}Start ${INFO}${link} ${WARNING}?" - echo -e -n "${NORMAL}(${FAILURE}y${NORMAL})es/(${FAILURE}n${NORMAL})o " - read -n 1 startit 2>&1 > /dev/null - echo "" - if [ "${startit}" = "y" -o "${startit}" = "Y" ]; then - ${link} start - else - echo -e -n "${WARNING}Not starting ${INFO}${link}" - echo -e "${WARNING}.${NORMAL}\n" - fi - else - ${link} start - fi - ;; - esac - error_value=${?} - - if [ "${error_value}" -gt "1" ]; then - print_error_msg - fi -done - -# Strip apply time to the logs, strip out any color codes and dump -# the log to /var/log/boot.log -if [ -f "${TEMPFS_MOUNT}/.bootlog" -a "${runlevel}" != "S" ]; then - # Remove any color codes from the temp log file - sed -i 's@\\033\[[0-9];[0-9][0-9]m@@g' "${TEMPFS_MOUNT}/.bootlog" - #Fix the time and hostname - BTIMESPEC=$(echo `date +"%b %d %T"` `hostname`) - sed -i "s@^bootlog:@${BTIMESPEC} bootlog:@" "${TEMPFS_MOUNT}/.bootlog" - # Don't try and write in 0 and 6, this is a 'boot' log - if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then - cat "${TEMPFS_MOUNT}/.bootlog" >> /var/log/boot.log - rm -f "${TEMPFS_MOUNT}/.bootlog" - fi -fi - -# End $RC_BASE/init.d/rc diff --git a/bootscripts/contrib/lsb-v3/init.d/reboot b/bootscripts/contrib/lsb-v3/init.d/reboot deleted file mode 100644 index 56e948a3f..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/reboot +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/reboot - -### 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_success_msg "Restarting system..." - reboot -d -f -i - ;; - - *) - echo "Usage: ${0} {stop}" - exit 1 - ;; - -esac - -# End /etc/init.d/reboot diff --git a/bootscripts/contrib/lsb-v3/init.d/sendsignals b/bootscripts/contrib/lsb-v3/init.d/sendsignals deleted file mode 100644 index 2cd9df84a..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/sendsignals +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/sendsignals - -### 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) - message="Sending all processes the TERM signal..." - killall5 -15 - error_value=${?} - # Account for successful return value of 2 - if [ ${error_value} -eq 2 ]; then - error_value=0 - fi - sleep 3 - - (exit ${error_value}) - evaluate_retval standard - - message="Sending all processes the KILL signal..." - killall5 -9 - error_value=${?} - # Account for successful return value of 2 - if [ ${error_value} -eq 2 ]; then - error_value=0 - fi - - sleep 3 - - (exit ${error_value}) - evaluate_retval standard - ;; - - *) - echo "Usage: ${0} {stop}" - exit 1 - ;; - -esac - -# End /etc/init.d/sendsignals diff --git a/bootscripts/contrib/lsb-v3/init.d/setclock b/bootscripts/contrib/lsb-v3/init.d/setclock deleted file mode 100644 index 5d47b8dc8..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/setclock +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/setclock - -### BEGIN INIT INFO -# Provides: hwclock -# Required-Start: -# Should-Start: modules -# Required-Stop: -# Should-Stop: $syslog -# Default-Start: -# 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 - -BIN_FILE="/sbin/hwclock" - -chk_stat - -case "${UTC}" in - yes|true|1) - CLOCKPARAMS="${CLOCKPARAMS} --utc" - ;; - - no|false|0) - CLOCKPARAMS="${CLOCKPARAMS} --localtime" - ;; - -esac - -case ${1} in - start) - message="Setting system clock..." - ${BIN_FILE} --hctosys ${CLOCKPARAMS} >/dev/null - evaluate_retval standard - ;; - - stop) - message="Setting hardware clock..." - ${BIN_FILE} --systohc ${CLOCKPARAMS} >/dev/null - evaluate_retval standard - ;; - - *) - echo "Usage: ${0} {start|stop}" - ;; - -esac - -# End /etc/init.d/setclock diff --git a/bootscripts/contrib/lsb-v3/init.d/swap b/bootscripts/contrib/lsb-v3/init.d/swap deleted file mode 100644 index 31e5591e5..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/swap +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/swap - -### 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) - message="Activating all swap files/partitions..." - swapon -a - evaluate_retval standard - ;; - - stop) - message="Deactivating all swap files/partitions..." - swapoff -a - evaluate_retval standard - ;; - - restart) - swapoff -a - error_level="${?}" - sleep 1 - swapon -a - error_level="$(( ${error_level} + ${?} ))" - (exit "${error_level}") - evaluate_retval restart - ;; - - status) - log_success_msg "Retrieving swap status..." - echo - swapon -s - ;; - - *) - echo "Usage: ${0} {start|stop|restart|status}" - exit 1 - ;; -esac - -# End /etc/init.d/swap diff --git a/bootscripts/contrib/lsb-v3/init.d/sysctl b/bootscripts/contrib/lsb-v3/init.d/sysctl deleted file mode 100644 index cccff126e..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/sysctl +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/sysctl - -### 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 - message="Setting kernel runtime parameters..." - sysctl -q -p - evaluate_retval standard - fi - ;; - - status) - sysctl -a - ;; - - *) - echo "Usage: ${0} {start|status}" - exit 1 - ;; -esac - -# End /etc/init.d/sysctl diff --git a/bootscripts/contrib/lsb-v3/init.d/sysklogd b/bootscripts/contrib/lsb-v3/init.d/sysklogd deleted file mode 100644 index dc8829f07..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/sysklogd +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/sysklogd - -### 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) - MESSAGE="system log daemon..." - start_daemon /sbin/syslogd -m 0 - evaluate_retval start - - MESSAGE="kernel log daemon..." - start_daemon /sbin/klogd - evaluate_retval start - ;; - - stop) - MESSAGE="kernel log daemon..." - killproc /sbin/klogd - evaluate_retval stop - - MESSAGE="system log daemon..." - killproc /sbin/syslogd - evaluate_retval stop - ;; - - force-reload) - MESSAGE="system log daemon config file..." - killproc -HUP `/sbin/syslogd` - evaluate_retval reload - ;; - - restart) - MESSAGE="system and kernel log deamons..." - failed=0 - killproc /sbin/klogd || failed=1 - killproc /sbin/syslogd || failed=1 - start_daemon /sbin/syslogd -m 0 || failed=1 - start_daemon /sbin/klogd || failed=1 - (exit ${failed}) - evaluate_retval restart - ;; - - status) - statusproc /sbin/syslogd - statusproc /sbin/klogd - ;; - - *) - echo "Usage: ${0} {start|stop|force-reload|restart|status}" - exit 1 - ;; -esac - -# End /etc/init.d/sysklogd diff --git a/bootscripts/contrib/lsb-v3/init.d/template b/bootscripts/contrib/lsb-v3/init.d/template deleted file mode 100644 index cb3222a35..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/template +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/sh -# Begin /etc/init.d/template - -### 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 - -# Source the LSB init-functions, ours are pulled in from there. -. /lib/lsb/init-functions - -# These are optional, but required for chk_stat. They will be used in -# the rest of the functions if defined, else you must provide a program -# name to control, and a message ('Starting Template Service...' -# or 'Stoping Template Service...') to evauate_retval. See the -# documentaion in the lfs-fucntions file for more information. -MESSAGE="Template Service" -BIN_FILE="/some/path/to/template" -CONFIGFILE="/etc/sysconfig/template.conf" - -# check that $BIN_FILE exists and is executable, and $CONFIGFILE exists. -chk_stat - -# LSB Defined functions require that at least $BIN_FILE be passed to them, -# where as lfs-functions will use the $BIN_FILE environment variable. -# loadproc() and endproc() are just wrappers that pass everything on to -# the LSB defined functions. - -case "${1}" in - start) - #start_daemon "${BIN_FILE}" -arg1 -arg2 #... or: - loadproc -arg1 -arg2 -arg3 #... - evaluate_retval start - ;; - - stop) - #killproc -TERM "${BIN_FILE}" or: - endproc - evaluate_retval stop - ;; - - force-reload) - reloadproc -force - evaluate_retval force-reload - ;; - - restart) - $0 stop - $0 start - ;; - - status) - statusproc - ;; - -# reload and try-restart are optional per LSB requirements - reload) - reloadproc - evaluate_retval reload - ;; - - try-restart) - # Since this is optional there is no lfs-function for this one... - # might be at a later time if used enough, but I doubt it usefullness. - pidofproc "${BIN_FILE}" > /dev/null - if [ "${?}" -ne "0" ]; then - MESSAGE="${MESSAGE}: Not Running" - else - $0 stop - $0 start - exit 0 - fi - evaluate_retval try-restart - ;; - - *) - echo "Usage: ${0} {start|stop|{force-}reload|{try-}restart|status}" - exit 1 - ;; -esac - -# End /etc/init.d/template diff --git a/bootscripts/contrib/lsb-v3/init.d/udev b/bootscripts/contrib/lsb-v3/init.d/udev deleted file mode 100644 index ac91fccf3..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/udev +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh -# Begin $rc_base/init.d/udev - -### BEGIN INIT INFO -# Provides: udev -# Required-Start: -# Should-Start: modules -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Populated /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 - -MESSAGE="Populating /dev with device nodes..." - -case "${1}" in - start) - if ! grep -q '[[:space:]]sysfs' /proc/mounts; then - echo_failure - boot_mesg -n "FAILURE:\n\nUnable to create" ${FAILURE} - boot_mesg -n " devices without a SysFS filesystem" - boot_mesg -n "\n\nAfter you press Enter, this system" - boot_mesg -n " will be halted and powered off." - boot_mesg -n "\n\nPress Enter to continue..." ${INFO} - boot_mesg "" ${NORMAL} - $FAILURE_ACTION - /etc/rc.d/init.d/halt stop - fi - - # Mount a temporary file system over /dev, so that any devices - # made or removed during this boot don't affect the next one. - # The reason we don't write to mtab is because we don't ever - # want /dev to be unavailable (such as by `umount -a'). - if ! mountpoint /dev > /dev/null; then - mount -n -t tmpfs tmpfs /dev -o mode=755 - fi - if [ ${?} -ne 0 ]; then - echo_failure - boot_mesg -n "FAILURE:\n\nCannot mount a tmpfs" ${FAILURE} - boot_mesg -n " onto /dev, this system will be halted." - boot_mesg -n "\n\nAfter you press Enter, this system" - boot_mesg -n " will be halted and powered off." - boot_mesg -n "\n\nPress Enter to continue..." ${INFO} - boot_mesg "" ${NORMAL} - $FAILURE_ACTION - /etc/rc.d/init.d/halt stop - fi - - # Create a symlink for POSIX shared memory - ln -s /run/shm /dev/shm - - # Udev handles uevents itself, so we don't need to have - # the kernel call out to any binary in response to them - echo > /proc/sys/kernel/hotplug - - # Copy the only static device node that Udev >= 155 doesn't - # handle to /dev - cp -a /lib/udev/devices/null /dev - - # 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 - - # Now wait for udevd to process the uevents we triggered - /sbin/udevadm settle - evaluate_retval standard - ;; - - *) - echo "Usage ${0} {start}" - exit 1 - ;; -esac - -# End $rc_base/init.d/udev diff --git a/bootscripts/contrib/lsb-v3/init.d/udev_retry b/bootscripts/contrib/lsb-v3/init.d/udev_retry deleted file mode 100644 index 24b956ae0..000000000 --- a/bootscripts/contrib/lsb-v3/init.d/udev_retry +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Begin $rc_base/init.d/udev_retry - -### BEGIN INIT INFO -# Provides: udev_retry -# Required-Start: udev -# Should-Start: $local_fs -# Required-Stop: -# Should-Stop: -# Default-Start: S -# Default-Stop: -# Short-Description: Replays failed uevents and creates additonal devices. -# Description: Replays any failed uevents that were skipped due to -# slow hardware initialization, and creates those needed -# device nodes -# X-LFS-Provided-By: LFS -### END INIT INFO - -. /lib/lsb/init-functions - -MESSAGE="Retrying failed uevents, if any..." - -case "${1}" in - start) - - # From Debian: "copy the rules generated before / was mounted - # read-write": - for file in /dev/.udev/tmp-rules--*; do - dest=${file##*tmp-rules--} - [ "$dest" = '*' ] && break - cat $file >> /etc/udev/rules.d/$dest - rm -f $file - done - - # Re-trigger the failed uevents in hope they will succeed now - /sbin/udevadm trigger --type=failed --action=add - - # Now wait for udevd to process the uevents we triggered - /sbin/udevadm settle - evaluate_retval standard - ;; - - *) - echo "Usage ${0} {start}" - exit 1 - ;; -esac - -# End $rc_base/init.d/udev_retry diff --git a/bootscripts/contrib/lsb-v3/lib/lsb/init-functions b/bootscripts/contrib/lsb-v3/lib/lsb/init-functions new file mode 100644 index 000000000..d422a5b82 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/lib/lsb/init-functions @@ -0,0 +1,577 @@ +# Begin /lib/lsb/init-funtions + +# Provides initialization funtions as defined by the Linux Standard Base +# specification, version 3.1.0 + +# Source rc configuration if not inherited from the environment +if [ "${RC_BASE}" = "" ]; then + . /etc/sysconfig/rc +fi + +# Source the distro functions file +if [ "${DISTRO_MINI}" != "" ]; then + . "${RC_BASE}/init.d/${DISTRO_MINI}-functions" +fi + +################################################################################ +# 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 + # succesful 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" ] # signal is used to terminate the program + then + # account for empty pidlist (pid file still exists and nosignal 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 + else + # just check one last time and if still alive, fail + sleep 1 + 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 it's job, and evaluate kills 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/[^/]*$//'` + progname=`echo "${program}" | sed "s@${prefix}@@"` + # 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="${pids}${pid} " + else + exitstatus="1" + fi + done + + if [ -z "${lpids}" -a ! -f "${pidfile}" ]; then + return 3 + else + echo "${lpids}" + return "${exitstatus}" + fi +} +################################################################################ +# log_success_msg() # +# Usage: log_success_msg [$MESSAGE | "message"] # +# # +# Purpose: Print a successful status message to the screen and optionally # +# a boot log file. # +# # +# Inputs: accepts one string value, either a quoted string or optionally # +# the value of $MESSAGE if set in the running environment. # +# # +# Return values: Not used # +################################################################################ +log_success_msg() +{ + echo -n -e "${PREFIX_SUCCESS}${@}" + echo -e "${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]${NORMAL}" + if [ "${BOOTLOG_ENAB}" = "yes" ]; then + if [ $( hostname ) = "(none)" ]; then + BTTIMESPEC="" + else + BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " + fi + echo "${BTTIMESPEC}bootlog: ${@} Successful" >> "${TEMPFS_MOUNT}/.bootlog" + fi + return 0 +} + +################################################################################ +# log_failure_msg() # +# Usage: log_failure_msg [$MESSAGE | "message"] # +# # +# Purpose: Print a failure status message to the screen and optionally # +# a boot log file. # +# # +# Inputs: accepts one string value, either a quoted string or optionally # +# the value of $MESSAGE if set in the running environment. # +# # +# Return values: Not used # +################################################################################ +log_failure_msg() +{ + echo -n -e "${PREFIX_FAILURE}${@}" + echo -e "${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}" + if [ "${BOOTLOG_ENAB}" = "yes" ]; then + if [ $( hostname ) = "(none)" ]; then + BTTIMESPEC="" + else + BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " + fi + echo "${BTTIMESPEC}bootlog: ${@} Failed!" >> "${TEMPFS_MOUNT}/.bootlog" + fi + return 0 +} + +################################################################################ +# log_warning_msg() # +# Usage: log_warning_msg [$MESSAGE | "message"] # +# # +# Purpose: Print a warning status message to the screen and optionally # +# a boot log file. # +# # +# Inputs: accepts one string value, either a quoted string or optionally # +# the value of $MESSAGE if set in the running environment. # +# # +# Return values: Not used # +################################################################################ +log_warning_msg() +{ + echo -n -e "${PREFIX_WARNING}${@}" + echo -e "${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}" + if [ "${BOOTLOG_ENAB}" = "yes" ]; then + if [ $( hostname ) = "(none)" ]; then + BTTIMESPEC="" + else + BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " + fi + echo "${BTTIMESPEC}bootlog: ${@} Warning" >> "${TEMPFS_MOUNT}/.bootlog" + fi + return 0 +} + +################################################################################ +# 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 +} + +# End /lib/lsb/init-functions diff --git a/bootscripts/contrib/lsb-v3/lib/lsb/manage-functions b/bootscripts/contrib/lsb-v3/lib/lsb/manage-functions new file mode 100644 index 000000000..7c7a8f495 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/lib/lsb/manage-functions @@ -0,0 +1,306 @@ +#!/bin/bash +# Begin /lib/lsb/manage-functions + +# /lib/lsb/manage-functions contains the functions used by +# /lib/lsb/install_initd and /lib/lsb/remove_initd as well as additional helper +# functions for use in programs that would provide functionality similar to +# the RedHat chkconfig utility, for instance. + +# source the confif file +. /etc/lsb/lsb-config + +# Define all arrays at script start to avoid scope issues +# scriptlist is a list of valid scripts used as an index +declare -a scriptlist +# fullheaders is a complete set of valid LSB headers, stored in memory for +# each indexed script, to avoid multiple disk reads +declare -a fullheaders + +############################################################################### +# get_headers() - Obtains a valid list of scripts contained in ${rcbase} and # +# inserts the name of the script into the scriptlist[] array # +# for use by all other functions. Additionally, it inserts # +# the entire LSB header information from each script into a # +# second array, fullheaders[], so that diskreads need only be # +# done once # +# Returns no value, but populates the variable ${scriptcount} # +# and the arrays ${scriptlist} and ${fullheaders} for use # +# with other functions in this script. This function is # +# called unconditionally at the end of this scrip and is # +# provided as a function only for the case that it needs to # +# be called again after other operations. # +############################################################################### +get_headers() +{ + echo -n "Retrieving script information from disk..." + count=1 + for file in $(find -P /etc/init.d -xdev -perm -u=x | sed -n 2~1p \ + | sed "s@/etc/init.d/rc@@") + do + # determine if script is an LSB compliant script + grep "### BEGIN INIT INFO" $file > /dev/null + if test $? -gt "0" + then + # this is not a valid script and is ignored + # skip the rest of the loop + continue + fi + # determine basename using only bash (is basename a builtin?) + filename=$(echo "${file}" | sed "s@${rcbase}/@@") + # assign it to an array possition + scriptlist["${count}"]="${filename}" + # find the begining of the init info for the script + begin=$(grep -n "### BEGIN INIT INFO" "${file}" | cut -d: -f1) + # find the end of the init info for the script + end=$(grep -n "### END INIT INFO" "${file}" | cut -d: -f1) + # we'll use the difference between the values in the tail command + diff=$(( ${end} - ${begin} )) + # assign the entire LSB header information as a single string to the + # fullheaders[] array + fullheaders["${count}"]=$(head -n "${end}" "${file}" \ + | tail -n "${diff}") + count=$(( ${count} + 1 )) + unset begin + unset end + unset diff + unset filename + done + # a number or array elements would be a nice regular variable assignment + scriptcount="${#scriptlist[@]}" + unset count + echo -e "Completed!" +} + +############################################################################### +# print_headers() - Presents a formatted list of all LSB compliant script # +# headers to stdout preceeded by script name for use in # +# other scripts # +############################################################################### +print_headers() +{ + get_headers + count=1 + while test "${count}" -lt "${scriptcount}" + do + echo "${scriptlist[$count]}" + echo "=============================================================" + echo "${fullheaders[$count]}" + echo "" + echo "" + count="$(( ${count} + 1 ))" + done +} + +############################################################################### +# get_index() - Determines the array index of the specified script # +############################################################################### + +get_index() +{ + filename=$(echo "${1}" | sed "s@${rcbase}/@@") + count=1 + while test "${count}" -lt "${scriptcount}" + do + echo "${scriptlist[${count}]}" | grep "${filename}" > /dev/null + if test "${?}" -ne "0" + then + count=$(( ${count} + 1 )) + continue + else + break + fi + done + if test "${filename}" == "${scriptlist[${count}]}" + then + echo "${count}" + else + echo "${1} is not a valid LSB init script." + exit 1 + fi + unset filename + unset count +} + +############################################################################### +# get_lsb_value() - Obtains the LSB Value of $1 for index of script ($2). # +############################################################################### +get_lsb_value() +{ + # Probably need some error checking in here + echo "${fullheaders[${2}]}" | \ + grep "^# ${1}" | \ + sed -e "s@# ${1}:@@" \ + -e "s/^[ \t]*//" +} + +############################################################################### +# convert_lsb_required() - Converts LSB defined facilities (facility names # +# begining with a '$' character) into script names # +# for required start/stop # +############################################################################### +convert_lsb_required() +{ + local count=0 + local provides="" + local reqfacility="" + local reqprovideslist="" + + for reqfacility in $@ + do + # find the requires and it's index and then find the script name + # from the index. Since this is required, exit if it is not found + ## If reqfacility is already in script name format, nothing needs to + ## be done, just echo it back out. I can't think of an easy way to + ## do this right now, the scriptname will be the same as the provides + ## anyway, so just let it fly for now...it'll be correct, it just + ## takes an extra couple of commands to get the same result. + ## Besides, this will do some extra sanity checking in case somebody + ## writes a script that isn't named the same as provides, though this + ## isn't LSB compliant. Additionally, these same comments apply to + ## the convert_lsb_should() fucntion below. + count=0 + while test ${count} -lt ${scriptcount} + do + count=$(( $count + 1 )) + provides="$( get_lsb_value Provides ${count} )" + if test "${provides}" = "${reqfacility}" + then + reqprovideslist="${reqprovideslist} ${scriptlist[$count]}" + break + fi + if test ${count} -eq ${scriptcount}; then + # If we've never broken out of the while loop, then this is an + # unrecoverable error since it is a required item. Exit now! + echo "Error: unable to locate required facility ${reqfacility}!" + exit 5 + fi + done + done + echo "${reqprovideslist}" | sed -e "s/^[ \t]*//" -e "s/^[ \t]*//" +} + +############################################################################### +# convert_lsb_should() - Converts LSB defined facilities (facility names # +# begining with a '$' character) into script names for # +# should start/stop # +############################################################################### + +convert_lsb_should() +{ + local count=0 + local provides="" + local optfacility="" + local optprovideslist="" + + for optfacility in $@ + do + # find the should and it's index and then find the script name + # from the index. Since this is not an error, simply warn if it + # is not found. + count=0 + while test ${count} -lt ${scriptcount} + do + count=$(( $count + 1 )) + provides="$( get_lsb_value Provides ${count} )" + if test "${provides}" = "${optfacility}" + then + optprovideslist="${optprovideslist} ${scriptlist[$count]}" + break + fi + # No need to error or warn on should items, and it's messy if so! + done + done + echo "${optprovideslist}" | sed -e "s/^[ \t]*//" -e "s/[ \t]*$//" +} + +get_headers + +############################################################################### +# get_lsb_required_value() - Additional function to simplify repetitive tasks # +# Obtains the LSB Value of $1 for index of script # +# ($2) and immediately converts LSB defined # +# facilities (beginning with a '$' character) to a # +# script name. If the script is not found, then # +# the function exits with an error as per # +# convert_lsb_required. # +############################################################################### +get_lsb_required_value() +{ + local reqval + # Probably need some error checking in here + reqval=`echo "${fullheaders[${2}]}" | \ + grep "^# ${1}" | \ + sed -e "s@# ${1}:@@" \ + -e "s/^[ \t]*//"` + + # If $reqval contains a '$' charcter, then convert it to a script name + echo "${reqval}" | grep "\\$" 2>&1 > /dev/null + if test "${?}" -eq "0" + then + reqval=`convert_lsb_required "${reqval}"` + fi + echo "${reqval}" +} + +############################################################################### +# get_lsb_should_value() - Additional function to simplify repetitive tasks # +# Obtains the LSB Value of $1 for index of script # +# ($2) and immediately converts LSB defined # +# facilities (beginning with a '$' character) to a # +# script name. If the script is not found, the # +# value is removed from the list as it is optional. # +############################################################################### +get_lsb_should_value() +{ + local optval + local listitem + local optitem + # Probably need some error checking in here + optval=`echo "${fullheaders[${2}]}" | \ + grep "^# ${1}" | \ + sed -e "s@# ${1}:@@" \ + -e "s/^[ \t]*//"` + + # If $optval contains a '$' charcter, then convert it to a script name + echo "${optval}" | grep "\\$" 2>&1 > /dev/null + if test "${?}" -eq "0" + then + optval=`convert_lsb_should "${optval}"` + # if we still have a "$" character, then it's not found and it should + # be removed from the list (and it's trailing space if one exists) + # since it is optional + echo "${optval}" | grep "\\$" 2>&1 > /dev/null + if test "${?}" -eq "0" + then + # Remove the value + for listitem in ${optval} + do + echo "${listitem}" | grep "\\$" + if test "${?}" -eq "0" + then + optval=`echo "${optval}" | sed -e 's@${listitem} @@' \ + -e 's@${listitem}@@' | \ + sed -e "s@# ${1}:@@" \ + -e "s/^[ \t]*//"` + fi + done + fi + fi + # If a should start value does not have a script associted with it, then + # remove it (or it and trailing space) from the list + for optitem in ${otpval} + do + grep "${optitem}" "${statedir}/enabled-scripts" 2>&1 > /dev/null + if test "${?}" -ne "0" + then + optval=`echo "${optval}" | sed -e 's@${otpitem} @@' \ + -e 's@${optitem}@@' | \ + sed -e "s@# ${1}:@@" \ + -e "s/^[ \t]*//"` + fi + done + + echo "${optval}" +} + +# End /lib/lsb/manage-functions diff --git a/bootscripts/contrib/lsb-v3/lib/network-services/ipv4-static b/bootscripts/contrib/lsb-v3/lib/network-services/ipv4-static new file mode 100644 index 000000000..417d22de6 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/lib/network-services/ipv4-static @@ -0,0 +1,80 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/services/ipv4-static +# +# Description : IPV4 Static Boot Script +# +# Authors : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.00 +# +# Notes : +# +######################################################################## + +. /lib/lsb/init-functions +. ${IFCONFIG} + +if [ -z "${IP}" ]; then + log_failure_msg "IP variable missing from ${IFCONFIG}, cannot continue." + exit 1 +fi + +if [ -z "${PREFIX}" -a -z "${PEER}" ]; then + log_warning_msg "PREFIX variable missing from ${IFCONFIG}, assuming 24." + PREFIX=24 + args="${args} ${IP}/${PREFIX}" +elif [ -n "${PREFIX}" -a -n "${PEER}" ]; then + log_failure_msg "PREFIX and PEER both specified in ${IFCONFIG}, cannot continue." + exit 1 +elif [ -n "${PREFIX}" ]; then + args="${args} ${IP}/${PREFIX}" +elif [ -n "${PEER}" ]; then + args="${args} ${IP} peer ${PEER}" +fi + +if [ -n "${BROADCAST}" ]; then + args="${args} broadcast ${BROADCAST}" +fi + +if [ -n "${SOURCE}" ]; then + args="${args} src ${SOURCE}" +fi + +case "${2}" in + up) + MESSAGE="Adding IPv4 address ${IP} to the ${1} interface..." + ip addr add ${args} dev ${1} + evaluate_retval + + if [ -n "${GATEWAY}" ]; then + if ip route | grep -q default; then + log_warning_msg "Gateway already setup; skipping." ${WARNING} + else + MESSAGE="Setting up default gateway..." + ip route add default via ${GATEWAY} dev ${1} + evaluate_retval + fi + fi + ;; + + down) + if [ -n "${GATEWAY}" ]; then + MESSAGE="Removing default gateway..." + ip route del default + evaluate_retval + fi + + MESSAGE="Removing IPv4 address ${IP} from the ${1} interface..." + ip addr del ${args} dev ${1} + evaluate_retval + ;; + + *) + echo "Usage: ${0} [interface] {up|down}" + exit 1 + ;; +esac + +# End $NETWORK_DEVICES/services/ipv4-static diff --git a/bootscripts/contrib/lsb-v3/lib/network-services/ipv4-static-route b/bootscripts/contrib/lsb-v3/lib/network-services/ipv4-static-route new file mode 100644 index 000000000..4205a022d --- /dev/null +++ b/bootscripts/contrib/lsb-v3/lib/network-services/ipv4-static-route @@ -0,0 +1,92 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/services/ipv4-static-route +# +# Description : IPV4 Static Route Script +# +# Authors : Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.00 +# +# Notes : +# +######################################################################## + +. /lib/lsb/init-functions +. ${IFCONFIG} + +case "${TYPE}" in + ("" | "network") + need_ip=1 + need_gateway=1 + ;; + + ("default") + need_gateway=1 + args="${args} default" + desc="default" + ;; + + ("host") + need_ip=1 + ;; + + ("unreachable") + need_ip=1 + args="${args} unreachable" + desc="unreachable " + ;; + + (*) + boot_mesg "Unknown route type (${TYPE}) in ${IFCONFIG}, cannot continue." ${FAILURE} + echo_failure + exit 1 + ;; +esac + +if [ -n "${need_ip}" ]; then + if [ -z "${IP}" ]; then + boot_mesg "IP variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} + echo_failure + exit 1 + fi + + if [ -z "${PREFIX}" ]; then + boot_mesg "PREFIX variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} + echo_failure + exit 1 + fi + + args="${args} ${IP}/${PREFIX}" + desc="${desc}${IP}/${PREFIX}" +fi + +if [ -n "${need_gateway}" ]; then + if [ -z "${GATEWAY}" ]; then + boot_mesg "GATEWAY variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} + echo_failure + exit 1 + fi + args="${args} via ${GATEWAY}" +fi + +case "${2}" in + up) + boot_mesg "Adding '${desc}' route to the ${1} interface..." + ip route add ${args} dev ${1} + evaluate_retval + ;; + + down) + boot_mesg "Removing '${desc}' route from the ${1} interface..." + ip route del ${args} dev ${1} + evaluate_retval + ;; + + *) + echo "Usage: ${0} [interface] {up|down}" + exit 1 + ;; +esac + +# End $NETWORK_DEVICES/services/ipv4-static-route diff --git a/bootscripts/contrib/lsb-v3/lsb/init-functions b/bootscripts/contrib/lsb-v3/lsb/init-functions deleted file mode 100644 index d422a5b82..000000000 --- a/bootscripts/contrib/lsb-v3/lsb/init-functions +++ /dev/null @@ -1,577 +0,0 @@ -# Begin /lib/lsb/init-funtions - -# Provides initialization funtions as defined by the Linux Standard Base -# specification, version 3.1.0 - -# Source rc configuration if not inherited from the environment -if [ "${RC_BASE}" = "" ]; then - . /etc/sysconfig/rc -fi - -# Source the distro functions file -if [ "${DISTRO_MINI}" != "" ]; then - . "${RC_BASE}/init.d/${DISTRO_MINI}-functions" -fi - -################################################################################ -# 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 - # succesful 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" ] # signal is used to terminate the program - then - # account for empty pidlist (pid file still exists and nosignal 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 - else - # just check one last time and if still alive, fail - sleep 1 - 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 it's job, and evaluate kills 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/[^/]*$//'` - progname=`echo "${program}" | sed "s@${prefix}@@"` - # 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="${pids}${pid} " - else - exitstatus="1" - fi - done - - if [ -z "${lpids}" -a ! -f "${pidfile}" ]; then - return 3 - else - echo "${lpids}" - return "${exitstatus}" - fi -} -################################################################################ -# log_success_msg() # -# Usage: log_success_msg [$MESSAGE | "message"] # -# # -# Purpose: Print a successful status message to the screen and optionally # -# a boot log file. # -# # -# Inputs: accepts one string value, either a quoted string or optionally # -# the value of $MESSAGE if set in the running environment. # -# # -# Return values: Not used # -################################################################################ -log_success_msg() -{ - echo -n -e "${PREFIX_SUCCESS}${@}" - echo -e "${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]${NORMAL}" - if [ "${BOOTLOG_ENAB}" = "yes" ]; then - if [ $( hostname ) = "(none)" ]; then - BTTIMESPEC="" - else - BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " - fi - echo "${BTTIMESPEC}bootlog: ${@} Successful" >> "${TEMPFS_MOUNT}/.bootlog" - fi - return 0 -} - -################################################################################ -# log_failure_msg() # -# Usage: log_failure_msg [$MESSAGE | "message"] # -# # -# Purpose: Print a failure status message to the screen and optionally # -# a boot log file. # -# # -# Inputs: accepts one string value, either a quoted string or optionally # -# the value of $MESSAGE if set in the running environment. # -# # -# Return values: Not used # -################################################################################ -log_failure_msg() -{ - echo -n -e "${PREFIX_FAILURE}${@}" - echo -e "${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}" - if [ "${BOOTLOG_ENAB}" = "yes" ]; then - if [ $( hostname ) = "(none)" ]; then - BTTIMESPEC="" - else - BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " - fi - echo "${BTTIMESPEC}bootlog: ${@} Failed!" >> "${TEMPFS_MOUNT}/.bootlog" - fi - return 0 -} - -################################################################################ -# log_warning_msg() # -# Usage: log_warning_msg [$MESSAGE | "message"] # -# # -# Purpose: Print a warning status message to the screen and optionally # -# a boot log file. # -# # -# Inputs: accepts one string value, either a quoted string or optionally # -# the value of $MESSAGE if set in the running environment. # -# # -# Return values: Not used # -################################################################################ -log_warning_msg() -{ - echo -n -e "${PREFIX_WARNING}${@}" - echo -e "${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}" - if [ "${BOOTLOG_ENAB}" = "yes" ]; then - if [ $( hostname ) = "(none)" ]; then - BTTIMESPEC="" - else - BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " - fi - echo "${BTTIMESPEC}bootlog: ${@} Warning" >> "${TEMPFS_MOUNT}/.bootlog" - fi - return 0 -} - -################################################################################ -# 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 -} - -# End /lib/lsb/init-functions diff --git a/bootscripts/contrib/lsb-v3/lsb/manage-functions b/bootscripts/contrib/lsb-v3/lsb/manage-functions deleted file mode 100644 index 7c7a8f495..000000000 --- a/bootscripts/contrib/lsb-v3/lsb/manage-functions +++ /dev/null @@ -1,306 +0,0 @@ -#!/bin/bash -# Begin /lib/lsb/manage-functions - -# /lib/lsb/manage-functions contains the functions used by -# /lib/lsb/install_initd and /lib/lsb/remove_initd as well as additional helper -# functions for use in programs that would provide functionality similar to -# the RedHat chkconfig utility, for instance. - -# source the confif file -. /etc/lsb/lsb-config - -# Define all arrays at script start to avoid scope issues -# scriptlist is a list of valid scripts used as an index -declare -a scriptlist -# fullheaders is a complete set of valid LSB headers, stored in memory for -# each indexed script, to avoid multiple disk reads -declare -a fullheaders - -############################################################################### -# get_headers() - Obtains a valid list of scripts contained in ${rcbase} and # -# inserts the name of the script into the scriptlist[] array # -# for use by all other functions. Additionally, it inserts # -# the entire LSB header information from each script into a # -# second array, fullheaders[], so that diskreads need only be # -# done once # -# Returns no value, but populates the variable ${scriptcount} # -# and the arrays ${scriptlist} and ${fullheaders} for use # -# with other functions in this script. This function is # -# called unconditionally at the end of this scrip and is # -# provided as a function only for the case that it needs to # -# be called again after other operations. # -############################################################################### -get_headers() -{ - echo -n "Retrieving script information from disk..." - count=1 - for file in $(find -P /etc/init.d -xdev -perm -u=x | sed -n 2~1p \ - | sed "s@/etc/init.d/rc@@") - do - # determine if script is an LSB compliant script - grep "### BEGIN INIT INFO" $file > /dev/null - if test $? -gt "0" - then - # this is not a valid script and is ignored - # skip the rest of the loop - continue - fi - # determine basename using only bash (is basename a builtin?) - filename=$(echo "${file}" | sed "s@${rcbase}/@@") - # assign it to an array possition - scriptlist["${count}"]="${filename}" - # find the begining of the init info for the script - begin=$(grep -n "### BEGIN INIT INFO" "${file}" | cut -d: -f1) - # find the end of the init info for the script - end=$(grep -n "### END INIT INFO" "${file}" | cut -d: -f1) - # we'll use the difference between the values in the tail command - diff=$(( ${end} - ${begin} )) - # assign the entire LSB header information as a single string to the - # fullheaders[] array - fullheaders["${count}"]=$(head -n "${end}" "${file}" \ - | tail -n "${diff}") - count=$(( ${count} + 1 )) - unset begin - unset end - unset diff - unset filename - done - # a number or array elements would be a nice regular variable assignment - scriptcount="${#scriptlist[@]}" - unset count - echo -e "Completed!" -} - -############################################################################### -# print_headers() - Presents a formatted list of all LSB compliant script # -# headers to stdout preceeded by script name for use in # -# other scripts # -############################################################################### -print_headers() -{ - get_headers - count=1 - while test "${count}" -lt "${scriptcount}" - do - echo "${scriptlist[$count]}" - echo "=============================================================" - echo "${fullheaders[$count]}" - echo "" - echo "" - count="$(( ${count} + 1 ))" - done -} - -############################################################################### -# get_index() - Determines the array index of the specified script # -############################################################################### - -get_index() -{ - filename=$(echo "${1}" | sed "s@${rcbase}/@@") - count=1 - while test "${count}" -lt "${scriptcount}" - do - echo "${scriptlist[${count}]}" | grep "${filename}" > /dev/null - if test "${?}" -ne "0" - then - count=$(( ${count} + 1 )) - continue - else - break - fi - done - if test "${filename}" == "${scriptlist[${count}]}" - then - echo "${count}" - else - echo "${1} is not a valid LSB init script." - exit 1 - fi - unset filename - unset count -} - -############################################################################### -# get_lsb_value() - Obtains the LSB Value of $1 for index of script ($2). # -############################################################################### -get_lsb_value() -{ - # Probably need some error checking in here - echo "${fullheaders[${2}]}" | \ - grep "^# ${1}" | \ - sed -e "s@# ${1}:@@" \ - -e "s/^[ \t]*//" -} - -############################################################################### -# convert_lsb_required() - Converts LSB defined facilities (facility names # -# begining with a '$' character) into script names # -# for required start/stop # -############################################################################### -convert_lsb_required() -{ - local count=0 - local provides="" - local reqfacility="" - local reqprovideslist="" - - for reqfacility in $@ - do - # find the requires and it's index and then find the script name - # from the index. Since this is required, exit if it is not found - ## If reqfacility is already in script name format, nothing needs to - ## be done, just echo it back out. I can't think of an easy way to - ## do this right now, the scriptname will be the same as the provides - ## anyway, so just let it fly for now...it'll be correct, it just - ## takes an extra couple of commands to get the same result. - ## Besides, this will do some extra sanity checking in case somebody - ## writes a script that isn't named the same as provides, though this - ## isn't LSB compliant. Additionally, these same comments apply to - ## the convert_lsb_should() fucntion below. - count=0 - while test ${count} -lt ${scriptcount} - do - count=$(( $count + 1 )) - provides="$( get_lsb_value Provides ${count} )" - if test "${provides}" = "${reqfacility}" - then - reqprovideslist="${reqprovideslist} ${scriptlist[$count]}" - break - fi - if test ${count} -eq ${scriptcount}; then - # If we've never broken out of the while loop, then this is an - # unrecoverable error since it is a required item. Exit now! - echo "Error: unable to locate required facility ${reqfacility}!" - exit 5 - fi - done - done - echo "${reqprovideslist}" | sed -e "s/^[ \t]*//" -e "s/^[ \t]*//" -} - -############################################################################### -# convert_lsb_should() - Converts LSB defined facilities (facility names # -# begining with a '$' character) into script names for # -# should start/stop # -############################################################################### - -convert_lsb_should() -{ - local count=0 - local provides="" - local optfacility="" - local optprovideslist="" - - for optfacility in $@ - do - # find the should and it's index and then find the script name - # from the index. Since this is not an error, simply warn if it - # is not found. - count=0 - while test ${count} -lt ${scriptcount} - do - count=$(( $count + 1 )) - provides="$( get_lsb_value Provides ${count} )" - if test "${provides}" = "${optfacility}" - then - optprovideslist="${optprovideslist} ${scriptlist[$count]}" - break - fi - # No need to error or warn on should items, and it's messy if so! - done - done - echo "${optprovideslist}" | sed -e "s/^[ \t]*//" -e "s/[ \t]*$//" -} - -get_headers - -############################################################################### -# get_lsb_required_value() - Additional function to simplify repetitive tasks # -# Obtains the LSB Value of $1 for index of script # -# ($2) and immediately converts LSB defined # -# facilities (beginning with a '$' character) to a # -# script name. If the script is not found, then # -# the function exits with an error as per # -# convert_lsb_required. # -############################################################################### -get_lsb_required_value() -{ - local reqval - # Probably need some error checking in here - reqval=`echo "${fullheaders[${2}]}" | \ - grep "^# ${1}" | \ - sed -e "s@# ${1}:@@" \ - -e "s/^[ \t]*//"` - - # If $reqval contains a '$' charcter, then convert it to a script name - echo "${reqval}" | grep "\\$" 2>&1 > /dev/null - if test "${?}" -eq "0" - then - reqval=`convert_lsb_required "${reqval}"` - fi - echo "${reqval}" -} - -############################################################################### -# get_lsb_should_value() - Additional function to simplify repetitive tasks # -# Obtains the LSB Value of $1 for index of script # -# ($2) and immediately converts LSB defined # -# facilities (beginning with a '$' character) to a # -# script name. If the script is not found, the # -# value is removed from the list as it is optional. # -############################################################################### -get_lsb_should_value() -{ - local optval - local listitem - local optitem - # Probably need some error checking in here - optval=`echo "${fullheaders[${2}]}" | \ - grep "^# ${1}" | \ - sed -e "s@# ${1}:@@" \ - -e "s/^[ \t]*//"` - - # If $optval contains a '$' charcter, then convert it to a script name - echo "${optval}" | grep "\\$" 2>&1 > /dev/null - if test "${?}" -eq "0" - then - optval=`convert_lsb_should "${optval}"` - # if we still have a "$" character, then it's not found and it should - # be removed from the list (and it's trailing space if one exists) - # since it is optional - echo "${optval}" | grep "\\$" 2>&1 > /dev/null - if test "${?}" -eq "0" - then - # Remove the value - for listitem in ${optval} - do - echo "${listitem}" | grep "\\$" - if test "${?}" -eq "0" - then - optval=`echo "${optval}" | sed -e 's@${listitem} @@' \ - -e 's@${listitem}@@' | \ - sed -e "s@# ${1}:@@" \ - -e "s/^[ \t]*//"` - fi - done - fi - fi - # If a should start value does not have a script associted with it, then - # remove it (or it and trailing space) from the list - for optitem in ${otpval} - do - grep "${optitem}" "${statedir}/enabled-scripts" 2>&1 > /dev/null - if test "${?}" -ne "0" - then - optval=`echo "${optval}" | sed -e 's@${otpitem} @@' \ - -e 's@${optitem}@@' | \ - sed -e "s@# ${1}:@@" \ - -e "s/^[ \t]*//"` - fi - done - - echo "${optval}" -} - -# End /lib/lsb/manage-functions diff --git a/bootscripts/contrib/lsb-v3/sbin/ifdown b/bootscripts/contrib/lsb-v3/sbin/ifdown new file mode 100644 index 000000000..28d1f1813 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sbin/ifdown @@ -0,0 +1,93 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/ifdown +# +# Description : Interface Down +# +# Authors : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.01 +# +# Notes : the IFCONFIG variable is passed to the scripts found +# in the services directory, to indicate what file the +# service should source to get environmental variables. +# +######################################################################## + +. /lib/lsb/init-functions + +# Collect a list of configuration files for our interface +if [ -n "${2}" ]; then + for file in ${@#$1}; do # All parameters except $1 + FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}" + done +elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then + FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*` +else + FILES="${NETWORK_DEVICES}/ifconfig.${1}" +fi + +# Reverse the order configuration files are processed in +for file in ${FILES}; do + FILES2="${file} ${FILES2}" +done +FILES=${FILES2} + +# Process each configuration file +for file in ${FILES}; do + # skip backup files + if [ "${file}" != "${file%""~""}" ]; then + continue + fi + + if [ ! -f "${file}" ]; then + message="${file} is not a network configuration file or directory." + log_warning_msg + fi + ( + . ${file} + + # Will not process this service if started by boot, and ONBOOT + # is not set to yes + if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then + continue + fi + + # Will not process this service if started by hotplug, and + # ONHOTPLUG is not set to yes + if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" ]; then + continue + fi + + # This will run the service script, if SERVICE is set + if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then + if ip link show ${1} > /dev/null 2>&1 + then + IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} down + else + message="Interface ${1} doesn't exist." + log_warning_msg + fi + else + echo -e "${FAILURE}Unable to process ${file}. Either" + echo -e "${FAILURE}the SERVICE variable was not set," + echo -e "${FAILURE}or the specified service cannot be executed." + message="" + log_failure_msg + fi + ) +done + +if [ -z "${2}" ]; then + link_status=`ip link show $1` + if [ -n "${link_status}" ]; then + if echo "${link_status}" | grep -q UP; then + message="Bringing down the ${1} interface..." + ip link set ${1} down + evaluate_retval standard + fi + fi +fi + +# End $NETWORK_DEVICES/ifdown diff --git a/bootscripts/contrib/lsb-v3/sbin/ifup b/bootscripts/contrib/lsb-v3/sbin/ifup new file mode 100644 index 000000000..50e173ca6 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sbin/ifup @@ -0,0 +1,87 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/ifup +# +# Description : Interface Up +# +# Authors : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.00 +# +# Notes : the IFCONFIG variable is passed to the scripts found +# in the services directory, to indicate what file the +# service should source to get environmental variables. +# +######################################################################## + +. /lib/lsb/init-functions + +# Collect a list of configuration files for our interface +if [ -n "${2}" ]; then + for file in ${@#$1} # All parameters except $1 + do + FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}" + done +elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then + FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*` +else + FILES="${NETWORK_DEVICES}/ifconfig.${1}" +fi + +message="Bringing up the ${1} interface..." + +# Process each configruation file +for file in ${FILES}; do + # skip backup files + if [ "${file}" != "${file%""~""}" ]; then + continue + fi + + if [ ! -f "${file}" ]; then + log_warning_msg + message="${file} is not a network configuration file or directory." + log_warning_msg + fi + + ( + . ${file} + + # Will not process this service if started by boot, and ONBOOT + # is not set to yes + if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then + continue + fi + # Will not process this service if started by hotplug, and + # ONHOTPLUG is not set to yes + if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" -a "${HOSTNAME}" != "(none)" ]; then + continue + fi + + if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then + if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then + if ip link show ${1} > /dev/null 2>&1; then + link_status=`ip link show ${1}` + if [ -n "${link_status}" ]; then + if ! echo "${link_status}" | grep -q UP; then + ip link set ${1} up + evaluate_retval standard + fi + fi + else + message="${message}Interface ${1} doesn't exist." + log_warning_msg + fi + fi + IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} up + else + echo -e "${FAILURE}Unable to process ${file}. Either" + echo -e "${FAILURE}the SERVICE variable was not set," + echo -e "${FAILURE}or the specified service cannot be executed." + message="" + log_failure_msg + fi + ) +done + +# End $NETWORK_DEVICES/ifup diff --git a/bootscripts/contrib/lsb-v3/sysconfig/createfiles b/bootscripts/contrib/lsb-v3/sysconfig/createfiles deleted file mode 100644 index 8d1f89dc6..000000000 --- a/bootscripts/contrib/lsb-v3/sysconfig/createfiles +++ /dev/null @@ -1,28 +0,0 @@ -######################################################################## -# Begin /etc/sysconfig/createfiles -# -# Description : Createfiles script config file -# -# Authors : -# -# Version : 00.00 -# -# Notes : The syntax of this file is as follows: -# if type is equal to "file" or "dir" -# -# if type is equal to "dev" -# -# -# is the name of the file which is to be created -# is either file, dir, or dev. -# file creates a new file -# dir creates a new directory -# dev creates a new device -# is either block, char or pipe -# block creates a block device -# char creates a character deivce -# pipe creates a pipe, this will ignore the and fields -# and are the major and minor numbers used for the device. -######################################################################## - -# End /etc/sysconfig/createfiles diff --git a/bootscripts/contrib/lsb-v3/sysconfig/modules b/bootscripts/contrib/lsb-v3/sysconfig/modules deleted file mode 100644 index 1c8493d45..000000000 --- a/bootscripts/contrib/lsb-v3/sysconfig/modules +++ /dev/null @@ -1,18 +0,0 @@ -######################################################################## -# Begin /etc/sysconfig/modules -# -# Description : Module auto-loading configuration -# -# Authors : -# -# Version : 00.00 -# -# Notes : The syntax of this file is as follows: -# [ ...] -# -# Each module should be on it's own line, and any options that you want -# passed to the module should follow it. The line deliminator is either -# a space or a tab. -######################################################################## - -# End /etc/sysconfig/modules diff --git a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifdown b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifdown deleted file mode 100644 index 28d1f1813..000000000 --- a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifdown +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $NETWORK_DEVICES/ifdown -# -# Description : Interface Down -# -# Authors : Nathan Coulson - nathan@linuxfromscratch.org -# Kevin P. Fleming - kpfleming@linuxfromscratch.org -# -# Version : 00.01 -# -# Notes : the IFCONFIG variable is passed to the scripts found -# in the services directory, to indicate what file the -# service should source to get environmental variables. -# -######################################################################## - -. /lib/lsb/init-functions - -# Collect a list of configuration files for our interface -if [ -n "${2}" ]; then - for file in ${@#$1}; do # All parameters except $1 - FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}" - done -elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then - FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*` -else - FILES="${NETWORK_DEVICES}/ifconfig.${1}" -fi - -# Reverse the order configuration files are processed in -for file in ${FILES}; do - FILES2="${file} ${FILES2}" -done -FILES=${FILES2} - -# Process each configuration file -for file in ${FILES}; do - # skip backup files - if [ "${file}" != "${file%""~""}" ]; then - continue - fi - - if [ ! -f "${file}" ]; then - message="${file} is not a network configuration file or directory." - log_warning_msg - fi - ( - . ${file} - - # Will not process this service if started by boot, and ONBOOT - # is not set to yes - if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then - continue - fi - - # Will not process this service if started by hotplug, and - # ONHOTPLUG is not set to yes - if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" ]; then - continue - fi - - # This will run the service script, if SERVICE is set - if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then - if ip link show ${1} > /dev/null 2>&1 - then - IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} down - else - message="Interface ${1} doesn't exist." - log_warning_msg - fi - else - echo -e "${FAILURE}Unable to process ${file}. Either" - echo -e "${FAILURE}the SERVICE variable was not set," - echo -e "${FAILURE}or the specified service cannot be executed." - message="" - log_failure_msg - fi - ) -done - -if [ -z "${2}" ]; then - link_status=`ip link show $1` - if [ -n "${link_status}" ]; then - if echo "${link_status}" | grep -q UP; then - message="Bringing down the ${1} interface..." - ip link set ${1} down - evaluate_retval standard - fi - fi -fi - -# End $NETWORK_DEVICES/ifdown diff --git a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifup b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifup deleted file mode 100644 index 50e173ca6..000000000 --- a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifup +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $NETWORK_DEVICES/ifup -# -# Description : Interface Up -# -# Authors : Nathan Coulson - nathan@linuxfromscratch.org -# Kevin P. Fleming - kpfleming@linuxfromscratch.org -# -# Version : 00.00 -# -# Notes : the IFCONFIG variable is passed to the scripts found -# in the services directory, to indicate what file the -# service should source to get environmental variables. -# -######################################################################## - -. /lib/lsb/init-functions - -# Collect a list of configuration files for our interface -if [ -n "${2}" ]; then - for file in ${@#$1} # All parameters except $1 - do - FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}" - done -elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then - FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*` -else - FILES="${NETWORK_DEVICES}/ifconfig.${1}" -fi - -message="Bringing up the ${1} interface..." - -# Process each configruation file -for file in ${FILES}; do - # skip backup files - if [ "${file}" != "${file%""~""}" ]; then - continue - fi - - if [ ! -f "${file}" ]; then - log_warning_msg - message="${file} is not a network configuration file or directory." - log_warning_msg - fi - - ( - . ${file} - - # Will not process this service if started by boot, and ONBOOT - # is not set to yes - if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then - continue - fi - # Will not process this service if started by hotplug, and - # ONHOTPLUG is not set to yes - if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" -a "${HOSTNAME}" != "(none)" ]; then - continue - fi - - if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then - if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then - if ip link show ${1} > /dev/null 2>&1; then - link_status=`ip link show ${1}` - if [ -n "${link_status}" ]; then - if ! echo "${link_status}" | grep -q UP; then - ip link set ${1} up - evaluate_retval standard - fi - fi - else - message="${message}Interface ${1} doesn't exist." - log_warning_msg - fi - fi - IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} up - else - echo -e "${FAILURE}Unable to process ${file}. Either" - echo -e "${FAILURE}the SERVICE variable was not set," - echo -e "${FAILURE}or the specified service cannot be executed." - message="" - log_failure_msg - fi - ) -done - -# End $NETWORK_DEVICES/ifup diff --git a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static deleted file mode 100644 index 417d22de6..000000000 --- a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $NETWORK_DEVICES/services/ipv4-static -# -# Description : IPV4 Static Boot Script -# -# Authors : Nathan Coulson - nathan@linuxfromscratch.org -# Kevin P. Fleming - kpfleming@linuxfromscratch.org -# -# Version : 00.00 -# -# Notes : -# -######################################################################## - -. /lib/lsb/init-functions -. ${IFCONFIG} - -if [ -z "${IP}" ]; then - log_failure_msg "IP variable missing from ${IFCONFIG}, cannot continue." - exit 1 -fi - -if [ -z "${PREFIX}" -a -z "${PEER}" ]; then - log_warning_msg "PREFIX variable missing from ${IFCONFIG}, assuming 24." - PREFIX=24 - args="${args} ${IP}/${PREFIX}" -elif [ -n "${PREFIX}" -a -n "${PEER}" ]; then - log_failure_msg "PREFIX and PEER both specified in ${IFCONFIG}, cannot continue." - exit 1 -elif [ -n "${PREFIX}" ]; then - args="${args} ${IP}/${PREFIX}" -elif [ -n "${PEER}" ]; then - args="${args} ${IP} peer ${PEER}" -fi - -if [ -n "${BROADCAST}" ]; then - args="${args} broadcast ${BROADCAST}" -fi - -if [ -n "${SOURCE}" ]; then - args="${args} src ${SOURCE}" -fi - -case "${2}" in - up) - MESSAGE="Adding IPv4 address ${IP} to the ${1} interface..." - ip addr add ${args} dev ${1} - evaluate_retval - - if [ -n "${GATEWAY}" ]; then - if ip route | grep -q default; then - log_warning_msg "Gateway already setup; skipping." ${WARNING} - else - MESSAGE="Setting up default gateway..." - ip route add default via ${GATEWAY} dev ${1} - evaluate_retval - fi - fi - ;; - - down) - if [ -n "${GATEWAY}" ]; then - MESSAGE="Removing default gateway..." - ip route del default - evaluate_retval - fi - - MESSAGE="Removing IPv4 address ${IP} from the ${1} interface..." - ip addr del ${args} dev ${1} - evaluate_retval - ;; - - *) - echo "Usage: ${0} [interface] {up|down}" - exit 1 - ;; -esac - -# End $NETWORK_DEVICES/services/ipv4-static diff --git a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static-route b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static-route deleted file mode 100644 index 4205a022d..000000000 --- a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static-route +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $NETWORK_DEVICES/services/ipv4-static-route -# -# Description : IPV4 Static Route Script -# -# Authors : Kevin P. Fleming - kpfleming@linuxfromscratch.org -# -# Version : 00.00 -# -# Notes : -# -######################################################################## - -. /lib/lsb/init-functions -. ${IFCONFIG} - -case "${TYPE}" in - ("" | "network") - need_ip=1 - need_gateway=1 - ;; - - ("default") - need_gateway=1 - args="${args} default" - desc="default" - ;; - - ("host") - need_ip=1 - ;; - - ("unreachable") - need_ip=1 - args="${args} unreachable" - desc="unreachable " - ;; - - (*) - boot_mesg "Unknown route type (${TYPE}) in ${IFCONFIG}, cannot continue." ${FAILURE} - echo_failure - exit 1 - ;; -esac - -if [ -n "${need_ip}" ]; then - if [ -z "${IP}" ]; then - boot_mesg "IP variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} - echo_failure - exit 1 - fi - - if [ -z "${PREFIX}" ]; then - boot_mesg "PREFIX variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} - echo_failure - exit 1 - fi - - args="${args} ${IP}/${PREFIX}" - desc="${desc}${IP}/${PREFIX}" -fi - -if [ -n "${need_gateway}" ]; then - if [ -z "${GATEWAY}" ]; then - boot_mesg "GATEWAY variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} - echo_failure - exit 1 - fi - args="${args} via ${GATEWAY}" -fi - -case "${2}" in - up) - boot_mesg "Adding '${desc}' route to the ${1} interface..." - ip route add ${args} dev ${1} - evaluate_retval - ;; - - down) - boot_mesg "Removing '${desc}' route from the ${1} interface..." - ip route del ${args} dev ${1} - evaluate_retval - ;; - - *) - echo "Usage: ${0} [interface] {up|down}" - exit 1 - ;; -esac - -# End $NETWORK_DEVICES/services/ipv4-static-route diff --git a/bootscripts/contrib/lsb-v3/sysconfig/rc b/bootscripts/contrib/lsb-v3/sysconfig/rc deleted file mode 100644 index ffb70d98c..000000000 --- a/bootscripts/contrib/lsb-v3/sysconfig/rc +++ /dev/null @@ -1,52 +0,0 @@ -# Begin /etc/sysconfig/rc - -# Author: DJ Lucas - dj@linuxfromscratch.org -# Version: 1.0 LSB V.3.1 - -# Global variable inherited by initscripts are in caps -# Local variables for the rc script are in lowercase - -# Source site specific rc configuration -. /etc/sysconfig/rc.site - -# This sets default terminal options. -# stty sane - this has been removed as nobody recalls -# the reason for it in the first place - if no problems arize, -# then it will be removed completely at a later date. - -# Setup default values for the environment -umask 022 -PATH="/bin:/sbin" - -# 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 Cursur Position Commands, used via echo -e -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 - -# Bootlogging and interactive startup require a valid tempfs mount -# if this mount is not present, disable them -if [ "${TEMPFS_MOUNT}" = "" -o ! -d "${TEMPFS_MOUNT}" ]; then - TEMPFS_MOUNT="" - iprompt="" - BOOTLOG_ENAB="" -fi - -# Export the environment variables so they are inherited by the scripts -export PATH SET_COL SET_WCOL CURS_UP TEMPFS_MOUNT BOOTLOG_ENAB RUNLEVEL - -# End /etc/sysconfig/rc diff --git a/bootscripts/contrib/lsb-v3/sysconfig/rc.site b/bootscripts/contrib/lsb-v3/sysconfig/rc.site deleted file mode 100644 index f3369db58..000000000 --- a/bootscripts/contrib/lsb-v3/sysconfig/rc.site +++ /dev/null @@ -1,81 +0,0 @@ -# Set base directory information -RC_BASE="/etc" -RC_FUNCTIONS="${RC_BASE}/init.d/lfs-functions" - -# Location of network device scripts and config files -NETWORK_DEVICES="/etc/sysconfig/network-devices" - -# Directory to store boot process accounting information -# Used for boot logging and interactive flag when rootfs -# is not writable -TEMPFS_MOUNT="${RC_BASE}/init.d/boottemp" - -# Bootlogging (requires a tempfs mount) -BOOTLOG_ENAB="yes" - -# Hostname -HOSTNAME= - -# System time variables -UTC=1 -CLOCKPARAMS= - -# Manual input is not appropriate on remote systems. Define what happens when -# an error is encountered that interupts the boot/shutdown proceess -FAILURE_ACTION="read ENTER" - -# Distro Information -DISTRO="Linux From Scratch" # The distro name -DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address -DISTRO_MINI="lfs" # Short name used in filenames for distro config - -# Define custom colors used in messages printed to the screen -BRACKET="\\033[1;34m" # Blue -FAILURE="\\033[1;31m" # Red -INFO="\\033[1;36m" # Cyan -NORMAL="\\033[0;39m" # Grey -SUCCESS="\\033[1;32m" # Green -WARNING="\\033[1;33m" # Yellow - -# Prefix boot messages for easier reading on framebuffer consoles -PREFIX_SUCCESS=" ${SUCCESS}*${NORMAL} " -PREFIX_WARNING="${WARNING}**${NORMAL} " -PREFIX_FAILURE="${FAILURE}***${NORMAL}" - -# Export varialbles so that they are inherited by the initscripts -export RC_BASE RC_FUNCTIONS NETWORK_DEVICES TEMPFS_MOUNT BOOTLOG_ENAB -export HOSTNAME UTC CLOCKPARAMS FAILURE_ACTION -export DISTRO DISTRO_CONTACT DISTRO_MINI -export BRACKET FAILURE INFO NORMAL SUCCESS WARNING -export PREFIX_SUCCESS PREFIX_WARNING PREFIX_FAILURE - -# Interactive startup -iprompt="yes" # Wether to display the interactive boot promp -itime="2" # The ammount of time (in seconds) to display the prompt -dlen="29" # The total length of the distro welcome string -ilen="38" # The total length of the interactive message -welcome_message="Welcome to ${INFO}${DISTRO}${NORMAL}" -i_message="Press '${FAILURE}I${NORMAL}' to enter interactive startup" - -# Error message displayed when a script's exit value is not zero -print_error_msg() -{ - # ${link} and ${error_value} are defined by the rc script - echo -e "${FAILURE}FAILURE: You should not be reading this error message." - echo -e "" - echo -e -n "${FAILURE}It means that an unforseen error took place in" - echo -e -n "${INFO} ${link}" - echo -e "${FAILURE}," - echo -e "${FAILURE}which exited with a return value of ${error_value}." - echo -e "" - echo -e -n "${FAILURE}If you are able to track this error down to a bug" - echo -e "${FAILURE}in one of the files" - echo -e -n "provided by ${INFO}${DISTRO}${FAILURE}, " - echo -e -n "${FAILURE}please be so kind to inform us at " - echo -e "${INFO}${DISTRO_CONTACT}${FAILURE}.${NORMAL}" - echo -e "" - echo -e "${INFO}Press Enter to continue..." - echo -e "${NORMAL}" - $FAILURE_ACTION -} - -- cgit v1.2.3-54-g00ecf