git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9532 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
DJ Lucas 2011-05-14 21:00:31 +00:00
parent b4a678295e
commit dc55fb5e4b
17 changed files with 98 additions and 76 deletions

View File

@ -5,6 +5,13 @@ ChangeLog
where user input is not appropriate in the event of a failure where user input is not appropriate in the event of a failure
* Moved configuration of clock and hostname to rc.site * Moved configuration of clock and hostname to rc.site
* Removed $time provides from setclock script * Removed $time provides from setclock script
* Setup the /run mountpoint in the rc script (for use by bootloging)
* Moved network services to /lib/network-services
* Moved network configuration files to /etc/network
* Moved ifup and ifdown scripts to /sbin
* ifup - copy network configuration scritps to /run on startup
* ifdown - use running configuration stored in /run to stop interfaces
* Moved sysconfig files to /etc/default
20110424 - [dj] 20110424 - [dj]
* Sync to LFS-Bootscripts-20110424 (move new run mounts and * Sync to LFS-Bootscripts-20110424 (move new run mounts and

View File

@ -17,6 +17,7 @@ create-dirs:
install -d -m ${DIRMODE} ${EXTDIR}/rcS.d install -d -m ${DIRMODE} ${EXTDIR}/rcS.d
install -d -m ${DIRMODE} ${EXTDIR}/init.d install -d -m ${DIRMODE} ${EXTDIR}/init.d
install -d -m ${DIRMODE} ${EXTDIR}/default install -d -m ${DIRMODE} ${EXTDIR}/default
install -d -m ${DIRMODE} ${EXTDIR}/network
install -d -m ${DIRMODE} ${DESTDIR}/lib/lsb install -d -m ${DIRMODE} ${DESTDIR}/lib/lsb
install -d -m ${DIRMODE} ${EXTDIR}/lsb/state install -d -m ${DIRMODE} ${EXTDIR}/lsb/state
install -d -m ${DIRMODE} ${DESTDIR}/lib/network-services install -d -m ${DIRMODE} ${DESTDIR}/lib/network-services

View File

@ -1,5 +1,5 @@
######################################################################## ########################################################################
# Begin /etc/sysconfig/createfiles # Begin /etc/default/createfiles
# #
# Description : Createfiles script config file # Description : Createfiles script config file
# #

View File

@ -1,5 +1,5 @@
######################################################################## ########################################################################
# Begin /etc/sysconfig/modules # Begin /etc/default/modules
# #
# Description : Module auto-loading configuration # Description : Module auto-loading configuration
# #
@ -15,4 +15,4 @@
# a space or a tab. # a space or a tab.
######################################################################## ########################################################################
# End /etc/sysconfig/modules # End /etc/default/modules

View File

@ -1,4 +1,4 @@
# Begin /etc/sysconfig/rc # Begin /etc/default/rc
# Author: DJ Lucas - dj@linuxfromscratch.org # Author: DJ Lucas - dj@linuxfromscratch.org
# Version: 1.0 LSB V.3.1 # Version: 1.0 LSB V.3.1
@ -7,7 +7,7 @@
# Local variables for the rc script are in lowercase # Local variables for the rc script are in lowercase
# Source site specific rc configuration # Source site specific rc configuration
. /etc/sysconfig/rc.site . /etc/default/rc.site
# This sets default terminal options. # This sets default terminal options.
# stty sane - this has been removed as nobody recalls # stty sane - this has been removed as nobody recalls
@ -38,15 +38,7 @@ SET_COL="\\033[${COL}G" # at the $COL char
SET_WCOL="\\033[${WCOL}G" # at the $WCOL char SET_WCOL="\\033[${WCOL}G" # at the $WCOL char
CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char CURS_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 the environment variables so they are inherited by the scripts
export PATH SET_COL SET_WCOL CURS_UP TEMPFS_MOUNT BOOTLOG_ENAB RUNLEVEL export PATH SET_COL SET_WCOL CURS_UP BOOTLOG_ENAB
# End /etc/sysconfig/rc # End /etc/default/rc

View File

@ -3,12 +3,7 @@ RC_BASE="/etc"
RC_FUNCTIONS="${RC_BASE}/init.d/lfs-functions" RC_FUNCTIONS="${RC_BASE}/init.d/lfs-functions"
# Location of network device scripts and config files # Location of network device scripts and config files
NETWORK_DEVICES="/etc/sysconfig/network-devices" NETWORK_DEVICES="/etc/network"
# 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) # Bootlogging (requires a tempfs mount)
BOOTLOG_ENAB="yes" BOOTLOG_ENAB="yes"
@ -43,7 +38,7 @@ PREFIX_WARNING="${WARNING}**${NORMAL} "
PREFIX_FAILURE="${FAILURE}***${NORMAL}" PREFIX_FAILURE="${FAILURE}***${NORMAL}"
# Export varialbles so that they are inherited by the initscripts # Export varialbles so that they are inherited by the initscripts
export RC_BASE RC_FUNCTIONS NETWORK_DEVICES TEMPFS_MOUNT BOOTLOG_ENAB export RC_BASE RC_FUNCTIONS NETWORK_DEVICES BOOTLOG_ENAB
export HOSTNAME UTC CLOCKPARAMS FAILURE_ACTION export HOSTNAME UTC CLOCKPARAMS FAILURE_ACTION
export DISTRO DISTRO_CONTACT DISTRO_MINI export DISTRO DISTRO_CONTACT DISTRO_MINI
export BRACKET FAILURE INFO NORMAL SUCCESS WARNING export BRACKET FAILURE INFO NORMAL SUCCESS WARNING
@ -79,3 +74,4 @@ print_error_msg()
$FAILURE_ACTION $FAILURE_ACTION
} }

View File

@ -12,7 +12,7 @@
# Short-Description: Cleans temporary directories early in the boot process. # Short-Description: Cleans temporary directories early in the boot process.
# Description: Cleans temporary directories /var/run, /var/lock, and # Description: Cleans temporary directories /var/run, /var/lock, and
# /tmp. cleanfs also creates /var/run/utmp and any files # /tmp. cleanfs also creates /var/run/utmp and any files
# defined in /etc/sysconfig/createfiles. # defined in /etc/default/createfiles.
# X-LFS-Provided-By: LFS # X-LFS-Provided-By: LFS
### END INIT INFO ### END INIT INFO
@ -22,7 +22,7 @@
create_files() create_files()
{ {
# Read in the configuration file. # Read in the configuration file.
exec 9>&0 < /etc/sysconfig/createfiles exec 9>&0 < /etc/default/createfiles
while read name type perm usr grp dtype maj min junk while read name type perm usr grp dtype maj min junk
do do
# Ignore comments and blank lines. # Ignore comments and blank lines.
@ -89,7 +89,7 @@ case "${1}" in
(exit ${failed}) (exit ${failed})
evaluate_retval standard evaluate_retval standard
if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null if egrep -qv '^(#|$)' /etc/default/createfiles 2>/dev/null
then then
message="Creating files and directories..." message="Creating files and directories..."
create_files create_files

View File

@ -11,7 +11,7 @@
# Default-Stop: # Default-Stop:
# Short-Description: Sets up a localised console. # Short-Description: Sets up a localised console.
# Description: Sets up fonts and language settings for the user's # Description: Sets up fonts and language settings for the user's
# local as defined by /etc/sysconfig/console. # local as defined by /etc/default/console.
# X-LFS-Provided-By: LFS # X-LFS-Provided-By: LFS
### END INIT INFO ### END INIT INFO
@ -19,10 +19,10 @@
MESSAGE="Setting up Linux console..." MESSAGE="Setting up Linux console..."
# Native English speakers probably don't have /etc/sysconfig/console at all # Native English speakers probably don't have /etc/default/console at all
if [ -f /etc/sysconfig/console ] if [ -f /etc/default/console ]
then then
. /etc/sysconfig/console . /etc/default/console
fi fi
is_true() { is_true() {

View File

@ -10,7 +10,7 @@
# Default-Start: S # Default-Start: S
# Default-Stop: # Default-Stop:
# Short-Description: Loads required modules. # Short-Description: Loads required modules.
# Description: Loads modules listed in /etc/sysconfig/modules. # Description: Loads modules listed in /etc/default/modules.
# X-LFS-Provided-By: LFS # X-LFS-Provided-By: LFS
### END INIT INFO ### END INIT INFO
@ -24,8 +24,8 @@ case "${1}" in
# Exit if there's no modules file or there are no # Exit if there's no modules file or there are no
# valid entries # valid entries
[ -r /etc/sysconfig/modules ] && [ -r /etc/default/modules ] &&
egrep -qv '^($|#)' /etc/sysconfig/modules || egrep -qv '^($|#)' /etc/default/modules ||
exit 0 exit 0
# If proc is mounted, find the current kernel # If proc is mounted, find the current kernel
@ -44,11 +44,11 @@ case "${1}" in
# Only try to load modules if the user has actually given us # Only try to load modules if the user has actually given us
# some modules to load. # some modules to load.
if egrep -qv '^(#|$)' /etc/sysconfig/modules 2>/dev/null if egrep -qv '^(#|$)' /etc/default/modules 2>/dev/null
then then
# Read in the configuration file. # Read in the configuration file.
exec 9>&0 < /etc/sysconfig/modules exec 9>&0 < /etc/default/modules
message="${INFO}Loading modules:" message="${INFO}Loading modules:"

View File

@ -30,11 +30,8 @@ case "${1}" in
mount -n /sys || failed=1 mount -n /sys || failed=1
fi fi
if ! mountpoint /run > /dev/null; then # create needed directories in /run
message="${message}${INFO} /run${NORMAL}"
mount -n /run || failed=1
mkdir /run/{var,lock,shm} || failed=1 mkdir /run/{var,lock,shm} || failed=1
fi
(exit ${failed}) (exit ${failed})
evaluate_retval standard evaluate_retval standard

View File

@ -15,7 +15,6 @@
### END INIT INFO ### END INIT INFO
. /lib/lsb/init-functions . /lib/lsb/init-functions
. /etc/sysconfig/network
case "${1}" in case "${1}" in
start) start)
@ -29,14 +28,14 @@ case "${1}" in
then then
continue continue
fi fi
IN_BOOT=1 ${NETWORK_DEVICES}/ifup ${interface} IN_BOOT=1 /sbin/ifup ${interface}
done done
;; ;;
stop) stop)
# Reverse list # Reverse list
FILES="" FILES=""
for file in ${NETWORK_DEVICES}/ifconfig.* for file in /run/network/ifconfig.*
do do
FILES="${file} ${FILES}" FILES="${file} ${FILES}"
done done
@ -52,7 +51,7 @@ case "${1}" in
continue continue
fi fi
IN_BOOT=1 ${NETWORK_DEVICES}/ifdown ${interface} IN_BOOT=1 /sbin/ifdown ${interface}
done done
;; ;;

View File

@ -3,7 +3,7 @@
# Get the configuration file # Get the configuration file
# All changes are to occur in the config file # All changes are to occur in the config file
. /etc/sysconfig/rc . /etc/default/rc
# These 3 signals will not cause our script to exit # These 3 signals will not cause our script to exit
trap "" INT QUIT TSTP trap "" INT QUIT TSTP
@ -25,9 +25,9 @@ if [ "${prevlevel}" = "" ]; then
prevlevel="N" prevlevel="N"
fi fi
# Mount a tmpfs to store boot accounting information # Mount /run
if [ "${runlevel}" = "S" -a "${TEMPFS_MOUNT}" != "" ]; then if [ "${runlevel}" = "S" ]; then
mount -n -t tmpfs tmpfs "${TEMPFS_MOUNT}" -o mode=600 mount -n -t tmpfs tmpfs /run
fi fi
# Provide an interactive prompt (if requested) # Provide an interactive prompt (if requested)
@ -52,7 +52,7 @@ if [ "${runlevel}" = "S" -a "${iprompt}" = "yes" ]; then
if [ "${interactive}" = "I" -o "${interactive}" = "i" ]; then if [ "${interactive}" = "I" -o "${interactive}" = "i" ]; then
echo -n -e "${CURS_UP}" echo -n -e "${CURS_UP}"
echo -e "${INFO}Interactive boot selected...${NORMAL}" echo -e "${INFO}Interactive boot selected...${NORMAL}"
echo "interactive=I" > "${TEMPFS_MOUNT}/.interactive-start" echo "interactive=I" > /run/.interactive-start
fi fi
fi fi
fi fi
@ -66,8 +66,8 @@ if [ ! -d "${RC_BASE}/rc${runlevel}.d" ]; then
fi fi
# Source the interactive state file if it exists # Source the interactive state file if it exists
if [ "${runlevel}" != "S" -a -f "${TEMPFS_MOUNT}/.interactive-start" ]; then if [ "${runlevel}" != "S" -a -f /run/.interactive-start ]; then
. "${TEMPFS_MOUNT}/.interactive-start" . /run/.interactive-start
fi fi
# Prompt for interactive startup after completing S # Prompt for interactive startup after completing S
@ -180,17 +180,22 @@ done
# Strip apply time to the logs, strip out any color codes and dump # Strip apply time to the logs, strip out any color codes and dump
# the log to /var/log/boot.log # the log to /var/log/boot.log
if [ -f "${TEMPFS_MOUNT}/.bootlog" -a "${runlevel}" != "S" ]; then if [ -f /run/.bootlog -a "${runlevel}" != "S" ]; then
# Remove any color codes from the temp log file # Remove any color codes from the temp log file
sed -i 's@\\033\[[0-9];[0-9][0-9]m@@g' "${TEMPFS_MOUNT}/.bootlog" sed -i 's@\\033\[[0-9];[0-9][0-9]m@@g' /run/.bootlog
#Fix the time and hostname #Fix the time and hostname
BTIMESPEC=$(echo `date +"%b %d %T"` `hostname`) BTIMESPEC=$(echo `date +"%b %d %T"` `hostname`)
sed -i "s@^bootlog:@${BTIMESPEC} bootlog:@" "${TEMPFS_MOUNT}/.bootlog" sed -i "s@^bootlog:@${BTIMESPEC} bootlog:@" /run/.bootlog
# Don't try and write in 0 and 6, this is a 'boot' log # Don't try and write in 0 and 6, this is a 'boot' log
if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then
cat "${TEMPFS_MOUNT}/.bootlog" >> /var/log/boot.log cat /run/.bootlog >> /var/log/boot.log
rm -f "${TEMPFS_MOUNT}/.bootlog" rm -f /run/.bootlog
fi fi
fi fi
# Remove interactive boot temp file
if [ -f /run/.interactive-start -a "${runlevel}" != "S" ]; then
rm -f /run/.interactive-start
fi
# End $RC_BASE/init.d/rc # End $RC_BASE/init.d/rc

View File

@ -24,7 +24,7 @@
# documentaion in the lfs-fucntions file for more information. # documentaion in the lfs-fucntions file for more information.
MESSAGE="Template Service" MESSAGE="Template Service"
BIN_FILE="/some/path/to/template" BIN_FILE="/some/path/to/template"
CONFIGFILE="/etc/sysconfig/template.conf" CONFIGFILE="/etc/default/template.conf"
# check that $BIN_FILE exists and is executable, and $CONFIGFILE exists. # check that $BIN_FILE exists and is executable, and $CONFIGFILE exists.
chk_stat chk_stat

View File

@ -33,10 +33,11 @@ case "${1}" in
/etc/rc.d/init.d/halt stop /etc/rc.d/init.d/halt stop
fi fi
# Mount a temporary file system over /dev, so that any devices # If not using DEVTMPFS mount a temporary file system over
# made or removed during this boot don't affect the next one. # /dev, so that any devices made or removed during this boot
# The reason we don't write to mtab is because we don't ever # don't affect the next one. The reason we don't write to mtab
# want /dev to be unavailable (such as by `umount -a'). # is because we don't ever want /dev to be unavailable (such as
# by `umount -a').
if ! mountpoint /dev > /dev/null; then if ! mountpoint /dev > /dev/null; then
mount -n -t tmpfs tmpfs /dev -o mode=755 mount -n -t tmpfs tmpfs /dev -o mode=755
fi fi
@ -57,11 +58,14 @@ case "${1}" in
# Udev handles uevents itself, so we don't need to have # Udev handles uevents itself, so we don't need to have
# the kernel call out to any binary in response to them # the kernel call out to any binary in response to them
# This is a failsafe and should be done in kernel config
echo > /proc/sys/kernel/hotplug echo > /proc/sys/kernel/hotplug
# Copy the only static device node that Udev >= 155 doesn't # Copy the only static device node that Udev >= 155 doesn't
# handle to /dev # handle to /dev (handled by default with DEVTMPFS)
if [ ! -f /dev/null ]; then
cp -a /lib/udev/devices/null /dev cp -a /lib/udev/devices/null /dev
fi
# Start the udev daemon to continually watch for, and act on, # Start the udev daemon to continually watch for, and act on,
# uevents # uevents

View File

@ -5,7 +5,7 @@
# Source rc configuration if not inherited from the environment # Source rc configuration if not inherited from the environment
if [ "${RC_BASE}" = "" ]; then if [ "${RC_BASE}" = "" ]; then
. /etc/sysconfig/rc . /etc/default/rc
fi fi
# Source the distro functions file # Source the distro functions file
@ -449,7 +449,9 @@ log_success_msg()
else else
BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) "
fi fi
echo "${BTTIMESPEC}bootlog: ${@} Successful" >> "${TEMPFS_MOUNT}/.bootlog" if [ "${RUNLEVEL}" != "0" -a "${RUNLEVEL}" != "6" ]; then
echo "${BTTIMESPEC}bootlog: ${@} Successful" >> /run/.bootlog
fi
fi fi
return 0 return 0
} }
@ -476,7 +478,9 @@ log_failure_msg()
else else
BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) "
fi fi
echo "${BTTIMESPEC}bootlog: ${@} Failed!" >> "${TEMPFS_MOUNT}/.bootlog" if [ "${RUNLEVEL}" != "0" -a "${RUNLEVEL}" != "6" ]; then
echo "${BTTIMESPEC}bootlog: ${@} Failed!" >> /run/.bootlog
fi
fi fi
return 0 return 0
} }
@ -503,7 +507,9 @@ log_warning_msg()
else else
BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) " BTTIMESPEC="$(echo `date -u +"%b %d %T"` `hostname`) "
fi fi
echo "${BTTIMESPEC}bootlog: ${@} Warning" >> "${TEMPFS_MOUNT}/.bootlog" if [ "${RUNLEVEL}" != "0" -a "${RUNLEVEL}" != "6" ]; then
echo "${BTTIMESPEC}bootlog: ${@} Warning" >> /run/.bootlog
fi
fi fi
return 0 return 0
} }

View File

@ -20,12 +20,12 @@
# Collect a list of configuration files for our interface # Collect a list of configuration files for our interface
if [ -n "${2}" ]; then if [ -n "${2}" ]; then
for file in ${@#$1}; do # All parameters except $1 for file in ${@#$1}; do # All parameters except $1
FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}" FILES="${FILES} /run/network/ifconfig.${1}/${file}"
done done
elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then elif [ -d "/run/network/ifconfig.${1}" ]; then
FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*` FILES=`echo /run/network/ifconfig.${1}/*`
else else
FILES="${NETWORK_DEVICES}/ifconfig.${1}" FILES="/run/network/ifconfig.${1}"
fi fi
# Reverse the order configuration files are processed in # Reverse the order configuration files are processed in
@ -46,7 +46,9 @@ for file in ${FILES}; do
log_warning_msg log_warning_msg
fi fi
( (
if [ ! -d "${file}" ]; then
. ${file} . ${file}
fi
# Will not process this service if started by boot, and ONBOOT # Will not process this service if started by boot, and ONBOOT
# is not set to yes # is not set to yes
@ -61,10 +63,13 @@ for file in ${FILES}; do
fi fi
# This will run the service script, if SERVICE is set # This will run the service script, if SERVICE is set
if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then if [ -n "${SERVICE}" -a -x "/lib/network-services/${SERVICE}" ]; then
if ip link show ${1} > /dev/null 2>&1 if ip link show ${1} > /dev/null 2>&1
then then
IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} down IFCONFIG=${file} /lib/network-services/${SERVICE} ${1} down &&
if [ -f "${file}" ]; then
rm ${file}
fi
else else
message="Interface ${1} doesn't exist." message="Interface ${1} doesn't exist."
log_warning_msg log_warning_msg

View File

@ -45,7 +45,9 @@ for file in ${FILES}; do
fi fi
( (
if [ ! -d "${file}" ]; then
. ${file} . ${file}
fi
# Will not process this service if started by boot, and ONBOOT # Will not process this service if started by boot, and ONBOOT
# is not set to yes # is not set to yes
@ -58,7 +60,7 @@ for file in ${FILES}; do
continue continue
fi fi
if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then if [ -n "${SERVICE}" -a -x "/lib/network-services/${SERVICE}" ]; then
if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; 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 if ip link show ${1} > /dev/null 2>&1; then
link_status=`ip link show ${1}` link_status=`ip link show ${1}`
@ -73,7 +75,15 @@ for file in ${FILES}; do
log_warning_msg log_warning_msg
fi fi
fi fi
IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} up IFCONFIG=${file} /lib/network-services/${SERVICE} ${1} up
if [ "${?}" -eq "0" ]; then
if [ ! -d "${file}" -a "${file}" != "${NETWORK_DEVICES}/ifconfig.${1}" ]; then
mkdir -p "/run/network/ifconfig.${1}"
cp "${file}" "/run/network/ifconfig.${1}"
elif [ ! -d "${file}" ]; then
cp "${file}" "/run/network/"
fi
fi
else else
echo -e "${FAILURE}Unable to process ${file}. Either" echo -e "${FAILURE}Unable to process ${file}. Either"
echo -e "${FAILURE}the SERVICE variable was not set," echo -e "${FAILURE}the SERVICE variable was not set,"