Remove traditional Sysvinit bootscripts and custom Udev rules in preparation for Systemd integration.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/systemd/BOOK@10117 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
Matthew Burgess 2013-02-06 10:23:28 +00:00
parent 56b4279de8
commit 9be389cd04
64 changed files with 12 additions and 7473 deletions

View File

@ -85,13 +85,9 @@ tmpdir:
$(Q)rm -f $(RENDERTMP)/lfs-pdf.fo
validate: tmpdir
@echo "Processing bootscripts..."
$(Q)bash process-scripts.sh
@echo "Validating the book..."
$(Q)xmllint --nonet --noent --xinclude --postvalid \
-o $(RENDERTMP)/lfs-full.xml index.xml
$(Q)rm -f appendices/*.script
$(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
@echo "Validation complete."
profile-html: validate
@ -111,12 +107,6 @@ md5sums:
$(Q)mkdir -p $(BASEDIR)
$(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/md5sums \
stylesheets/md5sum.xsl chapter03/chapter03.xml
$(Q)sed -i -e "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.bz2 | cut -d' ' -f1)/" \
$(BASEDIR)/md5sums
#$(Q)sed -i -e "s/UDEV-MD5SUM/$(shell md5sum udev-config*.tar.bz2 | cut -d' ' -f1)/" \
# $(BASEDIR)/md5sums
dump-commands: validate
@echo "Dumping book commands..."

View File

@ -1,195 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
<!ENTITY checkfs SYSTEM "checkfs.script">
<!ENTITY cleanfs SYSTEM "cleanfs.script">
<!ENTITY console SYSTEM "console.script">
<!ENTITY functions SYSTEM "functions.script">
<!ENTITY halt SYSTEM "halt.script">
<!ENTITY initfunctions SYSTEM "init-functions.script">
<!ENTITY localnet SYSTEM "localnet.script">
<!ENTITY modules SYSTEM "modules.script">
<!ENTITY mountfs SYSTEM "mountfs.script">
<!ENTITY mountvirtfs SYSTEM "mountvirtfs.script">
<!ENTITY network SYSTEM "network.script">
<!ENTITY rc SYSTEM "rc.script">
<!ENTITY reboot SYSTEM "reboot.script">
<!ENTITY sendsignals SYSTEM "sendsignals.script">
<!ENTITY setclock SYSTEM "setclock.script">
<!ENTITY swap SYSTEM "swap.script">
<!ENTITY sysctl SYSTEM "sysctl.script">
<!ENTITY sysklogd SYSTEM "sysklogd.script">
<!ENTITY template SYSTEM "template.script">
<!ENTITY udev SYSTEM "udev.script">
<!ENTITY udev_retry SYSTEM "udev_retry.script">
<!ENTITY createfiles SYSTEM "createfiles.script">
<!ENTITY modules_sys SYSTEM "modules-sysinit.script">
<!ENTITY cfg_udev_retry SYSTEM "config-udev-retry.script">
<!ENTITY ifup SYSTEM "ifup.script">
<!ENTITY ifdown SYSTEM "ifdown.script">
<!ENTITY ipv4_static SYSTEM "ipv4-static.script">
<!ENTITY ipv4_static_route SYSTEM "ipv4-static-route.script">
%general-entities;
]>
<appendix id="scripts" xreflabel="Appendix D">
<?dbhtml dir="scripts"?>
<?dbhtml filename="scripts.html"?>
<title>Boot and sysconfig scripts version-&lfs-bootscripts-version;</title>
<para>The scripts in this appendix are listed by the directory where they
normally reside. The order is <filename
class='directory'>/etc/rc.d/init.d</filename>, <filename
class='directory'>/etc/sysconfig</filename>, <filename
class='directory'>/etc/sysconfig/network-devices</filename>, and <filename
class='directory'>/etc/sysconfig/network-devices/services</filename>. Within
each section, the files are listed in the order they are normally called.
</para>
<sect1 id="rc" role="wrap">
<title>/etc/rc.d/init.d/rc</title>
<para>The <systemitem>rc</systemitem> script is the first script called by
<application>init</application> and initiates the boot process.</para>
<screen>&rc;</screen>
</sect1>
<sect1 id="init-functions" role="wrap">
<title>/lib/lsb/init-functions</title>
<screen>&initfunctions;</screen>
</sect1>
<sect1 id="functions" role="wrap">
<title>/etc/rc.d/init.d/functions</title>
<screen>&functions;</screen>
</sect1>
<sect1 id="mountvirtfs" role="wrap">
<title>/etc/rc.d/init.d/mountvirtfs</title>
<screen>&mountvirtfs;</screen>
</sect1>
<sect1 id="modules" role="wrap">
<title>/etc/rc.d/init.d/modules</title>
<screen>&modules;</screen>
</sect1>
<sect1 id="udev" role="wrap">
<title>/etc/rc.d/init.d/udev</title>
<screen>&udev;</screen>
</sect1>
<sect1 id="swap" role="wrap">
<title>/etc/rc.d/init.d/swap</title>
<screen>&swap;</screen>
</sect1>
<sect1 id="setclock" role="wrap">
<title>/etc/rc.d/init.d/setclock</title>
<screen>&setclock;</screen>
</sect1>
<sect1 id="checkfs" role="wrap">
<title>/etc/rc.d/init.d/checkfs</title>
<screen>&checkfs;</screen>
</sect1>
<sect1 id="mountfs" role="wrap">
<title>/etc/rc.d/init.d/mountfs</title>
<screen>&mountfs;</screen>
</sect1>
<sect1 id="udev_retry" role="wrap">
<title>/etc/rc.d/init.d/udev_retry</title>
<screen>&udev_retry;</screen>
</sect1>
<sect1 id="cleanfs" role="wrap">
<title>/etc/rc.d/init.d/cleanfs</title>
<screen>&cleanfs;</screen>
</sect1>
<sect1 id="console" role="wrap">
<title>/etc/rc.d/init.d/console</title>
<screen>&console;</screen>
</sect1>
<sect1 id="localnet" role="wrap">
<title>/etc/rc.d/init.d/localnet</title>
<screen>&localnet;</screen>
</sect1>
<sect1 id="sysctlscript" role="wrap">
<title>/etc/rc.d/init.d/sysctl</title>
<screen>&sysctl;</screen>
</sect1>
<sect1 id="sysklogd" role="wrap">
<title>/etc/rc.d/init.d/sysklogd</title>
<screen>&sysklogd;</screen>
</sect1>
<sect1 id="network" role="wrap">
<title>/etc/rc.d/init.d/network</title>
<screen>&network;</screen>
</sect1>
<sect1 id="sendsignals" role="wrap">
<title>/etc/rc.d/init.d/sendsignals</title>
<screen>&sendsignals;</screen>
</sect1>
<sect1 id="rebootscript" role="wrap">
<title>/etc/rc.d/init.d/reboot</title>
<screen>&reboot;</screen>
</sect1>
<sect1 id="haltscript" role="wrap">
<title>/etc/rc.d/init.d/halt</title>
<screen>&halt;</screen>
</sect1>
<sect1 id="template" role="wrap">
<title>/etc/rc.d/init.d/template</title>
<screen>&template;</screen>
</sect1>
<sect1 id="modulessys" role="wrap">
<title>/etc/sysconfig/modules</title>
<screen>&modules_sys;</screen>
</sect1>
<sect1 id="createfiles" role="wrap">
<title>/etc/sysconfig/createfiles</title>
<screen>&createfiles;</screen>
</sect1>
<sect1 id="config-udev-retry" role="wrap">
<title>/etc/sysconfig/udev-retry</title>
<screen>&cfg_udev_retry;</screen>
</sect1>
<sect1 id="ifup" role="wrap">
<title>/sbin/ifup</title>
<screen>&ifup;</screen>
</sect1>
<sect1 id="ifdown" role="wrap">
<title>/sbin/ifdown</title>
<screen>&ifdown;</screen>
</sect1>
<sect1 id="ipv4static" role="wrap">
<title>/lib/services/ipv4-static</title>
<screen>&ipv4_static;</screen>
</sect1>
<sect1 id="ipv4route" role="wrap">
<title>/lib/services/ipv4-static-route</title>
<screen>&ipv4_static_route;</screen>
</sect1>
</appendix>

View File

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
<!ENTITY lfs-rules SYSTEM "55-lfs.rules.script">
%general-entities;
]>
<appendix id="rules" xreflabel="Appendix E">
<?dbhtml dir="scripts"?>
<?dbhtml filename="udev-rules.html"?>
<title>Udev configuration rules</title>
<para>The rules from &udev-lfs;.tar.bz2 in this appendix are listed for
convenience. Installation is normally done via instructions in <xref
linkend='ch-system-udev'/>. </para>
<sect1 id="lfsrules" role="wrap">
<title>55-lfs.rules</title>
<screen>&lfs-rules;</screen>
</sect1>
</appendix>

View File

@ -1,30 +0,0 @@
#!/bin/bash
if [ $# -lt 1 ] ; then
echo "This script needs the location of the xml file to update"
exit 1
fi
FILE=$1
./make-aux-files.sh
# Bootscript data
bootscripts=$(ls lfs-bootscripts*.bz2)
base=$(basename $bootscripts .tar.bz2)
bootsize=$(ls -lk $bootscripts | cut -f5 -d" ")
bootmd5=$(md5sum $bootscripts | cut -f1 -d" ")
# Figure intalled size of bootscripts
TOPDIR=$(pwd)
TMP_DIR=$(mktemp -d /tmp/lfsbootfiles.XXXXXX)
pushd $TMP_DIR > /dev/null
tar -xf $TOPDIR/$bootscripts
bootinstallsize=$(du -sk $TMP_DIR | cut -f1)
popd > /dev/null
rm -rf $TMP_DIR
sed -i -e s/BOOTSCRIPTS-SIZE/$bootsize/ \
-e s/BOOTSCRIPTS-INSTALL-KB/$bootinstallsize/ \
-e s/BOOTSCRIPTS-MD5SUM/$bootmd5/ $FILE

File diff suppressed because it is too large Load Diff

View File

@ -1,130 +0,0 @@
EXTDIR=${DESTDIR}/etc
LIBDIR=${DESTDIR}/lib/services
MAN8=${DESTDIR}/usr/share/man/man8
SBIN=${DESTDIR}/sbin
MODE=754
DIRMODE=755
CONFMODE=644
all: links
install: all
create-dirs:
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/rc0.d
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/rc1.d
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/rc2.d
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/rc3.d
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/rc4.d
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/rc5.d
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/rc6.d
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/rcS.d
install -d -m ${DIRMODE} ${EXTDIR}/rc.d/init.d
install -d -m ${DIRMODE} ${EXTDIR}/sysconfig
install -d -m ${DIRMODE} ${LIBDIR}
install -d -m ${DIRMODE} ${MAN8}
install -d -m ${DIRMODE} ${SBIN}
ln -sfn services ${DESTDIR}/lib/lsb
ln -sfn rc.d/init.d ${EXTDIR}/init.d
files: create-dirs
install -m ${MODE} lfs/init.d/checkfs ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/cleanfs ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/halt ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/console ${EXTDIR}/rc.d/init.d/
install -m ${CONFMODE} lfs/init.d/functions ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/localnet ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/modules ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/mountfs ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/mountvirtfs ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/network ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/rc ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/reboot ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/sendsignals ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/setclock ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/swap ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/sysctl ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/sysklogd ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/template ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/udev ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/init.d/udev_retry ${EXTDIR}/rc.d/init.d/
install -m ${MODE} lfs/sbin/ifup ${SBIN}
install -m ${MODE} lfs/sbin/ifdown ${SBIN}
install -m ${MODE} lfs/sbin/ifup.8 ${MAN8}
ln -sf ifup.8 ${MAN8}/ifdown.8
install -m ${MODE} lfs/lib/services/ipv4-static-route ${LIBDIR}
install -m ${MODE} lfs/lib/services/ipv4-static ${LIBDIR}
install -m ${CONFMODE} lfs/lib/services/init-functions ${LIBDIR}
if [ ! -f ${EXTDIR}/sysconfig/createfiles ]; then \
install -m ${CONFMODE} lfs/sysconfig/createfiles ${EXTDIR}/sysconfig/ ;\
fi
if [ ! -f ${EXTDIR}/sysconfig/modules ]; then \
install -m ${CONFMODE} lfs/sysconfig/modules ${EXTDIR}/sysconfig/ ;\
fi
if [ ! -f ${EXTDIR}/sysconfig/udev_retry ]; then \
install -m ${CONFMODE} lfs/sysconfig/udev_retry ${EXTDIR}/sysconfig/ ;\
fi
if [ ! -f ${EXTDIR}/sysconfig/rc.site ]; then \
install -m ${CONFMODE} lfs/sysconfig/rc.site ${EXTDIR}/sysconfig/ ;\
fi
links: rcS rc0 rc1 rc2 rc3 rc4 rc5 rc6
rcS: files
ln -sf ../init.d/mountvirtfs ${EXTDIR}/rc.d/rcS.d/S00mountvirtfs
ln -sf ../init.d/modules ${EXTDIR}/rc.d/rcS.d/S05modules
ln -sf ../init.d/localnet ${EXTDIR}/rc.d/rcS.d/S08localnet
ln -sf ../init.d/udev ${EXTDIR}/rc.d/rcS.d/S10udev
ln -sf ../init.d/swap ${EXTDIR}/rc.d/rcS.d/S20swap
ln -sf ../init.d/checkfs ${EXTDIR}/rc.d/rcS.d/S30checkfs
ln -sf ../init.d/mountfs ${EXTDIR}/rc.d/rcS.d/S40mountfs
ln -sf ../init.d/cleanfs ${EXTDIR}/rc.d/rcS.d/S45cleanfs
ln -sf ../init.d/udev_retry ${EXTDIR}/rc.d/rcS.d/S50udev_retry
ln -sf ../init.d/console ${EXTDIR}/rc.d/rcS.d/S70console
ln -sf ../init.d/sysctl ${EXTDIR}/rc.d/rcS.d/S90sysctl
rc0: files
ln -sf ../init.d/network ${EXTDIR}/rc.d/rc0.d/K80network
ln -sf ../init.d/sysklogd ${EXTDIR}/rc.d/rc0.d/K90sysklogd
ln -sf ../init.d/sendsignals ${EXTDIR}/rc.d/rc0.d/S60sendsignals
ln -sf ../init.d/swap ${EXTDIR}/rc.d/rc0.d/S65swap
ln -sf ../init.d/mountfs ${EXTDIR}/rc.d/rc0.d/S70mountfs
ln -sf ../init.d/localnet ${EXTDIR}/rc.d/rc0.d/S90localnet
ln -sf ../init.d/halt ${EXTDIR}/rc.d/rc0.d/S99halt
rc1: files
ln -sf ../init.d/network ${EXTDIR}/rc.d/rc1.d/K80network
ln -sf ../init.d/sysklogd ${EXTDIR}/rc.d/rc1.d/K90sysklogd
rc2: files
ln -sf ../init.d/network ${EXTDIR}/rc.d/rc2.d/K80network
ln -sf ../init.d/sysklogd ${EXTDIR}/rc.d/rc2.d/K90sysklogd
rc3: files
ln -sf ../init.d/sysklogd ${EXTDIR}/rc.d/rc3.d/S10sysklogd
ln -sf ../init.d/network ${EXTDIR}/rc.d/rc3.d/S20network
rc4: files
ln -sf ../init.d/sysklogd ${EXTDIR}/rc.d/rc4.d/S10sysklogd
ln -sf ../init.d/network ${EXTDIR}/rc.d/rc4.d/S20network
rc5: files
ln -sf ../init.d/sysklogd ${EXTDIR}/rc.d/rc5.d/S10sysklogd
ln -sf ../init.d/network ${EXTDIR}/rc.d/rc5.d/S20network
rc6: files
ln -sf ../init.d/network ${EXTDIR}/rc.d/rc6.d/K80network
ln -sf ../init.d/sysklogd ${EXTDIR}/rc.d/rc6.d/K90sysklogd
ln -sf ../init.d/sendsignals ${EXTDIR}/rc.d/rc6.d/S60sendsignals
ln -sf ../init.d/swap ${EXTDIR}/rc.d/rc6.d/S65swap
ln -sf ../init.d/mountfs ${EXTDIR}/rc.d/rc6.d/S70mountfs
ln -sf ../init.d/localnet ${EXTDIR}/rc.d/rc6.d/S90localnet
ln -sf ../init.d/reboot ${EXTDIR}/rc.d/rc6.d/S99reboot
uninstall:
rm -rf ${DESTDIR}/lib/services ${DESTDIR}/lib/lsb ${EXTDIR}/rc.d ${EXTDIR}/init.d \
${SBIN}/ifup ${SBIN}/ifdown ${MAN8}/ifup.8 ${MAN8}/ifdown.8 \
${EXTDIR}/sysconfig/rc
.PHONY: all create-dirs install files links rcS rc0 rc1 rc2 rc3 rc4 rc5 rc6 uninstall

View File

@ -1,74 +0,0 @@
Network Configuration:
Script Files:
/etc/rc.d/init.d/*
/sbin/ifup
/sbin/ifdown
/lib/lsb/*
Configuration Files:
/etc/sysconfig/ifconfig.*
Note: ifconfig.* files will be processed
in alphanumerical order on boot, and reversed on shutdown.
- IFACE : The interface that is being configured (e.g. eth0)
- SERVICE: Which script to run in services directory.
- ONBOOT : If set to yes, this interface will be started on bootup
/etc/sysconfig/network
- HOSTNAME: Value of the system's hostname (From LFS Book)
This value may also be set in /etc/sysconfig/rc.site
Additional Configuration:
SERVICE ipv4-static:
- IP : Static IP Address
- GATEWAY : Specifies the IP Address of the gateway server
- PREFIX : CIDR prefix of IP Address, defaults to 24 if not set
- PEER : IP Address of peer (for point-to-point connections and tunnels)
- BROADCAST: Broadcast address
SERVICE ipv4-static-route:
- TYPE : Network (default type if not specified), default, host or unreachable
- IP : IP Address of target (for network, host and unreachable)
- PREFIX : CIDR prefix of target (for network, host and unreachable)
- GATEWAY: IP Address of gateway to reach target (for network and default)
SetClock configuration:
/etc/rc.d/init.d/cleanfs
- SKIPTMPCLEAN: skips cleaning of /tmp directory
Configuration Files:
/etc/sysconfig/clock or /etc/sysconfig/rc.site
- UTC: 1 assumes hwclock is in UTC
0 assumes hwclock is in local time
- CLOCKPARAMS: any additional options to be passed to hwclock
CleanFS configuration:
Script Files:
/etc/rc.d/init.d/cleanfs
Configuration Files:
/etc/sysconfig/createfiles
Each line is parsed, using space as a deliminator.
[NAME] [TYPE] [PERMISSIONS] [USER] [GROUP]
The below fields are currently only used on dev type.
([DEV TYPE] [MAJOR#] [MINOR#])
Name:
File/Directory/Device name
Type:
dir: creates a directory
file: creates a file
dev: creates a device
Permissions:
chmod the created file
User/Group:
chown the created file/dir to this user/group
Dev Type:
char: character [needs MAJOR#, MINOR#]
block: block [needs MAJOR#, MINOR#]
pipe: pipe
Major#:
Used by character and block devices.
Minor#:
Used by character and block devices.

View File

@ -1,149 +0,0 @@
#!/bin/sh
########################################################################
# Begin checkfs
#
# Description : File System Check
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# A. Luebke - luebke@users.sourceforge.net
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
# Based on checkfs script from LFS-3.1 and earlier.
#
# From man fsck
# 0 - No errors
# 1 - File system errors corrected
# 2 - System should be rebooted
# 4 - File system errors left uncorrected
# 8 - Operational error
# 16 - Usage or syntax error
# 32 - Fsck canceled by user request
# 128 - Shared library error
#
#########################################################################
### BEGIN INIT INFO
# Provides: checkfs
# Required-Start: udev swap $time
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Checks local filesystems before mounting.
# Description: Checks local filesystmes before mounting.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
start)
if [ -f /fastboot ]; then
msg="/fastboot found, will omit "
msg="${msg} file system checks as requested.\n"
log_info_msg "${msg}"
exit 0
fi
log_info_msg "Mounting root file system in read-only mode... "
mount -n -o remount,ro / >/dev/null
if [ ${?} != 0 ]; then
log_failure_msg2
msg="\n\nCannot check root "
msg="${msg}filesystem because it could not be mounted "
msg="${msg}in read-only mode.\n\n"
msg="${msg}After you press Enter, this system will be "
msg="${msg}halted and powered off.\n\n"
log_failure_msg "${msg}"
log_info_msg "Press Enter to continue..."
wait_for_user
/etc/rc.d/init.d/halt stop
else
log_success_msg2
fi
if [ -f /forcefsck ]; then
msg="\n/forcefsck found, forcing file"
msg="${msg} system checks as requested."
log_success_msg "$msg"
options="-f"
else
options=""
fi
log_info_msg "Checking file systems..."
# Note: -a option used to be -p; but this fails e.g. on fsck.minix
if is_true "$VERBOSE_FSCK"; then
fsck ${options} -a -A -C -T
else
fsck ${options} -a -A -C -T >/dev/null
fi
error_value=${?}
if [ "${error_value}" = 0 ]; then
log_success_msg2
fi
if [ "${error_value}" = 1 ]; then
msg="\nWARNING:\n\nFile system errors "
msg="${msg}were found and have been corrected.\n"
msg="${msg}You may want to double-check that "
msg="${msg}everything was fixed properly."
log_warning_msg "$msg"
fi
if [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then
msg="\nWARNING:\n\nFile system errors "
msg="${msg}were found and have been been "
msg="${msg}corrected, but the nature of the "
msg="${msg}errors require this system to be rebooted.\n\n"
msg="${msg}After you press enter, "
msg="${msg}this system will be rebooted\n\n"
log_failure_msg "$msg"
log_info_msg "Press Enter to continue..."
wait_for_user
reboot -f
fi
if [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then
msg="\nFAILURE:\n\nFile system errors "
msg="${msg}were encountered that could not be "
msg="${msg}fixed automatically. This system "
msg="${msg}cannot continue to boot and will "
msg="${msg}therefore be halted until those "
msg="${msg}errors are fixed manually by a "
msg="${msg}System Administrator.\n\n"
msg="${msg}After you press Enter, this system will be "
msg="${msg}halted and powered off.\n\n"
log_failure_msg "$msg"
log_info_msg "Press Enter to continue..."
wait_for_user
/etc/rc.d/init.d/halt stop
fi
if [ "${error_value}" -ge 16 ]; then
msg="\nFAILURE:\n\nUnexpected Failure "
msg="${msg}running fsck. Exited with error "
msg="${msg} code: ${error_value}."
log_failure_msg $msg
exit ${error_value}
fi
exit 0
;;
*)
echo "Usage: ${0} {start}"
exit 1
;;
esac
# End checkfs

View File

@ -1,122 +0,0 @@
#!/bin/sh
########################################################################
# Begin cleanfs
#
# Description : Clean file system
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: cleanfs
# Required-Start: $local_fs
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Cleans temporary directories early in the boot process.
# Description: Cleans temporary directories /var/run, /var/lock, and
# optionally, /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()
{
# Input to file descriptor 9 and output to stdin (redirection)
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
;;
*)
log_warning_msg "\nUnknown device type: ${dtype}"
;;
esac
;;
*)
log_warning_msg "\nUnknown type: ${type}"
continue
;;
esac
# Set up the permissions, too.
chown ${usr}:${grp} "${name}"
chmod ${perm} "${name}"
fi
done
# Close file descriptor 9 (end redirection)
exec 0>&9 9>&-
return 0
}
case "${1}" in
start)
log_info_msg "Cleaning file systems:"
if [ "${SKIPTMPCLEAN}" = "" ]; then
log_info_msg2 " /tmp"
cd /tmp &&
find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1
fi
> /var/run/utmp
if grep -q '^utmp:' /etc/group ; then
chmod 664 /var/run/utmp
chgrp utmp /var/run/utmp
fi
(exit ${failed})
evaluate_retval
if egrep -qv '^(#|$)' /etc/sysconfig/createfiles 2>/dev/null; then
log_info_msg "Creating files and directories... "
create_files # Always returns 0
evaluate_retval
fi
exit $failed
;;
*)
echo "Usage: ${0} {start}"
exit 1
;;
esac
# End cleanfs

View File

@ -1,112 +0,0 @@
#!/bin/sh
########################################################################
# Begin console
#
# Description : Sets keymap and screen font
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# Alexander E. Patrakov
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: console
# Required-Start:
# Should-Start: $local_fs
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Sets up a localised console.
# Description: Sets up fonts and language settings for the user's
# local as defined by /etc/sysconfig/console.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
# Native English speakers probably don't have /etc/sysconfig/console at all
[ -r /etc/sysconfig/console ] && . /etc/sysconfig/console
is_true()
{
[ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ]
}
failed=0
case "${1}" in
start)
# See if we need to do anything
if [ -z "${KEYMAP}" ] && [ -z "${KEYMAP_CORRECTIONS}" ] &&
[ -z "${FONT}" ] && [ -z "${LEGACY_CHARSET}" ] &&
! is_true "${UNICODE}"; then
exit 0
fi
# There should be no bogus failures below this line!
log_info_msg "Setting up Linux console..."
# Figure out if a framebuffer console is used
[ -d /sys/class/graphics/fb0 ] && use_fb=1 || use_fb=0
# Figure out the command to set the console into the
# desired mode
is_true "${UNICODE}" &&
MODE_COMMAND="echo -en '\033%G' && kbd_mode -u" ||
MODE_COMMAND="echo -en '\033%@\033(K' && kbd_mode -a"
# On framebuffer consoles, font has to be set for each vt in
# UTF-8 mode. This doesn't hurt in non-UTF-8 mode also.
! is_true "${use_fb}" || [ -z "${FONT}" ] ||
MODE_COMMAND="${MODE_COMMAND} && setfont ${FONT}"
# Apply that command to all consoles mentioned in
# /etc/inittab. Important: in the UTF-8 mode this should
# happen before setfont, otherwise a kernel bug will
# show up and the unicode map of the font will not be
# used.
for TTY in `grep '^[^#].*respawn:/sbin/agetty' /etc/inittab |
grep -o '\btty[[:digit:]]*\b'`
do
openvt -f -w -c ${TTY#tty} -- \
/bin/sh -c "${MODE_COMMAND}" || failed=1
done
# Set the font (if not already set above) and the keymap
[ "${use_fb}" == "1" ] || [ -z "${FONT}" ] || setfont $FONT || failed=1
[ -z "${KEYMAP}" ] ||
loadkeys ${KEYMAP} >/dev/null 2>&1 ||
failed=1
[ -z "${KEYMAP_CORRECTIONS}" ] ||
loadkeys ${KEYMAP_CORRECTIONS} >/dev/null 2>&1 ||
failed=1
# Convert the keymap from $LEGACY_CHARSET to UTF-8
[ -z "$LEGACY_CHARSET" ] ||
dumpkeys -c "$LEGACY_CHARSET" | loadkeys -u >/dev/null 2>&1 ||
failed=1
# If any of the commands above failed, the trap at the
# top would set $failed to 1
( exit $failed )
evaluate_retval
exit $failed
;;
*)
echo "Usage: ${0} {start}"
exit 1
;;
esac
# End console

View File

@ -1,793 +0,0 @@
#!/bin/sh
########################################################################
# Begin boot functions
#
# Description : Run Level Control Functions
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
# Notes : With code based on Matthias Benkmann's simpleinit-msb
# http://winterdrache.de/linux/newboot/index.html
#
# This file is only present for backward BLFS compatibility
#
########################################################################
## Environmental setup
# Setup default values for environment
umask 022
export PATH="/bin:/usr/bin:/sbin:/usr/sbin"
# Signal sent to running processes to refresh their configuration
RELOADSIG="HUP"
# Number of seconds between STOPSIG and FALLBACK when stopping processes
KILLDELAY="3"
## Screen Dimensions
# Find current screen size
if [ -z "${COLUMNS}" ]; then
COLUMNS=$(stty size)
COLUMNS=${COLUMNS##* }
fi
# When using remote connections, such as a serial port, stty size returns 0
if [ "${COLUMNS}" = "0" ]; then
COLUMNS=80
fi
## Measurements for positioning result messages
COL=$((${COLUMNS} - 8))
WCOL=$((${COL} - 2))
## Provide an echo that supports -e and -n
# If formatting is needed, $ECHO should be used
case "`echo -e -n test`" in
-[en]*)
ECHO=/bin/echo
;;
*)
ECHO=echo
;;
esac
## Set Cursor Position Commands, used via $ECHO
SET_COL="\\033[${COL}G" # at the $COL char
SET_WCOL="\\033[${WCOL}G" # at the $WCOL char
CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char
## Set color commands, used via $ECHO
# Please consult `man console_codes for more information
# under the "ECMA-48 Set Graphics Rendition" section
#
# Warning: when switching from a 8bit to a 9bit font,
# the linux console will reinterpret the bold (1;) to
# the top 256 glyphs of the 9bit font. This does
# not affect framebuffer consoles
NORMAL="\\033[0;39m" # Standard console grey
SUCCESS="\\033[1;32m" # Success is green
WARNING="\\033[1;33m" # Warnings are yellow
FAILURE="\\033[1;31m" # Failures are red
INFO="\\033[1;36m" # Information is light cyan
BRACKET="\\033[1;34m" # Brackets are blue
STRING_LENGTH="0" # the length of the current message
#*******************************************************************************
# Function - boot_mesg()
#
# Purpose: Sending information from bootup scripts to the console
#
# Inputs: $1 is the message
# $2 is the colorcode for the console
#
# Outputs: Standard Output
#
# Dependencies: - sed for parsing strings.
# - grep for counting string length.
#
# Todo:
#*******************************************************************************
boot_mesg()
{
local ECHOPARM=""
while true
do
case "${1}" in
-n)
ECHOPARM=" -n "
shift 1
;;
-*)
echo "Unknown Option: ${1}"
return 1
;;
*)
break
;;
esac
done
## Figure out the length of what is to be printed to be used
## for warning messages.
STRING_LENGTH=$((${#1} + 1))
# Print the message to the screen
${ECHO} ${ECHOPARM} -e "${2}${1}"
# Log the message
[ -d /run/var ] || return
${ECHO} ${ECHOPARM} -e "${2}${1}" >> /run/var/bootlog
}
boot_mesg_flush()
{
# Reset STRING_LENGTH for next message
STRING_LENGTH="0"
}
echo_ok()
{
${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${SUCCESS} OK ${BRACKET}]"
${ECHO} -e "${NORMAL}"
boot_mesg_flush
[ -d /run/var ] || return
${ECHO} -e "[ OK ]" >> /run/var/bootlog
}
echo_failure()
{
${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${FAILURE} FAIL ${BRACKET}]"
${ECHO} -e "${NORMAL}"
boot_mesg_flush
[ -d /run/var ] || return
${ECHO} -e "[ FAIL]" >> /run/var/bootlog
}
echo_warning()
{
${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} WARN ${BRACKET}]"
${ECHO} -e "${NORMAL}"
boot_mesg_flush
[ -d /run/var ] || return
${ECHO} -e "[ WARN ]" >> /run/var/bootlog
}
echo_skipped()
{
${ECHO} -n -e "${CURS_UP}${SET_COL}${BRACKET}[${WARNING} SKIP ${BRACKET}]"
${ECHO} -e "${NORMAL}"
boot_mesg_flush
[ -d /run/var ] || return
${ECHO} -e " [ SKIP ]" >> /run/var/bootlog
}
wait_for_user()
{
# Wait for the user by default
[ "${HEADLESS=0}" = "0" ] && read ENTER
}
evaluate_retval()
{
error_value="${?}"
if [ ${error_value} = 0 ]; then
echo_ok
else
echo_failure
fi
# This prevents the 'An Unexpected Error Has Occurred' from trivial
# errors.
return 0
}
print_status()
{
if [ "${#}" = "0" ]; then
echo "Usage: ${0} {success|warning|failure}"
return 1
fi
case "${1}" in
success)
echo_ok
;;
warning)
# Leave this extra case in because old scripts
# may call it this way.
case "${2}" in
running)
${ECHO} -e -n "${CURS_UP}"
${ECHO} -e -n "\\033[${STRING_LENGTH}G "
boot_mesg "Already running." ${WARNING}
echo_warning
;;
not_running)
${ECHO} -e -n "${CURS_UP}"
${ECHO} -e -n "\\033[${STRING_LENGTH}G "
boot_mesg "Not running." ${WARNING}
echo_warning
;;
not_available)
${ECHO} -e -n "${CURS_UP}"
${ECHO} -e -n "\\033[${STRING_LENGTH}G "
boot_mesg "Not available." ${WARNING}
echo_warning
;;
*)
# This is how it is supposed to
# be called
echo_warning
;;
esac
;;
failure)
echo_failure
;;
esac
}
reloadproc()
{
local pidfile=""
local failure=0
while true
do
case "${1}" in
-p)
pidfile="${2}"
shift 2
;;
-*)
log_failure_msg "Unknown Option: ${1}"
return 2
;;
*)
break
;;
esac
done
if [ "${#}" -lt "1" ]; then
log_failure_msg "Usage: reloadproc [-p pidfile] pathname"
return 2
fi
# This will ensure compatibility with previous LFS Bootscripts
if [ -n "${PIDFILE}" ]; then
pidfile="${PIDFILE}"
fi
# Is the process running?
if [ -z "${pidfile}" ]; then
pidofproc -s "${1}"
else
pidofproc -s -p "${pidfile}" "${1}"
fi
# Warn about stale pid file
if [ "$?" = 1 ]; then
boot_mesg -n "Removing stale pid file: ${pidfile}. " ${WARNING}
rm -f "${pidfile}"
fi
if [ -n "${pidlist}" ]; then
for pid in ${pidlist}
do
kill -"${RELOADSIG}" "${pid}" || failure="1"
done
(exit ${failure})
evaluate_retval
else
boot_mesg "Process ${1} not running." ${WARNING}
echo_warning
fi
}
statusproc()
{
local pidfile=""
local base=""
local ret=""
while true
do
case "${1}" in
-p)
pidfile="${2}"
shift 2
;;
-*)
log_failure_msg "Unknown Option: ${1}"
return 2
;;
*)
break
;;
esac
done
if [ "${#}" != "1" ]; then
shift 1
log_failure_msg "Usage: statusproc [-p pidfile] pathname"
return 2
fi
# Get the process basename
base="${1##*/}"
# This will ensure compatibility with previous LFS Bootscripts
if [ -n "${PIDFILE}" ]; then
pidfile="${PIDFILE}"
fi
# Is the process running?
if [ -z "${pidfile}" ]; then
pidofproc -s "${1}"
else
pidofproc -s -p "${pidfile}" "${1}"
fi
# Store the return status
ret=$?
if [ -n "${pidlist}" ]; then
${ECHO} -e "${INFO}${base} is running with Process"\
"ID(s) ${pidlist}.${NORMAL}"
else
if [ -n "${base}" -a -e "/var/run/${base}.pid" ]; then
${ECHO} -e "${WARNING}${1} is not running but"\
"/var/run/${base}.pid exists.${NORMAL}"
else
if [ -n "${pidfile}" -a -e "${pidfile}" ]; then
${ECHO} -e "${WARNING}${1} is not running"\
"but ${pidfile} exists.${NORMAL}"
else
${ECHO} -e "${INFO}${1} is not running.${NORMAL}"
fi
fi
fi
# Return the status from pidofproc
return $ret
}
# The below functions are documented in the LSB-generic 2.1.0
#*******************************************************************************
# Function - pidofproc [-s] [-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
#
# Outputs: return 0 - Success, pid's in stdout
# return 1 - Program is dead, pidfile exists
# return 2 - Invalid or excessive number of arguments,
# warning in stdout
# return 3 - Program is not running
#
# Dependencies: pidof, echo, head
#
# Todo: Remove dependency on head
# This replaces getpids
# Test changes to pidof
#
#*******************************************************************************
pidofproc()
{
local pidfile=""
local lpids=""
local silent=""
pidlist=""
while true
do
case "${1}" in
-p)
pidfile="${2}"
shift 2
;;
-s)
# Added for legacy opperation of getpids
# eliminates several '> /dev/null'
silent="1"
shift 1
;;
-*)
log_failure_msg "Unknown Option: ${1}"
return 2
;;
*)
break
;;
esac
done
if [ "${#}" != "1" ]; then
shift 1
log_failure_msg "Usage: pidofproc [-s] [-p pidfile] pathname"
return 2
fi
if [ -n "${pidfile}" ]; then
if [ ! -r "${pidfile}" ]; then
return 3 # Program is not running
fi
lpids=`head -n 1 ${pidfile}`
for pid in ${lpids}
do
if [ "${pid}" -ne "$$" -a "${pid}" -ne "${PPID}" ]; then
kill -0 "${pid}" 2>/dev/null &&
pidlist="${pidlist} ${pid}"
fi
if [ "${silent}" != "1" ]; then
echo "${pidlist}"
fi
test -z "${pidlist}" &&
# Program is dead, pidfile exists
return 1
# else
return 0
done
else
pidlist=`pidof -o $$ -o $PPID -x "$1"`
if [ "${silent}" != "1" ]; then
echo "${pidlist}"
fi
# Get provide correct running status
if [ -n "${pidlist}" ]; then
return 0
else
return 3
fi
fi
if [ "$?" != "0" ]; then
return 3 # Program is not running
fi
}
#*******************************************************************************
# Function - loadproc [-f] [-n nicelevel] [-p pidfile] pathname [args]
#
# Purpose: This runs the specified program as a daemon
#
# Inputs: -f, run the program even if it is already running
# -n nicelevel, specifies a nice level. See nice(1).
# -p pidfile, uses the specified pidfile
# pathname, pathname to the specified program
# args, arguments to pass to specified program
#
# Outputs: return 0 - Success
# return 2 - Invalid of excessive number of arguments,
# warning in stdout
# return 4 - Program or service status is unknown
#
# Dependencies: nice, rm
#
# Todo: LSB says this should be called start_daemon
# LSB does not say that it should call evaluate_retval
# It checks for PIDFILE, which is deprecated.
# Will be removed after BLFS 6.0
# loadproc returns 0 if program is already running, not LSB compliant
#
#*******************************************************************************
loadproc()
{
local pidfile=""
local forcestart=""
local nicelevel="10"
# This will ensure compatibility with previous LFS Bootscripts
if [ -n "${PIDFILE}" ]; then
pidfile="${PIDFILE}"
fi
while true
do
case "${1}" in
-f)
forcestart="1"
shift 1
;;
-n)
nicelevel="${2}"
shift 2
;;
-p)
pidfile="${2}"
shift 2
;;
-*)
log_failure_msg "Unknown Option: ${1}"
return 2 #invalid or excess argument(s)
;;
*)
break
;;
esac
done
if [ "${#}" = "0" ]; then
log_failure_msg "Usage: loadproc [-f] [-n nicelevel] [-p pidfile] pathname [args]"
return 2 #invalid or excess argument(s)
fi
if [ -z "${forcestart}" ]; then
if [ -z "${pidfile}" ]; then
pidofproc -s "${1}"
else
pidofproc -s -p "${pidfile}" "${1}"
fi
case "${?}" in
0)
log_warning_msg "Unable to continue: ${1} is running"
return 0 # 4
;;
1)
boot_mesg "Removing stale pid file: ${pidfile}" ${WARNING}
rm -f "${pidfile}"
;;
3)
;;
*)
log_failure_msg "Unknown error code from pidofproc: ${?}"
return 4
;;
esac
fi
nice -n "${nicelevel}" "${@}"
evaluate_retval # This is "Probably" not LSB compliant,
# but required to be compatible with older bootscripts
return 0
}
#*******************************************************************************
# Function - killproc [-p pidfile] pathname [signal]
#
# Purpose:
#
# Inputs: -p pidfile, uses the specified pidfile
# pathname, pathname to the specified program
# signal, send this signal to pathname
#
# Outputs: return 0 - Success
# return 2 - Invalid of excessive number of arguments,
# warning in stdout
# return 4 - Unknown Status
#
# Dependencies: kill, rm
#
# Todo: LSB does not say that it should call evaluate_retval
# It checks for PIDFILE, which is deprecated.
# Will be removed after BLFS 6.0
#
#*******************************************************************************
killproc()
{
local pidfile=""
local killsig=TERM # default signal is SIGTERM
pidlist=""
# This will ensure compatibility with previous LFS Bootscripts
if [ -n "${PIDFILE}" ]; then
pidfile="${PIDFILE}"
fi
while true
do
case "${1}" in
-p)
pidfile="${2}"
shift 2
;;
-*)
log_failure_msg "Unknown Option: ${1}"
return 2
;;
*)
break
;;
esac
done
if [ "${#}" = "2" ]; then
killsig="${2}"
elif [ "${#}" != "1" ]; then
shift 2
log_failure_msg "Usage: killproc [-p pidfile] pathname [signal]"
return 2
fi
# Is the process running?
if [ -z "${pidfile}" ]; then
pidofproc -s "${1}"
else
pidofproc -s -p "${pidfile}" "${1}"
fi
# Remove stale pidfile
if [ "$?" = 1 ]; then
boot_mesg "Removing stale pid file: ${pidfile}." ${WARNING}
rm -f "${pidfile}"
fi
# If running, send the signal
if [ -n "${pidlist}" ]; then
for pid in ${pidlist}
do
kill -${killsig} ${pid} 2>/dev/null
# Wait up to 3 seconds, for ${pid} to terminate
case "${killsig}" in
TERM|SIGTERM|KILL|SIGKILL)
# sleep in 1/10ths of seconds and
# multiply KILLDELAY by 10
local dtime="${KILLDELAY}0"
while [ "${dtime}" != "0" ]
do
kill -0 ${pid} 2>/dev/null || break
sleep 0.1
dtime=$(( ${dtime} - 1))
done
# If ${pid} is still running, kill it
kill -0 ${pid} 2>/dev/null && kill -KILL ${pid} 2>/dev/null
;;
esac
done
# Check if the process is still running if we tried to stop it
case "${killsig}" in
TERM|SIGTERM|KILL|SIGKILL)
if [ -z "${pidfile}" ]; then
pidofproc -s "${1}"
else
pidofproc -s -p "${pidfile}" "${1}"
fi
# Program was terminated
if [ "$?" != "0" ]; then
# Remove the pidfile if necessary
if [ -f "${pidfile}" ]; then
rm -f "${pidfile}"
fi
echo_ok
return 0
else # Program is still running
echo_failure
return 4 # Unknown Status
fi
;;
*)
# Just see if the kill returned successfully
evaluate_retval
;;
esac
else # process not running
print_status warning not_running
fi
}
#*******************************************************************************
# Function - log_success_msg "message"
#
# Purpose: Print a success message
#
# Inputs: $@ - Message
#
# Outputs: Text output to screen
#
# Dependencies: echo
#
# Todo: logging
#
#*******************************************************************************
log_success_msg()
{
${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
${ECHO} -e "${SET_COL}""${BRACKET}""[""${SUCCESS}"" OK ""${BRACKET}""]""${NORMAL}"
[ -d /run/var ] || return 0
${ECHO} -n -e "${@} [ OK ]" >> /run/var/bootlog
return 0
}
#*******************************************************************************
# Function - log_failure_msg "message"
#
# Purpose: Print a failure message
#
# Inputs: $@ - Message
#
# Outputs: Text output to screen
#
# Dependencies: echo
#
# Todo: logging
#
#*******************************************************************************
log_failure_msg() {
${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
${ECHO} -e "${SET_COL}""${BRACKET}""[""${FAILURE}"" FAIL ""${BRACKET}""]""${NORMAL}"
[ -d /run/var ] || return 0
${ECHO} -e "${@} [ FAIL ]" >> /run/var/bootlog
return 0
}
#*******************************************************************************
# Function - log_warning_msg "message"
#
# Purpose: print a warning message
#
# Inputs: $@ - Message
#
# Outputs: Text output to screen
#
# Dependencies: echo
#
# Todo: logging
#
#*******************************************************************************
log_warning_msg() {
${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" WARN ""${BRACKET}""]""${NORMAL}"
[ -d /run/var ] || return 0
${ECHO} -e "${@} [ WARN ]" >> /run/var/bootlog
return 0
}
#*******************************************************************************
# Function - log_skipped_msg "message"
#
# Purpose: print a message that the script was skipped
#
# Inputs: $@ - Message
#
# Outputs: Text output to screen
#
# Dependencies: echo
#
# Todo: logging
#
#*******************************************************************************
log_skipped_msg() {
${ECHO} -n -e "${BOOTMESG_PREFIX}${@}"
${ECHO} -e "${SET_COL}""${BRACKET}""[""${WARNING}"" SKIP ""${BRACKET}""]""${NORMAL}"
[ -d /run/var ] || return 0
${ECHO} -e "${@} [ SKIP ]" >> /run/var/bootlog
return 0
}
# End boot functions

View File

@ -1,39 +0,0 @@
#!/bin/sh
########################################################################
# Begin halt
#
# Description : Halt Script
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: halt
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 0
# Default-Stop:
# Short-Description: Halts the system.
# Description: Halts the System.
# X-LFS-Provided-By: LFS
### END INIT INFO
case "${1}" in
stop)
halt -d -f -i -p
;;
*)
echo "Usage: {stop}"
exit 1
;;
esac
# End halt

View File

@ -1,69 +0,0 @@
#!/bin/sh
########################################################################
# Begin localnet
#
# Description : Loopback device
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: localnet
# Required-Start: $local_fs
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Starts the local network.
# Description: Sets the hostname of the machine and starts the
# loopback interface.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
[ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
case "${1}" in
start)
log_info_msg "Bringing up the loopback interface..."
ip addr add 127.0.0.1/8 label lo dev lo
ip link set lo up
evaluate_retval
log_info_msg "Setting hostname to ${HOSTNAME}..."
hostname ${HOSTNAME}
evaluate_retval
;;
stop)
log_info_msg "Bringing down the loopback interface..."
ip link set lo down
evaluate_retval
;;
restart)
${0} stop
sleep 1
${0} start
;;
status)
echo "Hostname is: $(hostname)"
ip link show lo
;;
*)
echo "Usage: ${0} {start|stop|restart|status}"
exit 1
;;
esac
exit 0
# End localnet

View File

@ -1,82 +0,0 @@
#!/bin/sh
########################################################################
# Begin modules
#
# Description : Module auto-loading script
#
# Authors : Zack Winkles
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: modules
# Required-Start: mountvirtfs sysctl
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Loads required modules.
# Description: Loads modules listed in /etc/sysconfig/modules.
# X-LFS-Provided-By: LFS
### END INIT INFO
# Assure that the kernel has module support.
[ -e /proc/ksyms -o -e /proc/modules ] || exit 0
. /lib/lsb/init-functions
case "${1}" in
start)
# Exit if there's no modules file or there are no
# valid entries
[ -r /etc/sysconfig/modules ] || exit 0
egrep -qv '^($|#)' /etc/sysconfig/modules || exit 0
log_info_msg "Loading modules:"
# Only try to load modules if the user has actually given us
# some modules to load.
while read module args; do
# Ignore comments and blank lines.
case "$module" in
""|"#"*) continue ;;
esac
# Attempt to load the module, passing any arguments provided.
modprobe ${module} ${args} >/dev/null
# Print the module name if successful, otherwise take note.
if [ $? -eq 0 ]; then
log_info_msg2 " ${module}"
else
failedmod="${failedmod} ${module}"
fi
done < /etc/sysconfig/modules
# Print a message about successfully loaded modules on the correct line.
log_success_msg2
# Print a failure message with a list of any modules that
# may have failed to load.
if [ -n "${failedmod}" ]; then
log_failure_msg "Failed to load modules:${failedmod}"
exit 1
fi
;;
*)
echo "Usage: ${0} {start}"
exit 1
;;
esac
exit 0
# End modules

View File

@ -1,79 +0,0 @@
#!/bin/sh
########################################################################
# Begin mountfs
#
# Description : File System Mount Script
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: $local_fs
# Required-Start: udev checkfs
# Should-Start:
# Required-Stop: swap
# Should-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Mounts/unmounts local filesystems defined in /etc/fstab.
# Description: Remounts root filesystem read/write and mounts all
# remaining local filesystems defined in /etc/fstab on
# start. Remounts root filesystem read-only and unmounts
# remaining filesystems on stop.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
start)
log_info_msg "Remounting root file system in read-write mode..."
mount -n -o remount,rw / >/dev/null
evaluate_retval
# Remove fsck-related file system watermarks.
rm -f /fastboot /forcefsck
log_info_msg "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
mount -f /dev || failed=1
(exit ${failed})
evaluate_retval
# This will mount all filesystems that do not have _netdev in
# their option list. _netdev denotes a network filesystem.
log_info_msg "Mounting remaining file systems..."
mount -a -O no_netdev >/dev/null
evaluate_retval
exit $failed
;;
stop)
# Don't unmount tmpfs like /run
log_info_msg "Unmounting all other currently mounted file systems..."
umount -a -d -r -t notmpfs,nosysfs,nodevtmpfs,noproc >/dev/null
evaluate_retval
# Make all LVM volume groups unavailable, if appropriate
# This fails if swap or / are on an LVM partition
#if [ -x /sbin/vgchange ]; then /sbin/vgchange -an > /dev/null; fi
;;
*)
echo "Usage: ${0} {start|stop}"
exit 1
;;
esac
# End mountfs

View File

@ -1,75 +0,0 @@
#!/bin/sh
########################################################################
# Begin mountvirtfs
#
# Description : Mount proc, sysfs, and run
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: mountvirtfs
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Mounts /sys and /proc virtual (kernel) filesystems.
# Mounts /run (tmpfs) and /dev (devtmpfs).
# Description: Mounts /sys and /proc virtual (kernel) filesystems.
# Mounts /run (tmpfs) and /dev (devtmpfs).
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
start)
# Make sure /run/var is available before logging any messages
if ! mountpoint /run >/dev/null; then
mount -n /run || failed=1
fi
mkdir -p /run/var /run/lock /run/shm
chmod 1777 /run/shm
log_info_msg "Mounting virtual file systems: ${INFO}/run"
if ! mountpoint /proc >/dev/null; then
log_info_msg2 " ${INFO}/proc"
mount -n -o nosuid,noexec,nodev /proc || failed=1
fi
if ! mountpoint /sys >/dev/null; then
log_info_msg2 " ${INFO}/sys"
mount -n -o nosuid,noexec,nodev /sys || failed=1
fi
if ! mountpoint /dev >/dev/null; then
log_info_msg2 " ${INFO}/dev"
mount -n -o mode=0755,nosuid /dev || failed=1
fi
# Copy devices that Udev >= 155 doesn't handle to /dev
cp -a /lib/udev/devices/* /dev
ln -sfn /run/shm /dev/shm
(exit ${failed})
evaluate_retval
exit $failed
;;
*)
echo "Usage: ${0} {start}"
exit 1
;;
esac
# End mountvirtfs

View File

@ -1,84 +0,0 @@
#!/bin/sh
########################################################################
# Begin network
#
# Description : Network Control Script
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# Nathan Coulson - nathan@linuxfromscratch.org
# Kevin P. Fleming - kpfleming@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: $network
# Required-Start: $local_fs swap localnet
# Should-Start: $syslog
# Required-Stop: $local_fs swap localnet
# Should-Stop: $syslog
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Short-Description: Starts and configures network interfaces.
# Description: Starts and configures network interfaces.
# X-LFS-Provided-By: LFS
### END INIT INFO
case "${1}" in
start)
# Start all network interfaces
for file in /etc/sysconfig/ifconfig.*
do
interface=${file##*/ifconfig.}
# Skip if $file is * (because nothing was found)
if [ "${interface}" = "*" ]
then
continue
fi
/sbin/ifup ${interface}
done
;;
stop)
# Reverse list
net_files=""
for file in /etc/sysconfig/ifconfig.*
do
net_files="${file} ${net_files}"
done
# Stop all network interfaces
for file in ${net_files}
do
interface=${file##*/ifconfig.}
# Skip if $file is * (because nothing was found)
if [ "${interface}" = "*" ]
then
continue
fi
/sbin/ifdown ${interface}
done
;;
restart)
${0} stop
sleep 1
${0} start
;;
*)
echo "Usage: ${0} {start|stop|restart}"
exit 1
;;
esac
exit 0
# End network

View File

@ -1,229 +0,0 @@
#!/bin/bash
########################################################################
# Begin rc
#
# Description : Main Run Level Control Script
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# : DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
. /lib/lsb/init-functions
print_error_msg()
{
log_failure_msg
# $i is set when called
MSG="FAILURE:\n\nYou should not be reading this error message.\n\n"
MSG="${MSG}It means that an unforeseen error took place in\n"
MSG="${MSG}${i},\n"
MSG="${MSG}which exited with a return value of ${error_value}.\n"
MSG="${MSG}If you're able to track this error down to a bug in one of\n"
MSG="${MSG}the files provided by the files provided by\n"
MSG="${MSG}the ${DISTRO_MINI} book, please be so kind to inform us at\n"
MSG="${MSG}${DISTRO_CONTACT}.\n"
log_failure_msg "${MSG}"
log_info_msg "Press Enter to continue..."
wait_for_user
}
check_script_status()
{
# $i is set when called
if [ ! -f ${i} ]; then
log_warning_msg "${i} is not a valid symlink."
continue
fi
if [ ! -x ${i} ]; then
log_warning_msg "${i} is not executable, skipping."
continue
fi
}
run()
{
if [ -z $interactive ]; then
${1} ${2}
return $?
fi
while true; do
read -p "Run ${1} ${2} (Yes/no/continue)? " -n 1 runit
echo
case ${runit} in
c | C)
interactive=""
${i} ${2}
ret=${?}
break;
;;
n | N)
return 0
;;
y | Y)
${i} ${2}
ret=${?}
break
;;
esac
done
return $ret
}
# Read any local settings/overrides
[ -r /etc/sysconfig/rc.site ] && source /etc/sysconfig/rc.site
DISTRO=${DISTRO:-"Linux From Scratch"}
DISTRO_CONTACT=${DISTRO_CONTACT:-"lfs-dev@linuxfromscratch.org (Registration required)"}
DISTRO_MINI=${DISTRO_MINI:-"LFS"}
IPROMPT=${IPROMPT:-"no"}
# These 3 signals will not cause our script to exit
trap "" INT QUIT TSTP
[ "${1}" != "" ] && runlevel=${1}
if [ "${runlevel}" == "" ]; then
echo "Usage: ${0} <runlevel>" >&2
exit 1
fi
previous=${PREVLEVEL}
[ "${previous}" == "" ] && previous=N
if [ ! -d /etc/rc.d/rc${runlevel}.d ]; then
log_info_msg "/etc/rc.d/rc${runlevel}.d does not exist.\n"
exit 1
fi
if [ "$runlevel" == "6" -o "$runlevel" == "0" ]; then IPROMPT="no"; fi
# Note: In ${LOGLEVEL:-7}, it is ':' 'dash' '7', not minus 7
if [ "$runlevel" == "S" ]; then
[ -r /etc/sysconfig/console ] && source /etc/sysconfig/console
dmesg -n "${LOGLEVEL:-7}"
fi
if [ "${IPROMPT}" == "yes" -a "${runlevel}" == "S" ]; then
# The total length of the distro welcome string, without escape codes
wlen=${wlen:-$(echo "Welcome to ${DISTRO}" | wc -c )}
welcome_message=${welcome_message:-"Welcome to ${INFO}${DISTRO}${NORMAL}"}
# The total length of the interactive string, without escape codes
ilen=${ilen:-$(echo "Press 'I' to enter interactive startup" | wc -c )}
i_message=${i_message:-"Press '${FAILURE}I${NORMAL}' to enter interactive startup"}
# dcol and icol are spaces before the message to center the message
# on screen. itime is the amount of wait time for the user to press a key
wcol=$(( ( ${COLUMNS} - ${wlen} ) / 2 ))
icol=$(( ( ${COLUMNS} - ${ilen} ) / 2 ))
itime=${itime:-"3"}
echo -e "\n\n"
echo -e "\\033[${wcol}G${welcome_message}"
echo -e "\\033[${icol}G${i_message}${NORMAL}"
echo ""
read -t "${itime}" -n 1 interactive 2>&1 > /dev/null
fi
# Make lower case
[ "${interactive}" == "I" ] && interactive="i"
[ "${interactive}" != "i" ] && interactive=""
# Read the state file if it exists from runlevel S
[ -r /var/run/interactive ] && source /var/run/interactive
# Attempt to stop all services started by the previous runlevel,
# and killed in this runlevel
if [ "${previous}" != "N" ]; then
for i in $(ls -v /etc/rc.d/rc${runlevel}.d/K* 2> /dev/null)
do
check_script_status
suffix=${i#/etc/rc.d/rc$runlevel.d/K[0-9][0-9]}
prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
sysinit_start=/etc/rc.d/rcS.d/S[0-9][0-9]$suffix
if [ "${runlevel}" != "0" -a "${runlevel}" != "6" ]; then
if [ ! -f ${prev_start} -a ! -f ${sysinit_start} ]; then
MSG="WARNING:\n\n${i} can't be "
MSG="${MSG}executed because it was not "
MSG="${MSG}not started in the previous "
MSG="${MSG}runlevel (${previous})."
log_warning_msg "$MSG"
continue
fi
fi
run ${i} stop
error_value=${?}
if [ "${error_value}" != "0" ]; then print_error_msg; fi
done
fi
if [ "${previous}" == "N" ]; then export IN_BOOT=1; fi
if [ "$runlevel" == "6" -a -n "${FASTBOOT}" ]; then
touch /fastboot
fi
# Start all functions in this runlevel
for i in $( ls -v /etc/rc.d/rc${runlevel}.d/S* 2> /dev/null)
do
if [ "${previous}" != "N" ]; then
suffix=${i#/etc/rc.d/rc$runlevel.d/S[0-9][0-9]}
stop=/etc/rc.d/rc$runlevel.d/K[0-9][0-9]$suffix
prev_start=/etc/rc.d/rc$previous.d/S[0-9][0-9]$suffix
[ -f ${prev_start} -a ! -f ${stop} ] && continue
fi
check_script_status
case ${runlevel} in
0|6)
run ${i} stop
;;
*)
run ${i} start
;;
esac
error_value=${?}
if [ "${error_value}" != "0" ]; then print_error_msg; fi
done
# Store interactive variable on switch from runlevel S and remove if not
if [ "${runlevel}" == "S" -a "${interactive}" == "i" ]; then
echo "interactive=\"i\"" > /var/run/interactive
else
rm -f /var/run/interactive 2> /dev/null
fi
# Copy the boot log on initial boot only
if [ "${previous}" == "N" -a "${runlevel}" != "S" ]; then
cat /run/var/bootlog >> /var/log/boot.log
# Mark the end of boot
echo "--------" >> /var/log/boot.log
# Remove the temporary file
rm -f /run/var/bootlog 2> /dev/null
fi
# End rc

View File

@ -1,43 +0,0 @@
#!/bin/sh
########################################################################
# Begin reboot
#
# Description : Reboot Scripts
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: reboot
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: 6
# Default-Stop:
# Short-Description: Reboots the system.
# Description: Reboots the System.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
stop)
log_info_msg "Restarting system..."
reboot -d -f -i
;;
*)
echo "Usage: ${0} {stop}"
exit 1
;;
esac
# End reboot

View File

@ -1,66 +0,0 @@
#!/bin/sh
########################################################################
# Begin sendsignals
#
# Description : Sendsignals Script
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: sendsignals
# Required-Start:
# Should-Start:
# Required-Stop: $local_fs swap localnet
# Should-Stop:
# Default-Start:
# Default-Stop: 0 6
# Short-Description: Attempts to kill remaining processes.
# Description: Attempts to kill remaining processes.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
stop)
log_info_msg "Sending all processes the TERM signal..."
killall5 -15
error_value=${?}
sleep ${KILLDELAY}
if [ "${error_value}" = 0 -o "${error_value}" = 2 ]; then
log_success_msg
else
log_failure_msg
fi
log_info_msg "Sending all processes the KILL signal..."
killall5 -9
error_value=${?}
sleep ${KILLDELAY}
if [ "${error_value}" = 0 -o "${error_value}" = 2 ]; then
log_success_msg
else
log_failure_msg
fi
;;
*)
echo "Usage: ${0} {stop}"
exit 1
;;
esac
exit 0
# End sendsignals

View File

@ -1,63 +0,0 @@
#!/bin/sh
########################################################################
# Begin setclock
#
# Description : Setting Linux Clock
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides:
# Required-Start:
# Should-Start: modules
# Required-Stop:
# Should-Stop: $syslog
# Default-Start: S
# Default-Stop:
# Short-Description: Stores and restores time from the hardware clock
# Description: On boot, system time is obtained from hwclock. The
# hardware clock can also be set on shutdown.
# X-LFS-Provided-By: LFS BLFS
### END INIT INFO
. /lib/lsb/init-functions
[ -r /etc/sysconfig/clock ] && . /etc/sysconfig/clock
case "${UTC}" in
yes|true|1)
CLOCKPARAMS="${CLOCKPARAMS} --utc"
;;
no|false|0)
CLOCKPARAMS="${CLOCKPARAMS} --localtime"
;;
esac
case ${1} in
start)
hwclock --hctosys ${CLOCKPARAMS} >/dev/null
;;
stop)
log_info_msg "Setting hardware clock..."
hwclock --systohc ${CLOCKPARAMS} >/dev/null
evaluate_retval
;;
*)
echo "Usage: ${0} {start|stop}"
exit 1
;;
esac
exit 0

View File

@ -1,63 +0,0 @@
#!/bin/sh
########################################################################
# Begin swap
#
# Description : Swap Control Script
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: swap
# Required-Start: udev
# Should-Start: modules
# Required-Stop: localnet
# Should-Stop:
# Default-Start: S
# Default-Stop: 0 6
# Short-Description: Mounts and unmounts swap partitions.
# Description: Mounts and unmounts swap partitions defined in
# /etc/fstab.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
start)
log_info_msg "Activating all swap files/partitions..."
swapon -a
evaluate_retval
;;
stop)
log_info_msg "Deactivating all swap files/partitions..."
swapoff -a
evaluate_retval
;;
restart)
${0} stop
sleep 1
${0} start
;;
status)
log_success_msg "Retrieving swap status."
swapon -s
;;
*)
echo "Usage: ${0} {start|stop|restart|status}"
exit 1
;;
esac
exit 0
# End swap

View File

@ -1,54 +0,0 @@
#!/bin/sh
########################################################################
# Begin sysctl
#
# Description : File uses /etc/sysctl.conf to set kernel runtime
# parameters
#
# Authors : Nathan Coulson (nathan@linuxfromscratch.org)
# Matthew Burgress (matthew@linuxfromscratch.org)
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: sysctl
# Required-Start: mountvirtfs
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Makes changes to the proc filesystem
# Description: Makes changes to the proc filesystem as defined in
# /etc/sysctl.conf. See 'man sysctl(8)'.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
start)
if [ -f "/etc/sysctl.conf" ]; then
log_info_msg "Setting kernel runtime parameters..."
sysctl -q -p
evaluate_retval
fi
;;
status)
sysctl -a
;;
*)
echo "Usage: ${0} {start|status}"
exit 1
;;
esac
exit 0
# End sysctl

View File

@ -1,79 +0,0 @@
#!/bin/sh
########################################################################
# Begin sysklogd
#
# Description : Sysklogd loader
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: $syslog
# Required-Start: localnet
# Should-Start:
# Required-Stop: $local_fs sendsignals
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts kernel and system log daemons.
# Description: Starts kernel and system log daemons.
# /etc/fstab.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
start)
log_info_msg "Starting system log daemon..."
parms=${SYSKLOGD_PARMS-'-m 0'}
start_daemon /sbin/syslogd $parms
evaluate_retval
log_info_msg "Starting kernel log daemon..."
start_daemon /sbin/klogd
evaluate_retval
;;
stop)
log_info_msg "Stopping kernel log daemon..."
killproc /sbin/klogd
evaluate_retval
log_info_msg "Stopping system log daemon..."
killproc /sbin/syslogd
evaluate_retval
;;
reload)
log_info_msg "Reloading system log daemon config file..."
pid=`pidofproc syslogd`
kill -HUP "${pid}"
evaluate_retval
;;
restart)
${0} stop
sleep 1
${0} start
;;
status)
statusproc /sbin/syslogd
statusproc klogd
;;
*)
echo "Usage: ${0} {start|stop|reload|restart|status}"
exit 1
;;
esac
exit 0
# End sysklogd

View File

@ -1,55 +0,0 @@
#!/bin/sh
########################################################################
# Begin scriptname
#
# Description :
#
# Authors :
#
# Version : LFS x.x
#
# Notes :
#
########################################################################
### BEGIN INIT INFO
# Provides: template
# Required-Start:
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:
# Default-Stop:
# Short-Description:
# Description:
# X-LFS-Provided-By:
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
start)
log_info_msg "Starting..."
start_daemon fully_qualified_path
;;
stop)
log_info_msg "Stopping..."
killproc fully_qualified_path
;;
restart)
${0} stop
sleep 1
${0} start
;;
*)
echo "Usage: ${0} {start|stop|restart}"
exit 1
;;
esac
exit 0
# End scriptname

View File

@ -1,80 +0,0 @@
#!/bin/sh
########################################################################
# Begin udev
#
# Description : Udev cold-plugging script
#
# Authors : Zack Winkles, Alexander E. Patrakov
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
### BEGIN INIT INFO
# Provides: udev $time
# Required-Start:
# Should-Start: modules
# Required-Stop:
# Should-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Populates /dev with device nodes.
# Description: Mounts a tempfs on /dev and starts the udevd daemon.
# Device nodes are created as defined by udev.
# X-LFS-Provided-By: LFS
### END INIT INFO
. /lib/lsb/init-functions
case "${1}" in
start)
log_info_msg "Populating /dev with device nodes... "
if ! grep -q '[[:space:]]sysfs' /proc/mounts; then
log_failure_msg2
msg="FAILURE:\n\nUnable to create "
msg="${msg}devices without a SysFS filesystem\n\n"
msg="${msg}After you press Enter, this system "
msg="${msg}will be halted and powered off.\n\n"
log_info_msg "$msg"
log_info_msg "Press Enter to continue..."
wait_for_user
/etc/rc.d/init.d/halt stop
fi
# 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
# Start the udev daemon to continually watch for, and act on,
# uevents
/lib/udev/udevd --daemon
# Now traverse /sys in order to "coldplug" devices that have
# already been discovered
/sbin/udevadm trigger --action=add --type=subsystems
/sbin/udevadm trigger --action=add --type=devices
/sbin/udevadm trigger --action=change --type=devices
# Now wait for udevd to process the uevents we triggered
if ! is_true "$OMIT_UDEV_SETTLE"; then
/sbin/udevadm settle
fi
# If any LVM based partitions are on the system, ensure they
# are activated so they can be used.
if [ -x /sbin/vgchange ]; then /sbin/vgchange -a y >/dev/null; fi
log_success_msg2
;;
*)
echo "Usage ${0} {start}"
exit 1
;;
esac
exit 0
# End udev

View File

@ -1,75 +0,0 @@
#!/bin/sh
########################################################################
# Begin udev_retry
#
# Description : Udev cold-plugging script (retry)
#
# Authors : Alexander E. Patrakov
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
# Bryan Kadzban -
#
# Version : LFS 7.0
#
########################################################################
### 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 additional 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
case "${1}" in
start)
log_info_msg "Retrying failed uevents, if any..."
# As of udev-186, the --run option is no longer valid
#rundir=$(/sbin/udevadm info --run)
rundir=/run/udev
# From Debian: "copy the rules generated before / was mounted
# read-write":
for file in ${rundir}/tmp-rules--*; do
dest=${file##*tmp-rules--}
[ "$dest" = '*' ] && break
cat $file >> /etc/udev/rules.d/$dest
rm -f $file
done
# Re-trigger the uevents that may have failed,
# in hope they will succeed now
/bin/sed -e 's/#.*$//' /etc/sysconfig/udev_retry | /bin/grep -v '^$' | \
while read line ; do
for subsystem in $line ; do
/sbin/udevadm trigger --subsystem-match=$subsystem --action=add
done
done
# Now wait for udevd to process the uevents we triggered
if ! is_true "$OMIT_UDEV_RETRY_SETTLE"; then
/sbin/udevadm settle
fi
evaluate_retval
;;
*)
echo "Usage ${0} {start}"
exit 1
;;
esac
exit 0
# End udev_retry

View File

@ -1,789 +0,0 @@
#!/bin/sh
########################################################################
#
# Begin /lib/lsb/init-funtions
#
# Description : Run Level Control Functions
#
# Authors : Gerard Beekmans - gerard@linuxfromscratch.org
# : DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
# Notes : With code based on Matthias Benkmann's simpleinit-msb
# http://winterdrache.de/linux/newboot/index.html
#
# The file should be located in /lib/lsb
#
########################################################################
## Environmental setup
# Setup default values for environment
umask 022
export PATH="/bin:/usr/bin:/sbin:/usr/sbin"
## Screen Dimensions
# Find current screen size
if [ -z "${COLUMNS}" ]; then
COLUMNS=$(stty size)
COLUMNS=${COLUMNS##* }
fi
# When using remote connections, such as a serial port, stty size returns 0
if [ "${COLUMNS}" = "0" ]; then
COLUMNS=80
fi
## Measurements for positioning result messages
COL=$((${COLUMNS} - 8))
WCOL=$((${COL} - 2))
## Set Cursor Position Commands, used via echo
SET_COL="\\033[${COL}G" # at the $COL char
SET_WCOL="\\033[${WCOL}G" # at the $WCOL char
CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char
CURS_ZERO="\\033[0G"
## Set color commands, used via echo
# Please consult `man console_codes for more information
# under the "ECMA-48 Set Graphics Rendition" section
#
# Warning: when switching from a 8bit to a 9bit font,
# the linux console will reinterpret the bold (1;) to
# the top 256 glyphs of the 9bit font. This does
# not affect framebuffer consoles
NORMAL="\\033[0;39m" # Standard console grey
SUCCESS="\\033[1;32m" # Success is green
WARNING="\\033[1;33m" # Warnings are yellow
FAILURE="\\033[1;31m" # Failures are red
INFO="\\033[1;36m" # Information is light cyan
BRACKET="\\033[1;34m" # Brackets are blue
# Use a colored prefix
BMPREFIX=" "
SUCCESS_PREFIX="${SUCCESS} * ${NORMAL}"
FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
WARNING_PREFIX="${WARNING} *** ${NORMAL}"
SUCCESS_SUFFIX="${BRACKET}[${SUCCESS} OK ${BRACKET}]${NORMAL}"
FAILURE_SUFFIX="${BRACKET}[${FAILURE} FAIL ${BRACKET}]${NORMAL}"
WARNING_SUFFIX="${BRACKET}[${WARNING} WARN ${BRACKET}]${NORMAL}"
BOOTLOG=/run/var/bootlog
KILLDELAY=3
# Set any user specified environment variables e.g. HEADLESS
[ -r /etc/sysconfig/rc.site ] && . /etc/sysconfig/rc.site
################################################################################
# start_daemon() #
# Usage: start_daemon [-f] [-n nicelevel] [-p pidfile] pathname [args...] #
# #
# Purpose: This runs the specified program as a daemon #
# #
# Inputs: -f: (force) run the program even if it is already running. #
# -n nicelevel: specify a nice level. See 'man nice(1)'. #
# -p pidfile: use the specified file to determine PIDs. #
# pathname: the complete path to the specified program #
# args: additional arguments passed to the program (pathname) #
# #
# Return values (as defined by LSB exit codes): #
# 0 - program is running or service is OK #
# 1 - generic or unspecified error #
# 2 - invalid or excessive argument(s) #
# 5 - program is not installed #
################################################################################
start_daemon()
{
local force=""
local nice="0"
local pidfile=""
local pidlist=""
local retval=""
# Process arguments
while true
do
case "${1}" in
-f)
force="1"
shift 1
;;
-n)
nice="${2}"
shift 2
;;
-p)
pidfile="${2}"
shift 2
;;
-*)
return 2
;;
*)
program="${1}"
break
;;
esac
done
# Check for a valid program
if [ ! -e "${program}" ]; then return 5; fi
# Execute
if [ -z "${force}" ]; then
if [ -z "${pidfile}" ]; then
# Determine the pid by discovery
pidlist=`pidofproc "${1}"`
retval="${?}"
else
# The PID file contains the needed PIDs
# Note that by LSB requirement, the path must be given to pidofproc,
# however, it is not used by the current implementation or standard.
pidlist=`pidofproc -p "${pidfile}" "${1}"`
retval="${?}"
fi
# Return a value ONLY
# It is the init script's (or distribution's functions) responsibilty
# to log messages!
case "${retval}" in
0)
# Program is already running correctly, this is a
# successful start.
return 0
;;
1)
# Program is not running, but an invalid pid file exists
# remove the pid file and continue
rm -f "${pidfile}"
;;
3)
# Program is not running and no pidfile exists
# do nothing here, let start_deamon continue.
;;
*)
# Others as returned by status values shall not be interpreted
# and returned as an unspecified error.
return 1
;;
esac
fi
# Do the start!
nice -n "${nice}" "${@}"
}
################################################################################
# killproc() #
# Usage: killproc [-p pidfile] pathname [signal] #
# #
# Purpose: Send control signals to running processes #
# #
# Inputs: -p pidfile, uses the specified pidfile #
# pathname, pathname to the specified program #
# signal, send this signal to pathname #
# #
# Return values (as defined by LSB exit codes): #
# 0 - program (pathname) has stopped/is already stopped or a #
# running program has been sent specified signal and stopped #
# successfully #
# 1 - generic or unspecified error #
# 2 - invalid or excessive argument(s) #
# 5 - program is not installed #
# 7 - program is not running and a signal was supplied #
################################################################################
killproc()
{
local pidfile
local program
local prefix
local progname
local signal="-TERM"
local fallback="-KILL"
local nosig
local pidlist
local retval
local pid
local delay="30"
local piddead
local dtime
# Process arguments
while true; do
case "${1}" in
-p)
pidfile="${2}"
shift 2
;;
*)
program="${1}"
if [ -n "${2}" ]; then
signal="${2}"
fallback=""
else
nosig=1
fi
# Error on additional arguments
if [ -n "${3}" ]; then
return 2
else
break
fi
;;
esac
done
# Check for a valid program
if [ ! -e "${program}" ]; then return 5; fi
# Check for a valid signal
check_signal "${signal}"
if [ "${?}" -ne "0" ]; then return 2; fi
# Get a list of pids
if [ -z "${pidfile}" ]; then
# determine the pid by discovery
pidlist=`pidofproc "${1}"`
retval="${?}"
else
# The PID file contains the needed PIDs
# Note that by LSB requirement, the path must be given to pidofproc,
# however, it is not used by the current implementation or standard.
pidlist=`pidofproc -p "${pidfile}" "${1}"`
retval="${?}"
fi
# Return a value ONLY
# It is the init script's (or distribution's functions) responsibilty
# to log messages!
case "${retval}" in
0)
# Program is running correctly
# Do nothing here, let killproc continue.
;;
1)
# Program is not running, but an invalid pid file exists
# Remove the pid file.
rm -f "${pidfile}"
# This is only a success if no signal was passed.
if [ -n "${nosig}" ]; then
return 0
else
return 7
fi
;;
3)
# Program is not running and no pidfile exists
# This is only a success if no signal was passed.
if [ -n "${nosig}" ]; then
return 0
else
return 7
fi
;;
*)
# Others as returned by status values shall not be interpreted
# and returned as an unspecified error.
return 1
;;
esac
# Perform different actions for exit signals and control signals
check_sig_type "${signal}"
if [ "${?}" -eq "0" ]; then # Signal is used to terminate the program
# Account for empty pidlist (pid file still exists and no
# signal was given)
if [ "${pidlist}" != "" ]; then
# Kill the list of pids
for pid in ${pidlist}; do
kill -0 "${pid}" 2> /dev/null
if [ "${?}" -ne "0" ]; then
# Process is dead, continue to next and assume all is well
continue
else
kill "${signal}" "${pid}" 2> /dev/null
# Wait up to ${delay}/10 seconds to for "${pid}" to
# terminate in 10ths of a second
while [ "${delay}" -ne "0" ]; do
kill -0 "${pid}" 2> /dev/null || piddead="1"
if [ "${piddead}" = "1" ]; then break; fi
sleep 0.1
delay="$(( ${delay} - 1 ))"
done
# If a fallback is set, and program is still running, then
# use the fallback
if [ -n "${fallback}" -a "${piddead}" != "1" ]; then
kill "${fallback}" "${pid}" 2> /dev/null
sleep 1
# Check again, and fail if still running
kill -0 "${pid}" 2> /dev/null && return 1
fi
fi
done
fi
# Check for and remove stale PID files.
if [ -z "${pidfile}" ]; then
# Find the basename of $program
prefix=`echo "${program}" | sed 's/[^/]*$//'`
progname=`echo "${program}" | sed "s@${prefix}@@"`
if [ -e "/var/run/${progname}.pid" ]; then
rm -f "/var/run/${progname}.pid" 2> /dev/null
fi
else
if [ -e "${pidfile}" ]; then rm -f "${pidfile}" 2> /dev/null; fi
fi
# For signals that do not expect a program to exit, simply
# let kill do 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/[^/]*$//'`
if [ -z "${prefix}" ]; then
progname="${program}"
else
progname=`echo "${program}" | sed "s@${prefix}@@"`
fi
# If a PID file exists with that name, assume that is it.
if [ -e "/var/run/${progname}.pid" ]; then
pidfile="/var/run/${progname}.pid"
fi
fi
# If a PID file is set and exists, use it.
if [ -n "${pidfile}" -a -e "${pidfile}" ]; then
# Use the value in the first line of the pidfile
pidlist=`/bin/head -n1 "${pidfile}"`
# This can optionally be written as 'sed 1q' to repalce 'head -n1'
# should LFS move /bin/head to /usr/bin/head
else
# Use pidof
pidlist=`pidof "${program}"`
fi
# Figure out if all listed PIDs are running.
for pid in ${pidlist}; do
kill -0 ${pid} 2> /dev/null
if [ "${?}" -eq "0" ]; then
lpids="${lpids}${pid} "
else
exitstatus="1"
fi
done
if [ -z "${lpids}" -a ! -f "${pidfile}" ]; then
return 3
else
echo "${lpids}"
return "${exitstatus}"
fi
}
################################################################################
# statusproc() #
# Usage: statusproc [-p pidfile] pathname #
# #
# Purpose: This function prints the status of a particular daemon to stdout #
# #
# Inputs: -p pidfile, use the specified pidfile instead of pidof #
# pathname, path to the specified program #
# #
# Return values: #
# 0 - Status printed #
# 1 - Input error. The daemon to check was not specified. #
################################################################################
statusproc()
{
local pidfile
local pidlist
if [ "${#}" = "0" ]; then
echo "Usage: statusproc [-p pidfle] {program}"
exit 1
fi
# Process arguments
while true; do
case "${1}" in
-p)
pidfile="${2}"
shift 2
;;
*)
if [ -n "${2}" ]; then
echo "Too many arguments"
return 1
else
break
fi
;;
esac
done
if [ -n "${pidfile}" ]; then
pidlist=`pidofproc -p "${pidfile}" $@`
else
pidlist=`pidofproc $@`
fi
# Trim trailing blanks
pidlist=`echo "${pidlist}" | sed -r 's/ +$//'`
base="${1##*/}"
if [ -n "${pidlist}" ]; then
/bin/echo -e "${INFO}${base} is running with Process" \
"ID(s) ${pidlist}.${NORMAL}"
else
if [ -n "${base}" -a -e "/var/run/${base}.pid" ]; then
/bin/echo -e "${WARNING}${1} is not running but" \
"/var/run/${base}.pid exists.${NORMAL}"
else
if [ -n "${pidfile}" -a -e "${pidfile}" ]; then
/bin/echo -e "${WARNING}${1} is not running" \
"but ${pidfile} exists.${NORMAL}"
else
/bin/echo -e "${INFO}${1} is not running.${NORMAL}"
fi
fi
fi
}
################################################################################
# timespec() #
# #
# Purpose: An internal utility function to format a timestamp #
# a boot log file. Sets the STAMP variable. #
# #
# Return value: Not used #
################################################################################
timespec()
{
STAMP="$(echo `date +"%b %d %T %:z"` `hostname`) "
return 0
}
################################################################################
# log_success_msg() #
# Usage: log_success_msg ["message"] #
# #
# Purpose: Print a successful status message to the screen and #
# a boot log file. #
# #
# Inputs: $@ - Message #
# #
# Return values: Not used #
################################################################################
log_success_msg()
{
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}"
# Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
timespec
/bin/echo -e "${STAMP} ${logmessage} OK" >> ${BOOTLOG}
return 0
}
log_success_msg2()
{
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}"
echo " OK" >> ${BOOTLOG}
return 0
}
################################################################################
# log_failure_msg() #
# Usage: log_failure_msg ["message"] #
# #
# Purpose: Print a failure status message to the screen and #
# a boot log file. #
# #
# Inputs: $@ - Message #
# #
# Return values: Not used #
################################################################################
log_failure_msg()
{
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}"
# Strip non-printable characters from log file
timespec
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
/bin/echo -e "${STAMP} ${logmessage} FAIL" >> ${BOOTLOG}
return 0
}
log_failure_msg2()
{
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}"
echo "FAIL" >> ${BOOTLOG}
return 0
}
################################################################################
# log_warning_msg() #
# Usage: log_warning_msg ["message"] #
# #
# Purpose: Print a warning status message to the screen and #
# a boot log file. #
# #
# Return values: Not used #
################################################################################
log_warning_msg()
{
/bin/echo -n -e "${BMPREFIX}${@}"
/bin/echo -e "${CURS_ZERO}${WARNING_PREFIX}${SET_COL}${WARNING_SUFFIX}"
# Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
timespec
/bin/echo -e "${STAMP} ${logmessage} WARN" >> ${BOOTLOG}
return 0
}
################################################################################
# log_info_msg() #
# Usage: log_info_msg message #
# #
# Purpose: Print an information message to the screen and #
# a boot log file. Does not print a trailing newline character. #
# #
# Return values: Not used #
################################################################################
log_info_msg()
{
/bin/echo -n -e "${BMPREFIX}${@}"
# Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
timespec
/bin/echo -n -e "${STAMP} ${logmessage}" >> ${BOOTLOG}
return 0
}
log_info_msg2()
{
/bin/echo -n -e "${@}"
# Strip non-printable characters from log file
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
/bin/echo -n -e "${logmessage}" >> ${BOOTLOG}
return 0
}
################################################################################
# evaluate_retval() #
# Usage: Evaluate a return value and print success or failyure as appropriate #
# #
# Purpose: Convenience function to terminate an info message #
# #
# Return values: Not used #
################################################################################
evaluate_retval()
{
local error_value="${?}"
if [ ${error_value} = 0 ]; then
log_success_msg2
else
log_failure_msg2
fi
}
################################################################################
# check_signal() #
# Usage: check_signal [ -{signal} | {signal} ] #
# #
# Purpose: Check for a valid signal. This is not defined by any LSB draft, #
# however, it is required to check the signals to determine if the #
# signals chosen are invalid arguments to the other functions. #
# #
# Inputs: Accepts a single string value in the form or -{signal} or {signal} #
# #
# Return values: #
# 0 - Success (signal is valid #
# 1 - Signal is not valid #
################################################################################
check_signal()
{
local valsig
# Add error handling for invalid signals
valsig="-ALRM -HUP -INT -KILL -PIPE -POLL -PROF -TERM -USR1 -USR2"
valsig="${valsig} -VTALRM -STKFLT -PWR -WINCH -CHLD -URG -TSTP -TTIN"
valsig="${valsig} -TTOU -STOP -CONT -ABRT -FPE -ILL -QUIT -SEGV -TRAP"
valsig="${valsig} -SYS -EMT -BUS -XCPU -XFSZ -0 -1 -2 -3 -4 -5 -6 -8 -9"
valsig="${valsig} -11 -13 -14 -15"
echo "${valsig}" | grep -- " ${1} " > /dev/null
if [ "${?}" -eq "0" ]; then
return 0
else
return 1
fi
}
################################################################################
# check_sig_type() #
# Usage: check_signal [ -{signal} | {signal} ] #
# #
# Purpose: Check if signal is a program termination signal or a control signal #
# This is not defined by any LSB draft, however, it is required to #
# check the signals to determine if they are intended to end a #
# program or simply to control it. #
# #
# Inputs: Accepts a single string value in the form or -{signal} or {signal} #
# #
# Return values: #
# 0 - Signal is used for program termination #
# 1 - Signal is used for program control #
################################################################################
check_sig_type()
{
local valsig
# The list of termination signals (limited to generally used items)
valsig="-ALRM -INT -KILL -TERM -PWR -STOP -ABRT -QUIT -2 -3 -6 -9 -14 -15"
echo "${valsig}" | grep -- " ${1} " > /dev/null
if [ "${?}" -eq "0" ]; then
return 0
else
return 1
fi
}
################################################################################
# wait_for_user() #
# #
# Purpose: Wait for the user to respond if not a headless system #
# #
################################################################################
wait_for_user()
{
# Wait for the user by default
[ "${HEADLESS=0}" = "0" ] && read ENTER
return 0
}
################################################################################
# is_true() #
# #
# Purpose: Utility to test if a variable is true | yes | 1 #
# #
################################################################################
is_true()
{
[ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] || [ "$1" = "y" ] ||
[ "$1" = "t" ]
}
# End /lib/lsb/init-functions

View File

@ -1,83 +0,0 @@
#!/bin/sh
########################################################################
# Begin /lib/services/ipv4-static
#
# Description : IPV4 Static Boot Script
#
# Authors : Nathan Coulson - nathan@linuxfromscratch.org
# Kevin P. Fleming - kpfleming@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
. /lib/lsb/init-functions
. ${IFCONFIG}
if [ -z "${IP}" ]; then
log_failure_msg "\nIP variable missing from ${IFCONFIG}, cannot continue."
exit 1
fi
if [ -z "${PREFIX}" -a -z "${PEER}" ]; then
log_warning_msg "\nPREFIX variable missing from ${IFCONFIG}, assuming 24."
PREFIX=24
args="${args} ${IP}/${PREFIX}"
elif [ -n "${PREFIX}" -a -n "${PEER}" ]; then
log_failure_msg "\nPREFIX 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
case "${2}" in
up)
if [ "$(ip addr show ${1} 2>/dev/null | grep ${IP}/)" = "" ]; then
# Cosmetic output not needed for multiple services
if ! $(echo ${SERVICE} | grep -q " "); then
log_info_msg2 "\n" # Terminate the previous message
fi
log_info_msg "Adding IPv4 address ${IP} to the ${1} interface..."
ip addr add ${args} dev ${1}
evaluate_retval
else
log_warning_msg "Cannot add IPv4 address ${IP} to ${1}. Already present."
fi
;;
down)
if [ "$(ip addr show ${1} 2>/dev/null | grep ${IP}/)" != "" ]; then
log_info_msg "Removing IPv4 address ${IP} from the ${1} interface..."
ip addr del ${args} dev ${1}
evaluate_retval
fi
if [ -n "${GATEWAY}" ]; then
# Only remove the gateway if there are no remaining ipv4 addresses
if [ "$(ip addr show ${1} 2>/dev/null | grep 'inet ')" != "" ]; then
log_info_msg "Removing default gateway..."
ip route del default
evaluate_retval
fi
fi
;;
*)
echo "Usage: ${0} [interface] {up|down}"
exit 1
;;
esac
# End /lib/services/ipv4-static

View File

@ -1,92 +0,0 @@
#!/bin/sh
########################################################################
# Begin /lib/services/ipv4-static-route
#
# Description : IPV4 Static Route Script
#
# Authors : Kevin P. Fleming - kpfleming@linuxfromscratch.org
# DJ Lucas - dj@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
########################################################################
. /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 "
;;
(*)
log_failure_msg "Unknown route type (${TYPE}) in ${IFCONFIG}, cannot continue."
exit 1
;;
esac
if [ -n "${need_ip}" ]; then
if [ -z "${IP}" ]; then
log_failure_msg "IP variable missing from ${IFCONFIG}, cannot continue."
exit 1
fi
if [ -z "${PREFIX}" ]; then
log_failure_msg "PREFIX variable missing from ${IFCONFIG}, cannot continue."
exit 1
fi
args="${args} ${IP}/${PREFIX}"
desc="${desc}${IP}/${PREFIX}"
fi
if [ -n "${need_gateway}" ]; then
if [ -z "${GATEWAY}" ]; then
log_failure_msg "GATEWAY variable missing from ${IFCONFIG}, cannot continue."
exit 1
fi
args="${args} via ${GATEWAY}"
fi
if [ -n "${SOURCE}" ]; then
args="${args} src ${SOURCE}"
fi
case "${2}" in
up)
log_info_msg "Adding '${desc}' route to the ${1} interface..."
ip route add ${args} dev ${1}
evaluate_retval
;;
down)
log_info_msg "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 /lib/services/ipv4-static-route

View File

@ -1,100 +0,0 @@
#!/bin/bash
########################################################################
# Begin /sbin/ifdown
#
# Description : Interface Down
#
# Authors : Nathan Coulson - nathan@linuxfromscratch.org
# Kevin P. Fleming - kpfleming@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.0
#
# Notes : the IFCONFIG variable is passed to the scripts found
# in the /lib/services directory, to indicate what file the
# service should source to get interface specifications.
#
########################################################################
RELEASE="7.0"
USAGE="Usage: $0 [ -hV ] [--help] [--version] interface"
VERSTR="LFS ifdown, version ${RELEASE}"
while [ $# -gt 0 ]; do
case "$1" in
--help | -h) help="y"; break ;;
--version | -V) echo "${VERSTR}"; exit 0 ;;
-*) echo "ifup: ${1}: invalid option" >&2
echo "${USAGE}" >& 2
exit 2 ;;
*) break ;;
esac
done
if [ -n "$help" ]; then
echo "${VERSTR}"
echo "${USAGE}"
echo
cat << HERE_EOF
ifdown is used to bring down a network interface. The interface
parameter, e.g. eth0 or eth0:2, must match the trailing part of the
interface specifications file, e.g. /etc/sysconfig/ifconfig.eth0:2.
HERE_EOF
exit 0
fi
file=/etc/sysconfig/ifconfig.${1}
# Skip backup files
[ "${file}" = "${file%""~""}" ] || exit 0
. /lib/lsb/init-functions
if [ ! -r "${file}" ]; then
log_warning_msg "${file} is missing or cannot be accessed."
exit 1
fi
. ${file}
if [ "$IFACE" = "" ]; then
log_failure_msg "${file} does not define an interface [IFACE]."
exit 1
fi
# We only need to first service to bring down the interface
S=`echo ${SERVICE} | cut -f1 -d" "`
if ip link show ${IFACE} > /dev/null 2>&1; then
if [ -n "${S}" -a -x "/lib/services/${S}" ]; then
IFCONFIG=${file} /lib/services/${S} ${IFACE} down
else
MSG="Unable to process ${file}. Either "
MSG="${MSG}the SERVICE variable was not set "
MSG="${MSG}or the specified service cannot be executed."
log_failure_msg "$MSG"
exit 1
fi
else
log_warning_msg "Interface ${1} doesn't exist."
fi
# Leave the interface up if there are additional interfaces in the device
link_status=`ip link show ${IFACE} 2>/dev/null`
if [ -n "${link_status}" ]; then
if [ "$(echo "${link_status}" | grep UP)" != "" ]; then
if [ "$(ip addr show ${IFACE} | grep 'inet ')" == "" ]; then
log_info_msg "Bringing down the ${IFACE} interface..."
ip link set ${IFACE} down
evaluate_retval
fi
fi
fi
# End /sbin/ifdown

View File

@ -1,136 +0,0 @@
#!/bin/sh
########################################################################
# Begin /sbin/ifup
#
# Description : Interface Up
#
# Authors : Nathan Coulson - nathan@linuxfromscratch.org
# Kevin P. Fleming - kpfleming@linuxfromscratch.org
# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version : LFS 7.2
#
# Notes : The IFCONFIG variable is passed to the SERVICE script
# in the /lib/services directory, to indicate what file the
# service should source to get interface specifications.
#
########################################################################
up()
{
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
fi
fi
else
log_failure_msg "\nInterface ${IFACE} doesn't exist."
exit 1
fi
}
RELEASE="7.2"
USAGE="Usage: $0 [ -hV ] [--help] [--version] interface"
VERSTR="LFS ifup, version ${RELEASE}"
while [ $# -gt 0 ]; do
case "$1" in
--help | -h) help="y"; break ;;
--version | -V) echo "${VERSTR}"; exit 0 ;;
-*) echo "ifup: ${1}: invalid option" >&2
echo "${USAGE}" >& 2
exit 2 ;;
*) break ;;
esac
done
if [ -n "$help" ]; then
echo "${VERSTR}"
echo "${USAGE}"
echo
cat << HERE_EOF
ifup is used to bring up a network interface. The interface
parameter, e.g. eth0 or eth0:2, must match the trailing part of the
interface specifications file, e.g. /etc/sysconfig/ifconfig.eth0:2.
HERE_EOF
exit 0
fi
file=/etc/sysconfig/ifconfig.${1}
# Skip backup files
[ "${file}" = "${file%""~""}" ] || exit 0
. /lib/lsb/init-functions
log_info_msg "Bringing up the ${1} interface... "
if [ ! -r "${file}" ]; then
log_failure_msg2 "${file} is missing or cannot be accessed."
exit 1
fi
. $file
if [ "$IFACE" = "" ]; then
log_failure_msg2 "${file} does not define an interface [IFACE]."
exit 1
fi
# Do not process this service if started by boot, and ONBOOT
# is not set to yes
if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
log_info_msg2 "skipped"
exit 0
fi
for S in ${SERVICE}; do
if [ ! -x "/lib/services/${S}" ]; then
MSG="\nUnable to process ${file}. Either "
MSG="${MSG}the SERVICE '${S} was not present "
MSG="${MSG}or cannot be executed."
log_failure_msg "$MSG"
exit 1
fi
done
# Create/configure the interface
for S in ${SERVICE}; do
IFCONFIG=${file} /lib/services/${S} ${IFACE} up
done
# Bring up the interface and any components
for I in $IFACE $INTERFACE_COMPONENTS; do up $I; done
# Set MTU if requested. Check if MTU has a "good" value.
if test -n "${MTU}"; then
if [[ ${MTU} =~ ^[0-9]+$ ]] && [[ $MTU -ge 68 ]] ; then
for I in $IFACE $INTERFACE_COMPONENTS; do
ip link set dev $I mtu $MTU;
done
else
log_info_msg2 "Invalid MTU $MTU"
fi
fi
# Set the route default gateway if requested
if [ -n "${GATEWAY}" ]; then
if ip route | grep -q default; then
log_warning_msg "\nGateway already setup; skipping."
else
log_info_msg "Setting up default gateway..."
ip route add default via ${GATEWAY} dev ${IFACE}
evaluate_retval
fi
fi
# End /sbin/ifup

View File

@ -1,174 +0,0 @@
ifup(8) ifup(8)
NAME
ifup - bring a network interface up
ifdown - take a network interface down
SYNOPSIS
ifup IFACE
ifup -h|--help
ifup -V|--version
ifdown IFACE
ifdown -h|--help
ifdown -V|--version
DESCRIPTION
The ifup and ifdown commands may be used to configure
(or, respectively, deconfigure) a network interface based
on interface definitions in the file
/etc/sysconfig/ifconfig.IFACE.
OPTIONS
A summary of options is included below.
-h, --help
Show summary of options.
-V, --version
Show version information.
EXAMPLES
ifup eth0
Bring up the interface defined in the file
/etc/sysconfig/ifconfig.eth0
ONBOOT=no
IFACE=eth0
SERVICE=ipv4-static
IP=192.168.1.22
GATEWAY=192.168.1.1
PREFIX=24
BROADCAST=192.168.1.255
ifdown eth0:2
Bring down the interface defined in the file
/etc/sysconfig/ifconfig.eth0:2
ONBOOT=no
IFACE=eth0:2
SERVICE=dhcpcd
DHCP_START="--waitip"
DHCP_STOP="-k"
# Set PRINTIP="yes" to have the script print the DHCP IP address
PRINTIP="yes"
# Set PRINTALL="yes" to print the DHCP assigned values for
# IP, SM, DG, and 1st NS.
PRINTALL="no"
ifup br0
Bring up the interface defined in the file
/etc/sysconfig/ifconfig.br0
ONBOOT=yes
IFACE=br0
SERVICE="bridge ipv4-static"
IP=192.168.1.22
GATEWAY=192.168.1.1
PREFIX=24
BROADCAST=192.168.1.255
STP=no # Spanning tree protocol, default no
INTERFACE_COMPONENTS=eth0 # Add to IFACE
IP_FORWARD=true
NOTES
The program does not configure network interfaces direct-
ly. It runs scripts defined by the SERVICE variable in
the network configuration file.
The configuration files must have the following environ-
ment variables set:
IFACE - The interface to configure, e.g. eth0. It must
be available in /sys/class/net.
SERVICE - The service script to run to bring up the inter-
face. Standard services are ipv4-static and
ipv4-static-route. Other services such as dhcp
or bridge may be installed. This value may
be a list of services when the interface is a
compound device such as a bridge.
ONBOOT - If set to 'yes', the specified interface is
configured by the netowrk boot script.
GATEWAY - The default IP address to use for routing if
the destination IP address is not in a static
route or on a local network, e.g., 192.168.1.1.
For secondary IP addresses on an interface, this
parameter should not be specified.
INTERFACE_COMPONENTS - A list of component interfaces
only needed for a compound device such as a bridge.
This list is normally a single value, e.g. eth0,
for use with a virtual host such as kvm.
Other paramters that are service specific include:
ipv4-static
IP - The IP address of the interface,
e.g. 192.168.1.2.
PREFIX - The number of bits that specify the network
number of the interface. The default, if not
specified, is 24.
BROADCAST - The brodcast address for this interface,
e.g 192.168.1.255. If not specified,
the broadcast address will be calculated
from the IP and PREFIX.
ipv4-static-route
TYPE - The type of route, typically 'default',
'network', 'or host'.
IP - The IP address for a network or host, if the
TYPE is not 'default'.
PREFIX - The prefix for the associated IP address.
GATEWAY - The IP address for a network route.
SOURCE - The source IP address to prefer when sending
to the destinations covered by the specified
route. (optional)
dhcp/dhclient
DHCP_START - Optional parameters to pass to the dhcp client
at startup.
DHCP_STOP - Optional paremeters to pass to the dhcp client
at shutdown.
PRINTIP - Flag to print the dhcp address to stdout
PRINTALL - Flag to print all obtained dhcp data to stdout
bridge
IP_FORWARD - An optional flag to enable the system to forward
inbound IP packets received by one interface to
another outbound interface.
STP - Set bridge spanning tree protocol. Default is no.
FILES
/etc/sysconfig/ifconfig.*
definitions of network interfaces
AUTHORS
The ifup/ifdown suite was written by Nathan Coulson
<nathan@linuxfromscratch.org> and Kevin P. Fleming
<kpfleming@linuxfromscratch.org>
and updated by Bruce Dubbs <bdubbs@linuxfromscratch>.
SEE ALSO
ip(8).
IFUP/IFDOWN 8 April 2012 ifup(8)

View File

@ -1,31 +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"
# <filename> <type> <permissions> <user> <group>
# if type is equal to "dev"
# <filename> <type> <permissions> <user> <group> <devtype>
# <major> <minor>
#
# <filename> is the name of the file which is to be created
# <type> is either file, dir, or dev.
# file creates a new file
# dir creates a new directory
# dev creates a new device
# <devtype> is either block, char or pipe
# block creates a block device
# char creates a character deivce
# pipe creates a pipe, this will ignore the <major> and
# <minor> fields
# <major> and <minor> are the major and minor numbers used for
# the device.
########################################################################
# End /etc/sysconfig/createfiles

View File

@ -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:
# <module> [<arg1> <arg2> ...]
#
# 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

View File

@ -1,90 +0,0 @@
# rc.site
# Optional parameters for boot scripts.
# Distro Information
# These values, if specified here, override the defaults
#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
# Please consult `man console_codes` for more information
# under the "ECMA-48 Set Graphics Rendition" section
#
# Warning: when switching from a 8bit to a 9bit font,
# the linux console will reinterpret the bold (1;) to
# the top 256 glyphs of the 9bit font. This does
# not affect framebuffer consoles
# These values, if specified here, override the defaults
#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
# Use a colored prefix
# These values, if specified here, override the defaults
#BMPREFIX=" "
#SUCCESS_PREFIX="${SUCCESS} * ${NORMAL}"
#FAILURE_PREFIX="${FAILURE}*****${NORMAL}"
#WARNING_PREFIX="${WARNING} *** ${NORMAL}"
# Interactive startup
#IPROMPT="yes" # Whether to display the interactive boot prompt
#itime="3" # The amount of time (in seconds) to display the prompt
# The total length of the distro welcome string, without escape codes
#wlen=$(echo "Welcome to ${DISTRO}" | wc -c )
#welcome_message="Welcome to ${INFO}${DISTRO}${NORMAL}"
# The total length of the interactive string, without escape codes
#ilen=$(echo "Press 'I' to enter interactive startup" | wc -c )
#i_message="Press '${FAILURE}I${NORMAL}' to enter interactive startup"
# Set scripts to skip the file system check on reboot
#FASTBOOT=yes
# Skip reading from the console
#HEADLESS=yes
# Speed up boot without waiting for settle in udev_retry
#OMIT_UDEV_RETRY_SETTLE=yes
# Write out fsck progress if yes
#VERBOSE_FSCK=no
# Speed up boot without waiting for settle in udev
#OMIT_UDEV_SETTLE=y
# Speed up boot without waiting for settle in udev_retry
#OMIT_UDEV_RETRY_SETTLE=yes
# Skip cleaning /tmp if yes
#SKIPTMPCLEAN=no
# For setclock
#UTC=1
#CLOCKPARAMS=
# For consolelog
#LOGLEVEL=5
# For network
#HOSTNAME=mylfs
# Delay between TERM and KILL signals at shutdown
#KILLDELAY=3
# Optional sysklogd parameters
#SYSKLOGD_PARMS="-m 0"
# Console parameters
#UNICODE=1
#KEYMAP="de-latin1"
#KEYMAP_CORRECTIONS="euro2"
#FONT="lat0-16 -m 8859-15"
#LEGACY_CHARSET=

View File

@ -1,19 +0,0 @@
########################################################################
# Begin /etc/sysconfig/udev_retry
#
# Description : udev_retry script configuration
#
# Authors :
#
# Version : 00.00
#
# Notes : Each subsystem that may need to be re-triggered after mountfs
# runs should be listed in this file. Probable subsystems to be
# listed here are rtc (due to /var/lib/hwclock/adjtime) and sound
# (due to both /var/lib/alsa/asound.state and /usr/sbin/alsactl).
# Entries are whitespace-separated.
########################################################################
rtc
# End /etc/sysconfig/udev_retry

View File

@ -36,6 +36,16 @@
</listitem>
-->
<listitem>
<para>2013-02-06</para>
<itemizedlist>
<listitem>
<para>[matthew] - Remove Sysvinit bootscripts and custom Udev rules,
to aid with Systemd integration.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>2013-01-30</para>
<itemizedlist>

View File

@ -22,7 +22,6 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="setclock.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="console.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="sysklogd.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="site.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="profile.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="inputrc.xml"/>

View File

@ -48,10 +48,6 @@
<para>If using an alternative style of init scripts, skip these sections.</para>
<para>A listing of the boot scripts are found in <xref linkend="scripts"
role="."/>.</para>
<itemizedlist>
<listitem>
<para><xref linkend="ch-scripts-bootscripts" role="."/></para>

View File

@ -1,103 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../general.ent">
<!ENTITY site SYSTEM "../appendices/rc.site.script">
%general-entities;
]>
<sect1 id="ch-scripts-site">
<?dbhtml filename="site.html"?>
<title>The rc.site File</title>
<indexterm zone="ch-scripts-site">
<primary sortas="a-rc.site">rc.site</primary>
</indexterm>
<para>The optional <filename>/etc/sysconfig/rc.site</filename> file contains
settings that are automatically set for each boot script. It can alternatively
set the values specified in the <filename>hostname</filename>,
<filename>console</filename>, and <filename>clock</filename> files in the
<filename class='directory'>/etc/sysconfig/</filename> directory. If the
associated variables are present in both these separate files and
<filename>rc.site</filename>, the values in the script specific files have
precedence. </para>
<para><filename>rc.site</filename> also contains parameters that can
customize other aspects of the boot process. Setting the IPROMPT variable
will enable selective running of bootscripts. Other options are described
in the file comments. The default version of the file is as follows:</para>
<!-- Use role to fix a pdf generation problem -->
<screen role="auto">&site;</screen>
<sect2>
<title>Customizing the Boot and Shutdown Scripts</title>
<para>The LFS boot scripts boot and shut down a system in a fairly
efficient manner, but there are a few tweaks that you can make in the
rc.site file to improve speed even more and to adjust messages accoring
to your preferences. To do this, adjust the settings in
the <filename>/etc/sysconfig/rc.site</filename> file above.</para>
<itemizedlist>
<listitem><para>During the boot script <filename>udev</filename>, there is
a call to <command>udev settle</command> that requires some time to
complete. This time may or may not be required depending on devices present
in the system. If you only have simple partitions and a single ethernet
card, the boot process will probably not need to wait for this command. To
skip it, set the variable OMIT_UDEV_SETTLE=y.</para></listitem>
<listitem><para>The boot script <filename>udev_retry</filename> also runs
<command>udev settle</command> by default. This command is only needed by
default if the <filename class='directory'>/var</filename> directory is
separately mounted. This is because the clock needs the file
<filename>/var/lib/hwclock/adjtime</filename>. Other customizations may
also need to wait for udev to complete, but in many installations it is not
needed. Skip the command by setting the variable OMIT_UDEV_RETRY_SETTLE=y.
</para></listitem>
<listitem><para>By default, the file system checks are silent. This can
appear to be a delay during the bootup process. To turn on the
<command>fsck</command> output, set the variable VERBOSE_FSCK=y.
</para></listitem>
<listitem><para>When rebooting, you may want to skip the filesystem check,
<command>fsck</command>, completely. To do this, either create the file
<filename>/fastboot</filename> or reboot the system with the command
<command>/sbin/shutdown -f -r now</command>. On the other hand, you can
force all file systems to be checked by creating
<filename>/forcefsck</filename> or running <command>shutdown</command> with
the <parameter>-F</parameter> parameter instead of <parameter>-f</parameter>.
</para>
<para>Setting the variable FASTBOOT=y will disable <command>fsck</command>
during the boot process until it is removed. This is not recommended
on a permanent basis.</para></listitem>
<listitem><para>Normally, all files in the <filename
class='directory'>/tmp</filename> directory are deleted at boot time.
Depending on the number of files or directories present, this can cause a
noticible delay in the boot process. To skip removing these files set the
variable SKIPTMPCLEAN=y.</para></listitem>
<listitem><para>During shutdown, the <command>init</command> program sends
a TERM signal to each program it has started (e.g. agetty), waits for a set
time (default 3 seconds), and sends each process a KILL signal and waits
again. This process is repeated in the <command>sendsignals</command>
script for any processes that are not shut down by their own scripts. The
delay for <command>init</command> can be set by passing a parameter. For
example to remove the delay in <command>init</command>, pass the -t0
parameter when shutting down or rebooting (e.g. <command>/sbin/shutdown
-t0 -r now</command>). The delay for the <command>sendsignals</command>
script can be skipped by setting the parameter
KILLDELAY=0.</para></listitem>
</itemizedlist>
</sect2>
</sect1>

View File

@ -1,5 +1,5 @@
<!ENTITY version "SYSTEMD-20130205">
<!ENTITY releasedate "February 5, 2013">
<!ENTITY version "SYSTEMD-20130206">
<!ENTITY releasedate "February 6, 2013">
<!ENTITY copyrightdate "1999-2013"><!-- jhalfs needs a literal dash, not &ndash; -->
<!ENTITY milestone "7.3">
<!ENTITY generic-version "systemd"> <!-- Use "development", "testing", or "x.y[-pre{x}]" -->

View File

@ -41,8 +41,6 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendices/acronymlist.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendices/acknowledgments.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendices/dependencies.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendices/scripts.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendices/udev-rules.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="appendices/license.xml"/>
</part>

View File

@ -1,22 +0,0 @@
#!/bin/bash
rm -f lfs-bootscripts*.tar.bz2
# Get base file name and move bootscripts directory to that name
version=`grep "ENTITY lfs-bootscripts-version" packages.ent |cut -d'"' -f2`
mv bootscripts lfs-bootscripts-$version
# Create the tarball and clean up
tar -cjf lfs-bootscripts-$version.tar.bz2 --exclude .svn lfs-bootscripts-$version
mv lfs-bootscripts-$version bootscripts
#rm -f udev-config*.bz2
# Get file name and move udev config directory to that name
#version=`grep "ENTITY udev-config " packages.ent |cut -d'"' -f2`
#mv udev-config $version
# Create the tarball and clean up
#tar -cjf $version.tar.bz2 --exclude .svn $version
#mv $version udev-config

View File

@ -1,24 +0,0 @@
#!/bin/bash
# Boot scripts
for s in bootscripts/lfs/init.d/* \
bootscripts/lfs/sysconfig/* \
bootscripts/lfs/lib/services/* \
bootscripts/lfs/sbin/* \
udev-lfs/*.rules
do
script=$(basename $s)
# Skip directories
[ $script == 'network-devices' ] && continue
#[ $script == 'services' ] && continue
# Disambiguate duplicate file names
[ $s == 'bootscripts/lfs/sysconfig/rc' ] && script='rc-sysinit';
[ $s == 'bootscripts/lfs/sysconfig/modules' ] && script='modules-sysinit';
[ $s == 'bootscripts/lfs/sysconfig/udev_retry' ] && script='config-udev-retry';
sed -e 's/\&/\&amp\;/g' -e 's/</\&lt\;/g' -e 's/>/\&gt\;/g' \
-e "s/'/\&apos\;/g" -e 's/"/\&quot\;/g' -e 's/\t/ /g' \
$s > appendices/${script}.script
done

View File

@ -1,14 +0,0 @@
# /etc/udev/rules.d/55-lfs.rules: Rule definitions for LFS.
# Core kernel devices
# This causes the system clock to be set as soon as /dev/rtc becomes available.
SUBSYSTEM=="rtc", ACTION=="add", MODE="0644", RUN+="/etc/rc.d/init.d/setclock start"
KERNEL=="rtc", ACTION=="add", MODE="0644", RUN+="/etc/rc.d/init.d/setclock start"
# Comms devices
KERNEL=="ippp[0-9]*", GROUP="dialout"
KERNEL=="isdn[0-9]*", GROUP="dialout"
KERNEL=="isdnctrl[0-9]*", GROUP="dialout"
KERNEL=="dcbri[0-9]*", GROUP="dialout"

View File

@ -1,20 +0,0 @@
Purpose of rules file:
Most of the rules installed by Udev itself create devices with the correct
properties. This file contains rules that have not been merged upstream yet.
Description of rules:
By default, Udev creates device nodes with UID 0, GID 0, and permissions 0660.
ISDN-related devices should be owned by the 'dialout' group, hence the following
rule (and similar):
KERNEL=="ippp[0-9]*", GROUP="dialout"
The RTC-related rules cause the setclock bootscript to be run as soon as the
RTC device has been created by Udev, meaning that times in log files, for
example, are as accurate as possible as quickly as possible.
A final word of caution: Any particular rule must be written on one line, and a
comma must separate each part of the rule.

View File

@ -1,3 +0,0 @@
# /etc/udev/rules.d/81-cdrom.rules: Set CD-ROM permissions and get device capabilities
ACTION=="add", SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", IMPORT{program}="cdrom_id --export $tempnode", GROUP="cdrom"

View File

@ -1,13 +0,0 @@
# /etc/udev/rules.d/83-cdrom-symlinks.rules: Determine CD drive capability.
ACTION!="add", GOTO="cd_aliases_generator_end"
SUBSYSTEM!="block", GOTO="cd_aliases_generator_end"
ENV{GENERATED}=="?*", GOTO="cd_aliases_generator_end"
# Fail the uevent if the autogenerated rules cannot be saved
ENV{ID_CDROM}=="?*", PROGRAM="/bin/grep -c ' / [^[:space:]]* rw' /proc/mounts", \
RESULT!="2", RUN+="/bin/false", GOTO="cd_aliases_generator_end"
ENV{ID_CDROM}=="?*", PROGRAM="write_cd_rules", SYMLINK+="%c"
LABEL="cd_aliases_generator_end"

View File

@ -1,254 +0,0 @@
2010-01-26 Matt Burgess <matthew@linuxfromscratch.org>
* 55-lfs.rules: Remove lots of rules that have been merged upstream.
* 61-cdrom.rules: Remove as upstream has a replacement.
* doc/*: Cleanup and rewrite now that the rules are much simpler.
2009-09-25 Bryan Kadzban <bryan@linuxfromscratch.org>
* 55-lfs.rules: Make the RTC rule (which runs setclock) work for people
that don't use the RTC-class driver -- add another copy of the rule,
using KERNEL=="rtc" instead of SUBSYSTEM=="rtc". Also move the ACTION
match before the assignment to MODE.
2009-05-23 Bruce Dubbs <bdubbs@linuxfromscratch.org>
* 55-lfs.rules: Set the rtc by udev upon boot. Removed aio device from
udev configuration so defaults are used.
2009-05-16 Bryan Kadzban <bryan@linuxfromscratch.org>
* 55-lfs.rules: Adopt udev permissions for random, urandom, kmsg, and
input devices (including psaux, which probably doesn't exist anymore
anyway).
2009-05-16 Matt Burgess <matthew@linuxfromscratch.org>
* 55-lfs.rules: Remove the block rule as it was only setting
permissions that Udev will set by default
* 55-lfs.rules: Remove the rfcomm rule as the group it sets is already
included in upstream's rule
* 55-lfs-rules: Remove the tape rules as the group they sets is already
included in upstream's rules
2009-03-15 Bryan Kadzban <bryan@linuxfromscratch.org>
* 55-lfs.rules: Remove the ISDN-handling rules (replaced with upstream's
version, which has a better match via SUBSYSTEM).
* 55-lfs.rules: Replace "uucp" with "dialout" now that udev has decided
to standardize on a Debian-like setup (uucp is for UUCP daemons to use
for privilege separation; dialout is for users and devices).
2008-12-07 Bruce Dubbs <bdubbs@linuxfromscratch.org>
* 55-lfs.rules: Change one line to use continuation so it does
not overflow the book's width.
2008-12-07 Bryan Kadzban <bryan@linuxfromscratch.org>
* 55-lfs.rules: Remove several rules that are either provided by upstream,
or that don't have any effect (there is no /dev/js or /dev/djs according
to devices.txt).
* 55-lfs.rules, 61-cdrom.rules: Replace ACTION=="add" with "add|change"
everywhere, per upstream's general request.
2008-11-11 Bryan Kadzban <bryan@linuxfromscratch.org>
* 55-lfs.rules, 61-cdrom.rules: Fix comments to use the right rule
numbers. Thanks to Trent Shea for the fix. Closes #2278.
2008-10-15 DJ Lucas <dj@linuxfromscratch.org>
* 55-lfs.rules: Override default perms on floppy disk devices provided
by 50-udev-default.rules. Thanks to Bruce Dubbs for the fix. Closes
LFS ticket #2076.
2008-05-21 Bryan Kadzban <bryan@linuxfromscratch.org>
* 81-firmware.rules, doc/81-firmware.txt: Remove. This rule is
already handled by udev's 50-udev-default.rules file. The docs
can be added back later if needed.
* Makefile: Don't install the above deleted files.
* 55-lfs.rules: Remove the device-mapper rule, since the upstream
50-udev-default.rules file handles it properly.
2008-04-02 Bryan Kadzban <bryan@linuxfromscratch.org>
* Makefile: Make the package DESTDIR-friendly by installing the docs
into a fixed $(PREFIX)/share/doc/udev-config directory, instead of
trying to figure out what version of udev was just installed.
2007-10-30 Bryan Kadzban <bryan@linuxfromscratch.org>
* 55-lfs.rules: Since the dialout group was renamed to uucp, delete
the rules that override upstream's assignment of the dialout group.
Replace "dialout" with "uucp" on the remaining rules.
2007-10-29 Bryan Kadzban <bryan@linuxfromscratch.org>
* 51-lfs.rules: Move to 55-lfs.rules.
* doc/51-lfs.rules: Move to doc/55-lfs.rules.
2007-10-27 Bryan Kadzban <bryan@linuxfromscratch.org>
* 25-lfs.rules: Some rules in here are duplicates of rules from udev's
new 50-udev-defaults.rules file; remove them. Override permissions
where needed elsewhere (and document overrides in comments).
* 26-modprobe.rules: Provided by udev's 80-drivers.rules and built-in
modaliases for SCSI device-type modules in 2.6.22+ kernels; remove.
* 25-lfs.rules: Move to 51-lfs.rules.
* 27-firmware.rules: Move to 81-firmware.rules.
* 81-cdrom.rules: Move to 61-cdrom.rules.
* doc/25-lfs.txt: Rename to 51-lfs.txt.
* doc/26-modprobe.txt: Rename to 80-drivers.txt, and modify to reflect
the upstream rules.
* doc/27-firmware.txt: Rename to 81-firmware.txt.
* doc/81-cdrom.txt: Rename to 61-cdrom.txt.
* Makefile: Use new filenames.
2007-07-31 Dan Nicholson <dnicholson@linuxfromscratch.org>
* 25-lfs.rules: Changed the usb_device rule tto create /dev/bus/usb
nodes if the usb_device in 2.6.22+ kernels. The rule was also changed
to only trigger on "add" events. This change is not backwards
compatible with older kernels.
2007-06-12 Dan Nicholson <dnicholson@linuxfromscratch.org>
* 25-lfs.rules: Fix the CPUID nodes from cpu/%n/cpu to cpu/%n/cpuid,
which is what's expected in userspace apps such as x86info.
2007-06-08 Bryan Kadzban <bryan@linuxfromscratch.org>
* 25-lfs.rules: Add rules for DVB devices (create nodes in /dev/dvb/)
and floppies (create extra nodes based on CMOS type), copied from
the SuSE rules file. Thanks to Alexander Patrakov for the bugreport.
2007-03-04 Matthew Burgess <matthew@linuxfromscratch.org>
* Makefile: Use `udevd --version' to work out what version of Udev is
installed (requires Udev >= 106)
2007-01-02 Bryan Kadzban <bryan@linuxfromscratch.org>
* 25-lfs.rules: Change CPU devices (cpu, msr, microcode) to be in
/dev/cpu/ and /dev/cpu/N/, to match Documentation/devices.txt.
2006-10-21 Bryan Kadzban <bryan@linuxfromscratch.org>
* Makefile: Add a missing backslash in install-extra-doc.
* 05-udev-early.rules, 60-persistent-input.rules,
60-persistent-storage.rules, 95-udev-late.rules: Remove. The book
will install these files from udev's etc/udev/rules.d directory
instead.
* Makefile: Don't install these rules files after all. Also, only
install corresponding docs if requested.
2006-10-20 Bryan Kadzban <bryan@linuxfromscratch.org>
* Makefile: Added; contains targets to install rules and doc files.
From Dan Nicholson.
2006-10-14 Bryan Kadzban <bryan@linuxfromscratch.org>
* 05-udev-early.rules, 60-persistent-storage.rules: Sync up with
upstream sample rules files (from udev-102), except for one rule
which is more specific in our tarball and should probably be changed
upstream.
* doc/60-persistent-storage.txt: Modify to match the changes. Also
fix a couple typos.
* 25-lfs.rules: Remove duplicate rules (ttyS[0-9]* is also matched by
tty[BC...S...][0-9]*, and ttyUSB[0-9]* is in there twice).
* 25-lfs.rules: Fix Alsa device KERNEL rules. Udev uses shell-style
glob matching, not regular expressions, so the old rules would match
nonsense device names like hw0asdf and pcmDzxcv. As long as the first
character after the "fixed" portion was in the list, the rule would
match; it wouldn't apply the same character range to later characters.
* doc/25-lfs.txt: Add a note on interaction between permissions and
symlinks.
2006-10-09 Bryan Kadzban <bryan@linuxfromscrtach.org>
* 25-lfs.rules: Fix fb[0-9]* device permissions (should use the default
0660).
* doc/25-lfs.txt: Fix typo: /dev/ptmx is given mode 0666, not 0660.
Also tweak the comment about other TTY devices.
2006-10-04 Bryan Kadzban <bryan@linuxfromscratch.org>
* 05-udev-early.rules: Remove WAIT_FOR_SYSFS="bus" rule. With kernel
2.6.18, this rule is no longer required.
* doc/05-udev-early.txt: Update to match.
2006-09-28 Bryan Kadzban <bryan@linuxfromscratch.org>
* doc/60-persistent-storage.txt: Explain persistent storage rules, or
at least the parts I understand. (I don't use DASD or netblock or
several other supported configurations.)
* doc/81-cdrom.txt: Explain 81-cdrom.rules.
* doc/95-udev-late.txt: Explain 95-udev-late.rules. Documentation is
now finished.
2006-09-26 Bryan Kadzban <bryan@linuxfromscratch.org>
* doc/60-persistent-input.txt: Explain (in probably too much detail)
60-persistent-input.rules.
2006-09-24 Bryan Kadzban <bryan@linuxfromscratch.org>
* doc/05-udev-early.txt: Rewrap to fit 80 columns.
* doc/26-modprobe.txt: Explain 26-modprobe.rules, and modaliases.
* doc/27-firmware.txt: Explain 27-firmware.rules.
2006-09-24 Bryan Kadzban <bryan@linuxfromscratch.org>
* doc/25-lfs.txt: Explain 25-lfs.rules.
* 25-lfs.rules: Use SYMLINK+= for isdn/capi20 also.
2006-09-23 Bryan Kadzban <bryan@linuxfromscratch.org>
* doc: New subdirectory to contain documentation of rules
* doc/README: New file, top-level documentation
* doc/*.txt: New documentation files, one for each rules file. Only
05-udev-early.txt has anything in it.
2006-09-23 Bryan Kadzban <bryan@linuxfromscratch.org>
* 25-lfs.rules: Add "ignore_device" to OPTIONS for DRI devices, instead
of setting NAME to an empty string. This matches the way we ignore
devmapper / LVM devices.
2006-09-22 Bryan Kadzban <bryan@linuxfromscratch.org>
* 60-persistent-input.rules, 95-udev-late.rules: Import from udev-100.
60-persistent-input.rules creates persistent symlinks for input
devices, and 95-udev-late.rules enables udevmonitor.
* 60-persistent-storage.rules: Replace ATTRS{../removable} with just
ATTRS{removable} on partition devices. Replace ATTRS{removable}
with ATTR{removable} on whole-disk devices.
2006-09-20 Bryan Kadzban <bryan@linuxfromscratch.org>
* 05-early.rules: Missed a rule in the last change. ENV{PHYSDEVBUS}
in the rule that waits for the "bus" symlink should be replaced by
SUBSYSTEMS.
2006-09-20 Bryan Kadzban <bryan@linuxfromscratch.org>
* Adapted rules to the new matches used in udev-098 and above (e.g.,
SYSFS becomes ATTRS). Prevents warnings, and support for the old
matches will be removed eventually. These rules will not work with
udev-097 and before!
* Fixed several bugs in the rules left over from previous udev
versions (missing commas, overwriting user symlinks using ="..."
instead of +="...", and matching against "*" instead of "?*").
* Renamed CHANGELOG to ChangeLog, started using pseudo-GNU-format
entries. (See standards.info; search it for "changelog" to get
the general gist.)
dnicholson - Jul 14, 2006
* Fixed usbdev PROGRAM so that it works with the BusyBox sh. Thanks
to Anthony Wright.
n/a - Jul 12, 2006
* Added options so temporary nodes are not created with device-mapper
* Adapted cdrom rules to identify CD-ROM drives correctly by adding
SUBSYSTEM=="block" test.
* Added simple 81-cdrom.rules file to set cdrom group ownership
n/a - Jun 07, 2006
* Removed nvidia rules
* Removed bug reporting rule
* Moved Debian-based persistent CD-ROM rules to contrib
* Adapted firmware rule to udev-093
n/a - May 15, 2006
* Part one of 25-lfs.rules rewrite
* Some minor tweaking of the layout
n/a - May 12, 2006
* Initial import of the udev-config directory.
* Reorganized and modularized the rules files.
* Added explanatory comments

View File

@ -1,338 +0,0 @@
# Custom systemd Makefile that builds/installs udev only for LFS
# Bruce Dubbs 2012-07-11
# vim: tabstop=3
SHELL=/bin/bash
SYSTEMD_VERSION=197
VERSION=197-2
ifeq ($(V),)
VB = @
else
VB =
endif
WARN = -Wall -W -Wextra -Wno-inline -Wvla -Wundef -Wformat=2 \
-Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs \
-Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self \
-Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes \
-Wstrict-prototypes -Wredundant-decls -Wmissing-declarations \
-Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align \
-Wstrict-aliasing=2 -Wwrite-strings -Wno-overlength-strings \
-Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result \
-Werror=overflow -Wp,-D_FORTIFY_SOURCE=2 -Wno-long-long
OPTIONS = -O2 -pipe -ffast-math -fno-common -fdiagnostics-show-option \
-fno-strict-aliasing -ffunction-sections -fdata-sections -fPIC
OPTIONS2 := $(OPTIONS) -fvisibility=hidden
LDFLAGS = -pthread -lrt -Wl,--as-needed -Wl,--gc-sections
LDFLAGS2 := $(LDFLAGS) -lblkid -lkmod
DEF = -include cfg.h \
-DSYSCONFDIR=\"/etc\" \
-DFIRMWARE_PATH="\"/lib/firmware/updates/\", \"/lib/firmware/\"" \
-DHWDB_BIN=\"/etc/udev/hwdb.bin\" \
-DROOTPREFIX= \
-DUDEVLIBEXECDIR=\"/lib/udev\" \
-D_LARGEFILE_SOURCE \
-D_FILE_OFFSET_BITS=64
INCLUDE = -I src/libudev -I src/shared -I src -I src/login -I src/systemd
LIBUDEV_SRCS = libudev-device-private.c \
libudev-device.c \
libudev-enumerate.c \
libudev-hwdb.c \
libudev-list.c \
libudev-monitor.c \
libudev-queue-private.c \
libudev-queue.c \
libudev-util.c \
libudev.c
LIBUDEV_OBJS := $(addprefix build/, $(LIBUDEV_SRCS:.c=.o))
LIBUDEV = libudev
LIBUDEV_MAJOR = .1
LIBUDEV_MINOR = .0
LIBUDEV_PATCH = .2
LIBUDEV_SONAME := $(LIBUDEV).so
LIBUDEV_LINK_NAME := $(LIBUDEV_SONAME)$(LIBUDEV_MAJOR)
LIBUDEV_REAL_NAME := $(LIBUDEV_LINK_NAME)$(LIBUDEV_MINOR)$(LIBUDEV_PATCH)
COMMON_LIB = udev-local.a
COMMON_SRCS = log.c \
label.c \
mkdir.c \
cgroup-util.c \
strv.c \
strbuf.c \
path-util.c \
conf-files.c \
hashmap.c \
set.c \
exit-status.c \
util.c \
dev-setup.c \
sd-login.c \
sd-daemon.c \
time-util.c
COMMON_OBJS := $(addprefix build/, $(COMMON_SRCS:.c=.o))
UDEVD_SRCS = udev-ctrl.c \
udev-rules.c \
udev-watch.c \
udev-event.c \
udev-node.c \
udev-builtin.c \
udev-builtin-blkid.c \
udev-builtin-firmware.c \
udev-builtin-path_id.c \
udev-builtin-hwdb.c \
udev-builtin-kmod.c \
udev-builtin-uaccess.c \
udev-builtin-net_id.c \
udev-builtin-usb_id.c \
udev-builtin-input_id.c \
udev-builtin-btrfs.c
UDEVD_OBJS := $(addprefix build/, $(UDEVD_SRCS:.c=.o))
UDEV_ADMIN_SRCS = udevadm.c \
udevadm-test.c \
udevadm-monitor.c \
udevadm-settle.c \
udevadm-hwdb.c \
udevadm-info.c \
udevadm-test-builtin.c \
udevadm-trigger.c \
udevadm-control.c \
udev-rules.c \
udev-ctrl.c \
udev-event.c \
udev-node.c \
udev-watch.c \
udev-builtin.c \
udev-builtin-blkid.c \
udev-builtin-firmware.c \
udev-builtin-path_id.c \
udev-builtin-hwdb.c \
udev-builtin-kmod.c \
udev-builtin-uaccess.c \
udev-builtin-net_id.c \
udev-builtin-usb_id.c \
udev-builtin-input_id.c \
udev-builtin-btrfs.c
UDEV_ADMIN_OBJS := $(addprefix build/, $(UDEV_ADMIN_SRCS:.c=.o))
LFS_RULES = 55-lfs.rules
VPATH = src/login src/udev src/udev/accelerometer \
src/udev/scsi_id src/udev/cdrom_id src/udev/v4l_id \
src/udev/mtd_probe src/udev/collect src/udev/ata_id \
src/libudev src/libsystemd-daemon
SED_PROCESS = \
sed -e 's|@VERSION@|$(SYSTEMD_VERSION)|g' \
-e 's|@prefix@|/usr|g' \
-e 's|@exec_prefix@|/usr|g' \
-e 's|@udevlibexecdir@|/lib/udev|g' \
-e 's|@libdir@|/usr/lib|g' \
-e 's|@includedir@|/usr/include|g' \
< $< > $@
SECURE = $(shell if nm /lib/libc.so.6 | grep -q " secure_getenv"; \
then echo yes; fi)
ifeq "$(SECURE)" "yes"
SECURE_GETENV = SECURE_GETENV
else
SECURE_GETENV = __SECURE_GETENV
endif
udev: common \
build/$(COMMON_LIB) \
build/$(LIBUDEV_REAL_NAME) \
build/udevd \
build/udevadm \
build/accelerometer \
build/ata_id \
build/cdrom_id \
build/scsi_id \
build/v4l_id \
build/mtd_probe \
build/collect \
build/udev.pc \
build/libudev.pc
cfg.h: udev-lfs-$(VERSION)/cfg.h
sed -e 's/LFS-VERSION/$(SYSTEMD_VERSION)/' \
-e 's/SECURE_GETENV/$(SECURE_GETENV)/' \
udev-lfs-$(VERSION)/cfg.h > ./cfg.h
@mkdir -p build
common: cfg.h
@touch common
build/%o: %c common
@echo CC $<
$(VB)gcc -c $(WARN) $(OPTIONS2) $(INCLUDE) $(DEF) -o $@ $<
# Sources from src/libudev use -fvisibility=hidden
build/%o: src/libudev/%c common
@echo CC $<
$(VB)gcc -c $(WARN) $(OPTIONS) $(INCLUDE) $(DEF) -o $@ $<
# Sources from src/shared use -fvisibility=hidden
build/%o: src/shared/%c common
@echo CC $<
$(VB)gcc -c $(WARN) $(OPTIONS) $(INCLUDE) $(DEF) -o $@ $<
# Build the dynamic library
build/$(LIBUDEV_REAL_NAME): $(LIBUDEV_OBJS) build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc -shared -fPIC -DPIC \
$(LIBUDEV_OBJS) \
build/$(COMMON_LIB) \
-Wl,--no-whole-archive -ldl -lrt -O2 \
-Wl,--as-needed \
-Wl,--gc-sections \
-Wl,-soname,$(LIBUDEV_LINK_NAME) \
-o build/$(LIBUDEV_REAL_NAME)
ln -sfn $(LIBUDEV_REAL_NAME) build/$(LIBUDEV_LINK_NAME)
ln -sfn $(LIBUDEV_REAL_NAME) build/$(LIBUDEV_SONAME)
#-Wl,--whole-archive \
#-Wl,--version-script=./src/libudev/libudev.sym \
# Build the static library for internal use
build/$(COMMON_LIB): $(COMMON_OBJS) $(LIBUDEV_OBJS) $(UDEVD_OBJS)
@echo AR $@
$(VB)ar rcs build/$(COMMON_LIB) $(COMMON_OBJS) $(LIBUDEV_OBJS)
build/udevd: build/$(COMMON_LIB) build/udevd.o
@echo LINK $@
$(VB)gcc build/udevd.o $(UDEVD_OBJS) -o $@ $(LDFLAGS2) \
build/udev-local.a build/$(COMMON_LIB)
$(VB)strip --strip-unneeded $@
build/udevadm: $(UDEV_ADMIN_OBJS) build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc $(UDEV_ADMIN_OBJS) -o $@ $(LDFLAGS2) build/$(COMMON_LIB)
$(VB)strip --strip-unneeded $@
build/accelerometer: build/accelerometer.o build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc build/accelerometer.o -o $@ \
build/udev-local.a build/$(COMMON_LIB) $(LDFLAGS) -lm
$(VB)strip --strip-unneeded $@
build/scsi_id: build/scsi_id.o build/scsi_serial.o build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc build/scsi_id.o build/scsi_serial.o -o $@ \
build/udev-local.a build/$(COMMON_LIB) $(LDFLAGS)
$(VB)strip --strip-unneeded $@
build/ata_id: build/ata_id.o build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc build/ata_id.o -o $@ build/udev-local.a build/$(COMMON_LIB) $(LDFLAGS)
$(VB)strip --strip-unneeded $@
build/cdrom_id: build/cdrom_id.o build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc build/cdrom_id.o -o $@ build/udev-local.a build/$(COMMON_LIB) $(LDFLAGS)
$(VB)strip --strip-unneeded $@
build/v4l_id: build/v4l_id.o build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc build/v4l_id.o -o $@ build/udev-local.a build/$(COMMON_LIB) $(LDFLAGS)
$(VB)strip --strip-unneeded $@
build/mtd_probe: build/mtd_probe.o build/probe_smartmedia.o build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc build/mtd_probe.o build/probe_smartmedia.o -o $@ \
build/udev-local.a build/$(COMMON_LIB) $(LDFLAGS)
$(VB)strip --strip-unneeded $@
build/collect: build/collect.o build/$(COMMON_LIB)
@echo LINK $@
$(VB)gcc build/collect.o -o $@ build/udev-local.a build/$(COMMON_LIB) $(LDFLAGS)
$(VB)strip --strip-unneeded $@
build/%pc: %pc.in common
@echo GEN $@
@$(SED_PROCESS)
install: udev
@mkdir -pv $(DESTDIR)/lib/udev/devices/pts $(DESTDIR)/lib/udev/rules.d \
$(DESTDIR){,/usr}/lib/firmware $(DESTDIR)/sbin \
$(DESTDIR)/usr/lib/pkgconfig $(DESTDIR)/etc/udev/rules.d \
$(DESTDIR)/usr/share/doc/udev/lfs $(DESTDIR)/usr/include \
$(DESTDIR)/usr/share/man/man{7,8}
# Copy executables
@cp -v build/udevadm $(DESTDIR)/sbin
@cp -v build/{udevd,accelerometer,ata_id,cdrom_id,collect,mtd_probe,scsi_id,v4l_id} \
$(DESTDIR)/lib/udev
@cp -v udev-lfs-$(VERSION)/write* $(DESTDIR)/lib/udev
@cp -v udev-lfs-$(VERSION)/*functions $(DESTDIR)/lib/udev
# Copy and set up library and associated files
@cp -v build/{lib,}udev.pc $(DESTDIR)/usr/lib/pkgconfig
@cp -v build/$(LIBUDEV_REAL_NAME) $(DESTDIR)/lib
ln -svfn ../../lib/$(LIBUDEV_REAL_NAME) $(DESTDIR)/usr/lib/$(LIBUDEV_SONAME)
ln -svfn $(LIBUDEV_REAL_NAME) $(DESTDIR)/lib/$(LIBUDEV_LINK_NAME)
# Copy the libudev header
@cp -v src/libudev/libudev.h $(DESTDIR)/usr/include
# Create null device and copy rules
@cp -v rules/* $(DESTDIR)/lib/udev/rules.d
@rm -v $(DESTDIR)/lib/udev/rules.d/99*
@cp -v udev-lfs-$(VERSION)/*.rules $(DESTDIR)/etc/udev/rules.d
# Set up hardware DB
@mkdir -pv $(DESTDIR)/lib/udev/hwdb.d
@cp hwdb/* $(DESTDIR)/lib/udev/hwdb.d
# @build/udevadm hwdb --update
# Copy documentation
@cp -v man/udev.7 $(DESTDIR)/usr/share/man/man7
@cp -v man/udevadm.8 $(DESTDIR)/usr/share/man/man8
@cp -v udev-lfs-$(VERSION)/udevd.8 $(DESTDIR)/usr/share/man/man8
@cp -v udev-lfs-$(VERSION)/README $(DESTDIR)/usr/share/doc/udev/lfs
@cp -v udev-lfs-$(VERSION)/*.txt $(DESTDIR)/usr/share/doc/udev/lfs
# Copy misc
@cp -v udev-lfs-$(VERSION)/init-net-rules.sh $(DESTDIR)/lib/udev
include udev-lfs-$(VERSION)/makefile-incl.gudev
include udev-lfs-$(VERSION)/makefile-incl.gir
include udev-lfs-$(VERSION)/makefile-incl.keymap
all : udev keymap gudev gir-data
install-all: install install-keymap install-gudev install-gir-data
clean:
rm -rf build
rm -f cfg.h
rm -f common
rm -f src/gudev/gudevmarshal.h
rm -f src/gudev/gudevmarshal.c
rm -f src/gudev/gudevenumtypes.h
rm -f src/gudev/gudevenumtypes.c
rm -f src/udev/keymap/keys.txt
rm -f src/udev/keymap/keys-from-name.gperf
rm -f src/udev/keymap/keys-from-name.h
rm -f src/udev/keymap/keys-to-name.h
.PHONY: clean

View File

@ -1,40 +0,0 @@
The udev-lfs set of files is a customization of systemd.
In 2012, udev was merged with systemd and a build methodology
incompatible with LFS. These files extract the udev
code from systemd for LFS.
These files are distributed in the form of a tar file available
from the LFS file mirrors. The tarball is created with:
mkdir /tmp/udev-lfs-$VERSION
cp -av * /tmp/udev-lfs-$VERSION
tar -jcf /tmp/udev-lfs-$VERSION.tar.bz2 -C /tmp udev-lfs-$VERSION
Makefile.lfs - The main LFS Makefile. Builds and installs
udev from systemd sources.
makefile-incl.keymap - BLFS makefile for keymap and supporting files
makefile-incl.gudev - BLFS makefile for libgudev
makefile-incl.gir - BLFS makefile for GObject files
contrib - Useful rules from debian
contrib/debian
contrib/debian/83-cdrom-symlinks.rules
contrib/debian/write_cd_aliases
contrib/debian/81-cdrom.rules
55-lfs.rules - LFS custom rules
write_net_rules - Scripts for LFS rules
write_cd_rules
rule_generator.functions
55-lfs.txt - Documentation for LFS installed rules
cfg.h - Basic info needed for udev compilation
ChangeLog - Log of changes to 55-lfs-rules
init-net-rules.sh - A script for establishing persistent network
rules before the first LFS boot

View File

@ -1,64 +0,0 @@
/* Custom udev (from systemd) configuration header file for LFS */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define if kmod is available */
#define HAVE_KMOD 1
/* Define if blkid is available */
#define HAVE_BLKID 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `secure_getenv' function. */
/* For glibc before 2.17, this should be HAVE___SECURE_GETENV */
#define HAVE_SECURE_GETENV 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the declaration of `name_to_handle_at', and to 0 if
* you don't. */
#define HAVE_DECL_NAME_TO_HANDLE_AT 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if XZ is available */
#define HAVE_XZ 1
/* Name of package */
#define PACKAGE "udev"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Enable GNU extensions on systems that have them. */
# define _GNU_SOURCE 1
/* Version number of package */
#define VERSION "LFS-VERSION"
#define HAVE_DECL_PIVOT_ROOT 0
#define HAVE_DECL_GETTID 0
#define HAVE_NAME_TO_HANDLE_AT 1

View File

@ -1,3 +0,0 @@
# /etc/udev/rules.d/81-cdrom.rules: Set CD-ROM permissions and get device capabilities
ACTION=="add", SUBSYSTEM=="block", ENV{ID_TYPE}=="cd", IMPORT{program}="cdrom_id --export $tempnode", GROUP="cdrom"

View File

@ -1,12 +0,0 @@
# /etc/udev/rules.d/83-cdrom-symlinks.rules: Determine CD drive capability.
ACTION!="add", GOTO="cd_aliases_generator_end"
SUBSYSTEM!="block", GOTO="cd_aliases_generator_end"
ENV{GENERATED}=="?*", GOTO="cd_aliases_generator_end"
# Fail the uevent if the autogenerated rules cannot be saved
ENV{ID_CDROM}=="?*", PROGRAM="/bin/grep -c ' / [^[:space:]]* rw' /proc/mounts", RESULT!="2", RUN+="/bin/false", GOTO="cd_aliases_generator_end"
ENV{ID_CDROM}=="?*", PROGRAM="write_cd_aliases", SYMLINK+="%c"
LABEL="cd_aliases_generator_end"

View File

@ -1,120 +0,0 @@
#!/bin/sh -e
# Updated for LFS by B. Dubbs, 2012-09-23
# Fix RULES_LOCK location
RULES_FILE="/etc/udev/rules.d/82-persistent-cd.rules"
##############################################################################
lock_rules_file() {
RULES_LOCK="/run/udev/lock-${RULES_FILE##*/}"
if [ ! -d /run/udev/ ]; then
echo "write_cd_aliases: /run/udev does not exist!" >&2
exit 2
fi
retry=10
while ! mkdir $RULES_LOCK 2> /dev/null; do
if [ $retry -eq 0 ]; then
echo "Cannot lock $RULES_FILE!" >&2
exit 2
fi
sleep 1
retry=$(($retry - 1))
done
}
unlock_rules_file() {
rmdir $RULES_LOCK || true
}
##############################################################################
find_next_available() {
# use echo to convert newlines to spaces
local links=`echo $(find_all_symlinks $1)`
local basename=${links%%[ 0-9]*}
local max=-1
for name in $links; do
local num=${name#$basename}
[ "$num" ] || num=0
[ $num -gt $max ] && max=$num
done
max=$(($max + 1))
# "name0" actually is just "name"
[ $max -eq 0 ] && return
echo "$max"
}
find_all_symlinks() {
local linkre="$1"
local match="$2"
[ -e $RULES_FILE ] || return
local search='.*[[:space:],]SYMLINK+="\('"$linkre"'\)"[[:space:]]*\(,.*\|\\\|\)$'
sed -n -e "${match}s/${search}/\1/p" $RULES_FILE
}
write_rule() {
local match="$1"
local link="$2"
local comment="$3"
[ -e "$RULES_FILE" ] || PRINT_HEADER=1
{
if [ "$PRINT_HEADER" ]; then
PRINT_HEADER=
echo "# This file was automatically generated by the $0"
echo "# program, probably run by the 83-cdrom.rules rules file."
echo "#"
echo "# You can modify it, as long as you keep each rule on a single line"
echo "# and set the \$GENERATED variable."
echo ""
fi
[ "$comment" ] && echo "# $comment"
echo "ACTION==\"add\", SUBSYSTEM==\"block\", $match, ENV{ID_CDROM}==\"1\", SYMLINK+=\"$link\", ENV{GENERATED}=\"1\""
} >> $RULES_FILE
SYMLINKS="$SYMLINKS $link"
}
##############################################################################
if [ -z "$DEVPATH" ]; then
echo "Missing \$DEVPATH." >&2
exit 1
fi
if [ -z "$ID_CDROM" ]; then
echo "$DEVPATH is not a CD reader." >&2
exit 1
fi
# Prevent parallel processes from modifying the file at the same time.
lock_rules_file
link_num=$(find_next_available 'cdrom[0-9]*')
#match="ENV{ID_PATH}==\"$ID_PATH\""
#kernel=${DEVPATH##*/}
#match="KERNEL==\"$kernel\""
id=${PHYSDEVPATH##*/}
match="BUS==\"$PHYSDEVBUS\", ID==\"$id\""
comment="$ID_MODEL ($ID_PATH)"
write_rule "$match" "cdrom$link_num" "$comment"
[ "$ID_CDROM_CD_RW" ] && write_rule "$match" "cdrw$link_num"
[ "$ID_CDROM_DVD" ] && write_rule "$match" "dvd$link_num"
[ "$ID_CDROM_DVD_RW" ] && write_rule "$match" "dvdrw$link_num"
unlock_rules_file
echo $SYMLINKS
exit 0

View File

@ -1,129 +0,0 @@
#! /bin/bash
# This script generates rules for persistent network device naming
# Data from udev-182 75-persistent-net-generator.rules
# Updated fof udev-197 (DEVICES=en*)
RULES=/etc/udev/rules.d/70-persistent-net.rules
DEVICES=$(eval echo /sys/class/net/{en*,eth*,ath*,wlan*[0-9],msh*,ra*,sta*,ctc*,lcs*,hsi*})
function usage
{
echo $msg
echo "init-net-rules.sh is an LFS-specific script to initialize"
echo "$RULES"
exit 1
}
declare -A VENDORS_IGNORED
VENDORS_IGNORED['52:54:00:']="kvm"
VENDORS_IGNORED['00:0c:29:']="vmware"
VENDORS_IGNORED['00:50:56:']="vmware"
VENDORS_IGNORED['00:15:5d:']="hyper-v"
VENDORS_IGNORED['00:00:00:']="invalid"
declare -A VENDORS
VENDORS['02:07:01:']="Interlan, DEC, etc"
VENDORS['02:60:60:']="3com"
VENDORS['02:60:8c:']="3Com IBM PC; Imagen. etc"
VENDORS['02:a0:c9:']="intel"
VENDORS['02:aa:3c:']="Olivetti"
VENDORS['02:cf:1f:']="Masscomp, Silicon Graphics, etc"
VENDORS['02:e0:3b:']="Gigabit"
VENDORS['02:e6:d3:']="BTI"
VENDORS['52:54:00:']="Realtek"
VENDORS['52:54:4c:']="Novell"
VENDORS['52:54:ab:']="Realtek"
VENDORS['e2:0c:0f:']="Kingston"
VENDORS['00:16:3e:']="Xensource"
function ignore_if
{
if [[ "${VENDORS_IGNORED[$VENDOR]}" != "" ]]; then return 0; fi
if [[ "${VENDORS[$VENDOR]}" != "" ]]; then return 1; fi
byte2=$(echo $VENDOR | cut -c2)
if echo $byte2 | grep -q "[2367abef]"; then return 0; fi
return 1 # Default is to not ignore
}
function comment
{
# Not implemented
# SUBSYSTEMS=="pci"
# export COMMENT="PCI device $attr{vendor}:$attr{device} ($driver)"
# SUBSYSTEMS=="usb", ATTRS{idVendor}=="?*"
# export COMMENT="USB device 0x$attr{idVendor}:0x$attr{idProduct} ($driver)"
# SUBSYSTEMS=="pcmcia",
# export COMMENT="PCMCIA device $attr{card_id}:$attr{manf_id} ($driver)"
# SUBSYSTEMS=="ieee1394",
# export COMMENT="Firewire device $attr{host_id})"
# ibmveth likes to use "locally administered" MAC addresses
# DRIVERS=="ibmveth",
# export COMMENT="ibmveth ($id)"
# S/390 uses id matches only, do not use MAC address match
# SUBSYSTEMS=="ccwgroup",
# export COMMENT="S/390 $driver device at $id",
# export MATCHID="$id"
# export MATCHDRV="$driver"
# export MATCHADDR=""
# Default
driver=$(basename $(readlink -f $NIC/device/driver/module))
export COMMENT="net device ${driver}"
}
if ! mountpoint -q /sys; then
msg="/sys mut be mounted"
usage
fi
if ! mountpoint -q /proc; then
msg="/proc mut be mounted"
usage
fi
if [ -e $RULES ]; then
msg="The rules file already exists"
usage
fi
# Ignore Xen virtual interfaces
if [ -e /proc/xen ]; then
msg="The rules file should not be created in the Xen environment"
usage
fi
# Variables used to communicate with write_net_rules:
# INTERFACE simple interface name
# MATCHADDR MAC address used for the match
# MATCHID bus_id used for the match
# MATCHDRV driver name used for the match
# MATCHIFTYPE interface type match
# COMMENT comment to add to the generated rule
# INTERFACE_NAME requested name supplied by external tool
# INTERFACE_NEW new interface name returned by rule writer
for NIC in $DEVICES; do
IF=${NIC##*/}
if echo $NIC | grep -q '*' ; then continue; fi
export INTERFACE=${NIC##*/} # Simple interface name
export MATCHADDR="$(cat $NIC/address)" # Read MAC address
VENDOR=$(echo $MATCHADDR | cut -c-9)
if ignore_if; then continue; fi
export MATCHDEVID="$(cat $NIC/dev_id)"
export MATCHIFTYPE="$(cat $NIC/type)" # Read interface type
comment
/lib/udev/write_net_rules
done

View File

@ -1,51 +0,0 @@
# Custom systemd Makefile include that builds/installs gir only for LFS
# vim: tabstop=3
G_IR_INCLUDES = \
src/gudev/gudev.h \
src/gudev/gudevtypes.h \
src/gudev/gudevenums.h \
src/gudev/gudevenumtypes.h \
src/gudev/gudevclient.h \
src/gudev/gudevdevice.h \
src/gudev/gudevenumerator.h \
src/gudev/gudevclient.c \
src/gudev/gudevdevice.c \
src/gudev/gudevenumerator.c
build/GUdev-1.0.gir: gudev
@echo G-IR-SCANNER $@
$(VB)LD_LIBRARY_PATH=./build g-ir-scanner \
$(G_IR_INCLUDES) \
-D_GUDEV_COMPILATION \
-D_GUDEV_WORK_AROUND_DEV_T_BUG \
-I src -I src/gudev \
-L./build -lgudev-1.0 -ludev \
--quiet \
--warn-all \
--no-libtool \
--include=GObject-2.0 \
--pkg-export=gudev-1.0 \
--c-include=gudev/gudev.h \
--library=gudev-1.0 \
--namespace=GUdev \
--nsversion=1.0 \
--output=$@
build/GUdev-1.0.typelib: build/GUdev-1.0.gir
@echo G-IR-COMPILER $@
$(VB)LIBRARY_PATH=./build g-ir-compiler $< > $@
gir-data: build/GUdev-1.0.gir build/GUdev-1.0.typelib
install-gir-data: gir-data
@mkdir -pv $(DESTDIR)/usr/lib/girepository-1.0 \
$(DESTDIR)/usr/share/gir-1.0
@cp -v build/GUdev-1.0.typelib $(DESTDIR)/usr/lib/girepository-1.0
@cp -v build/GUdev-1.0.gir $(DESTDIR)/usr/share/gir-1.0
clean-gir-data:
rm -f build/GUdev-1.0.typelib
rm -f build/GUdev-1.0.gir

View File

@ -1,108 +0,0 @@
# Custom systemd Makefile include that builds/installs gudev only for LFS
# vim: tabstop=3
LIBGUDEV_SRCS = \
gudevclient.c \
gudevdevice.c \
gudevenumerator.c \
gudevenumtypes.c \
gudevmarshal.c
LIBGUDEV_INCLUDES = \
src/gudev/gudev.h \
src/gudev/gudevenums.h \
src/gudev/gudevenumtypes.h \
src/gudev/gudevtypes.h \
src/gudev/gudevclient.h \
src/gudev/gudevdevice.h \
src/gudev/gudevenumerator.h
LIBGUDEV_OBJS := $(addprefix build/, $(LIBGUDEV_SRCS:.c=.o))
LIBGUDEV_CFLAGS = \
-I src/gudev \
-D_POSIX_PTHREAD_SEMANTICS \
-D_REENTRANT \
-D_GUDEV_COMPILATION \
-DG_LOG_DOMAIN=\"GUdev\" \
-fvisibility=default \
-I /usr/include/glib-2.0 \
-I /usr/lib/glib-2.0/include
LIBGUDEV_LDFLAGS = \
-L build -L /usr/lib \
-ludev -lgobject-2.0 \
-lglib-2.0
GUDEV_GENERATED = \
src/gudev/gudevmarshal.h \
src/gudev/gudevmarshal.c \
src/gudev/gudevenumtypes.h \
src/gudev/gudevenumtypes.c
LIBGUDEV = libgudev-1.0
LIBGUDEV_MAJOR = .0
LIBGUDEV_MINOR = .1
LIBGUDEV_PATCH = .2
LIBGUDEV_SONAME := $(LIBGUDEV).so
LIBGUDEV_LINK_NAME := $(LIBGUDEV_SONAME)$(LIBGUDEV_MAJOR)
LIBGUDEV_REAL_NAME := $(LIBGUDEV_LINK_NAME)$(LIBGUDEV_MINOR)$(LIBGUDEV_PATCH)
src/gudev/gudevmarshal.h: src/gudev/gudevmarshal.list
@echo GEN $@
$(VB)glib-genmarshal $< --prefix=g_udev_marshal --header > $@
src/gudev/gudevmarshal.c: src/gudev/gudevmarshal.list
@echo GEN $@
@echo "#include \"gudevmarshal.h\"" > $@
$(VB)glib-genmarshal $< --prefix=g_udev_marshal --body >> $@
src/gudev/gudevenumtypes.h: src/gudev/gudevenumtypes.h.template src/gudev/gudevenums.h
@echo GEN $@
$(VB)glib-mkenums --template $^ > $@
src/gudev/gudevenumtypes.c: src/gudev/gudevenumtypes.c.template src/gudev/gudevenums.h
@echo GEN $@
$(VB)glib-mkenums --template $^ > $@
build/%o: src/gudev/%c $(GUDEV_GENERATED) common
@echo CC $<
$(VB)gcc -c $(LIBGUDEV_CFLAGS) $(WARN) $(OPTIONS) $(INCLUDE) $(DEF) -o $@ $<
build/$(LIBGUDEV_REAL_NAME): $(LIBGUDEV_OBJS) build/udev-local.a build/$(LIBUDEV_REAL_NAME)
@echo LINK $@
$(VB)gcc -shared -Wl,--export-dynamic -Wl,-soname,$(LIBGUDEV_LINK_NAME) \
-o build/$(LIBGUDEV_REAL_NAME) $(LIBGUDEV_OBJS) $(LIBGUDEV_LDFLAGS)
ln -sfn $(LIBGUDEV_REAL_NAME) build/$(LIBGUDEV_LINK_NAME)
ln -sfn $(LIBGUDEV_REAL_NAME) build/$(LIBGUDEV_SONAME)
build/gudev-1.0.pc: src/gudev/gudev-1.0.pc.in common
@echo GEN $@
@$(SED_PROCESS)
gudev: build/$(LIBGUDEV_REAL_NAME) build/gudev-1.0.pc
clean-gudev:
rm -f src/gudev/gudevmarshal.h
rm -f src/gudev/gudevmarshal.c
rm -f src/gudev/gudevenumtypes.h
rm -f src/gudev/gudevenumtypes.c
rm -f $(LIBGUDEV_OBJS)
rm -f build/libgudev-1.0.so*
install-gudev: gudev
@mkdir -pv $(DESTDIR)/usr/include/gudev-1.0/gudev \
$(DESTDIR)/usr/lib/pkgconfig \
$(DESTDIR)/usr/share/gtk-doc/html/gudev
@cp -v $(LIBGUDEV_INCLUDES) $(DESTDIR)/usr/include/gudev-1.0/gudev
@cp -v build/$(LIBGUDEV_REAL_NAME) $(DESTDIR)/usr/lib
@ln -svfn $(LIBGUDEV_REAL_NAME) $(DESTDIR)/usr/lib/$(LIBGUDEV_SONAME)
@ln -svfn $(LIBGUDEV_REAL_NAME) $(DESTDIR)/usr/lib/$(LIBGUDEV_LINK_NAME)
@cp -v build/gudev-1.0.pc $(DESTDIR)/usr/lib/pkgconfig
@cp -v docs/gudev/html/* $(DESTDIR)/usr/share/gtk-doc/html/gudev

View File

@ -1,151 +0,0 @@
# Custom systemd Makefile include that builds/installs keymap tool only for LFS
# vim: tabstop=3
KEYMAPS = \
keymaps/acer \
keymaps/acer-aspire_5720 \
keymaps/acer-aspire_8930 \
keymaps/acer-aspire_5920g \
keymaps/acer-aspire_6920 \
keymaps/acer-travelmate_c300 \
keymaps/asus \
keymaps/compaq-e_evo \
keymaps/dell \
keymaps/dell-latitude-xt2 \
keymaps/everex-xt5000 \
keymaps/fujitsu-amilo_li_2732 \
keymaps/fujitsu-amilo_pa_2548 \
keymaps/fujitsu-amilo_pro_edition_v3505 \
keymaps/fujitsu-amilo_pro_v3205 \
keymaps/fujitsu-amilo_si_1520 \
keymaps/fujitsu-esprimo_mobile_v5 \
keymaps/fujitsu-esprimo_mobile_v6 \
keymaps/genius-slimstar-320 \
keymaps/hewlett-packard \
keymaps/hewlett-packard-2510p_2530p \
keymaps/hewlett-packard-compaq_elitebook \
keymaps/hewlett-packard-pavilion \
keymaps/hewlett-packard-presario-2100 \
keymaps/hewlett-packard-tablet \
keymaps/hewlett-packard-tx2 \
keymaps/ibm-thinkpad-usb-keyboard-trackpoint \
keymaps/inventec-symphony_6.0_7.0 \
keymaps/lenovo-3000 \
keymaps/lenovo-ideapad \
keymaps/lenovo-thinkpad-usb-keyboard-trackpoint \
keymaps/lenovo-thinkpad_x6_tablet \
keymaps/lenovo-thinkpad_x200_tablet \
keymaps/lg-x110 \
keymaps/logitech-wave \
keymaps/logitech-wave-cordless \
keymaps/logitech-wave-pro-cordless \
keymaps/maxdata-pro_7000 \
keymaps/medion-fid2060 \
keymaps/medionnb-a555 \
keymaps/micro-star \
keymaps/module-asus-w3j \
keymaps/module-ibm \
keymaps/module-lenovo \
keymaps/module-sony \
keymaps/module-sony-old \
keymaps/module-sony-vgn \
keymaps/olpc-xo \
keymaps/onkyo \
keymaps/oqo-model2 \
keymaps/samsung-other \
keymaps/samsung-90x3a \
keymaps/samsung-sq1us \
keymaps/samsung-sx20s \
keymaps/toshiba-satellite_a100 \
keymaps/toshiba-satellite_a110 \
keymaps/toshiba-satellite_m30x \
keymaps/zepto-znote
KEYMAPS_FR = \
keymaps-force-release/dell-touchpad \
keymaps-force-release/dell-xps \
keymaps-force-release/hp-other \
keymaps-force-release/samsung-other \
keymaps-force-release/samsung-90x3a \
keymaps-force-release/common-volume-keys
KEYMAP_DEPS = common src/udev/keymap/keys-from-name.h src/udev/keymap/keys-to-name.h
src/udev/keymap/keys.txt:
@echo GEN $@
$(VB)awk '/^#define.*KEY_[^ ]+[ \t]+[0-9]/ \
{ \
if ($$2 != "KEY_MAX") { print $$2 } \
}' \
/usr/include/linux/input.h | sed 's/^KEY_COFFEE$$/KEY_SCREENLOCK/' > $@
src/udev/keymap/keys-from-name.gperf: src/udev/keymap/keys.txt
@echo GEN $@
$(VB)awk 'BEGIN \
{ \
print "struct key \
{ \
const char* name; \
unsigned short id; \
};"; \
\
print "%null-strings"; print "%%"; \
} \
{ \
print $$1 ", " $$1 \
}' $< > $@
src/udev/keymap/keys-from-name.h: src/udev/keymap/keys-from-name.gperf
@echo GEN $@
$(VB)gperf -L ANSI-C -t --ignore-case -N lookup_key -H hash_key_name -p -C $< > $@
src/udev/keymap/keys-to-name.h: src/udev/keymap/keys.txt
@echo GEN $@
$(VB)awk 'BEGIN \
{ \
print "const char* const key_names[KEY_CNT] = { " \
} \
{ \
print "[" $$1 "] = \"" $$1 "\"," \
} \
END{print "};" \
}' $< > $@
build/keymap: src/udev/keymap/keymap.c build/$(COMMON_LIB) $(KEYMAP_DEPS)
@echo LINK $@
$(VB)gcc $< -o $@ -I src/udev/keymap $(WARN) $(OPTIONS2) $(INCLUDE) $(DEF) \
build/$(COMMON_LIB) $(LDFLAGS)
$(VB)strip --strip-unneeded $@
keymap: build/keymap
install-keymap: keymap
@mkdir -pv $(DESTDIR)/lib/udev/keymaps/force-release \
$(DESTDIR)/lib/udev/rules.d \
$(DESTDIR)/usr/share/doc/udev
@cp -v build/keymap $(DESTDIR)/lib/udev
@cp -v $(KEYMAPS) $(DESTDIR)/lib/udev/keymaps
@cp -v $(KEYMAPS_FR) $(DESTDIR)/lib/udev/keymaps/force-release
@cp -v src/udev/keymap/*.rules $(DESTDIR)/lib/udev/rules.d
@cp -v src/udev/keymap/findkeyboards $(DESTDIR)/lib/udev
@cp -v src/udev/keymap/*.txt $(DESTDIR)/usr/share/doc/udev
@sed -e 's|@udevlibexecdir@|/lib/udev|g' \
src/udev/keymap/keyboard-force-release.sh.in \
> $(DESTDIR)/lib/udev/keyboard-force-release.sh
@chmod 0755 $(DESTDIR)/lib/udev/keyboard-force-release.sh
clean-keymap:
rm -f src/udev/keymap/keys.txt
rm -f src/udev/keymap/keys-from-name.gperf
rm -f src/udev/keymap/keys-from-name.h
rm -f src/udev/keymap/keys-to-name.h
rm -f build/keymap
.PHONY: clean-keymap

View File

@ -1,115 +0,0 @@
# functions used by the udev rule generator
# Copyright (C) 2006 Marco d'Itri <md@Linux.IT>
# Updated for LFS by Bruce Dubbs <bdubbs@linuxfromscratch.org>
# Hardcoded RUNDIR
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PATH='/usr/bin:/bin:/usr/sbin:/sbin'
# Read a single line from file $1 in the $DEVPATH directory.
# The function must not return an error even if the file does not exist.
sysread() {
local file="$1"
[ -e "/sys$DEVPATH/$file" ] || return 0
local value
read value < "/sys$DEVPATH/$file" || return 0
echo "$value"
}
sysreadlink() {
local file="$1"
[ -e "/sys$DEVPATH/$file" ] || return 0
readlink -f /sys$DEVPATH/$file 2> /dev/null || true
}
# Return true if a directory is writeable.
writeable() {
if ln -s test-link $1/.is-writeable 2> /dev/null; then
rm -f $1/.is-writeable
return 0
else
return 1
fi
}
# Create a lock file for the current rules file.
lock_rules_file() {
RUNDIR=/run/udev
[ -e "$RUNDIR" ] || return 0
RULES_LOCK="$RUNDIR/.lock-${RULES_FILE##*/}"
retry=30
while ! mkdir $RULES_LOCK 2> /dev/null; do
if [ $retry -eq 0 ]; then
echo "Cannot lock $RULES_FILE!" >&2
exit 2
fi
sleep 1
retry=$(($retry - 1))
done
}
unlock_rules_file() {
[ "$RULES_LOCK" ] || return 0
rmdir $RULES_LOCK || true
}
# Choose the real rules file if it is writeable or a temporary file if not.
# Both files should be checked later when looking for existing rules.
choose_rules_file() {
RUNDIR=/run/udev
local tmp_rules_file="$RUNDIR/tmp-rules--${RULES_FILE##*/}"
[ -e "$RULES_FILE" -o -e "$tmp_rules_file" ] || PRINT_HEADER=1
if writeable ${RULES_FILE%/*}; then
RO_RULES_FILE='/dev/null'
else
RO_RULES_FILE=$RULES_FILE
RULES_FILE=$tmp_rules_file
fi
}
# Return the name of the first free device.
raw_find_next_available() {
local links="$1"
local basename=${links%%[ 0-9]*}
local max=-1
for name in $links; do
local num=${name#$basename}
[ "$num" ] || num=0
[ $num -gt $max ] && max=$num
done
local max=$(($max + 1))
# "name0" actually is just "name"
[ $max -eq 0 ] && return
echo "$max"
}
# Find all rules matching a key (with action) and a pattern.
find_all_rules() {
local key="$1"
local linkre="$2"
local match="$3"
local search='.*[[:space:],]'"$key"'"('"$linkre"')".*'
echo $(sed -n -r -e 's/^#.*//' -e "${match}s/${search}/\1/p" \
$RO_RULES_FILE \
$([ -e $RULES_FILE ] && echo $RULES_FILE) \
2>/dev/null)
}

View File

@ -1,115 +0,0 @@
.\" Title: systemd-udevd.service
.\" Author: Kay Sievers <kay@vrfy.org>
.\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
.\" Date: 07/20/2012
.\" Manual: systemd-udevd.service
.\" Source: systemd
.\" Language: English
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" Manually updated for udev only for LFS by BRuce Dubbs
.\" <bdubbs@linuxfromscratch.org>
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\"
.TH "UDEVD" "8" "" "systemd (LFS modified man page)" "udevd"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
udevd \- Device event managing daemon
.SH "SYNOPSIS"
.PP
.HP \w'\fB/usr/lib/udevd\fR\ 'u
\fB/lib/udev/udevd\fR [\fB\-\-daemon\fR] [\fB\-\-debug\fR] [\fB\-\-children\-max=\fR] [\fB\-\-exec\-delay=\fR] \ [\fB\-\-resolve\-names=early|late|never\fR] [\fB\-\-version\fR] [\fB\-\-help\fR]
.SH "DESCRIPTION"
.PP
udevd listens to kernel uevents\&. For every event, udevd executes matching instructions specified in udev rules\&. See
\fBudev\fR(7)\&.
.PP
The behavior of the running daemon can be changed with
\fBudevadm control\fR\&.
.SH "OPTIONS"
.PP
\fB\-\-daemon\fR
.RS 4
Detach and run in the background\&.
.RE
.PP
\fB\-\-debug\fR
.RS 4
Print debug messages to stderr\&.
.RE
.PP
\fB\-\-children\-max=\fR
.RS 4
Limit the number of parallel executed events\&.
.RE
.PP
\fB\-\-exec\-delay=\fR
.RS 4
Number of seconds to delay the execution of RUN instructions\&. This might be useful when debugging system crashes during coldplug cause by loading non\-working kernel modules\&.
.RE
.PP
\fB\-\-resolve\-names=\fR
.RS 4
Specify when udevd should resolve names of users and groups\&. When set to
\fBearly\fR
(the default) names will be resolved when the rules are parsed\&. When set to
\fBlate\fR
names will be resolved for every event\&. When set to
\fBnever\fR
names will never be resolved and all devices will be owned by root\&.
.RE
.PP
\fB\-\-version\fR
.RS 4
Print version number\&.
.RE
.PP
\fB\-\-help\fR
.RS 4
Print help text\&.
.RE
.SH "ENVIRONMENT"
.PP
\fIUDEV_LOG=\fR
.RS 4
Set the logging priority\&.
.RE
.SH "KERNEL COMMAND LINE"
.PP
The parameters starting with "rd\&.", will be read when udev is used in an initrd\&.
.PP
\fIudev\&.log\-priority=\fR, \fIrd\&.udev\&.log\-priority=\fR
.RS 4
Set the logging priority\&.
.RE
.PP
\fIudev\&.children\-max=\fR, \fIrd\&.udev\&.children\-max=\fR
.RS 4
Limit the number of parallel executed events\&.
.RE
.PP
\fIudev\&.exec\-delay=\fR, \fIrd\&.udev\&.exec\-delay=\fR
.RS 4
Number of seconds to delay the execution of RUN instructions\&. This might be useful when debugging system crashes during coldplug cause by loading non\-working kernel modules\&.
.RE
.SH "SEE ALSO"
.PP
\fBudev\fR(7),
\fBudevadm\fR(8)

View File

@ -1,126 +0,0 @@
#!/bin/sh -e
# This script is run if an optical drive lacks a rule for persistent naming.
#
# It adds symlinks for optical drives based on the device class determined
# by cdrom_id and used ID_PATH to identify the device.
# (C) 2006 Marco d'Itri <md@Linux.IT>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# debug, if UDEV_LOG=<debug>
if [ -n "$UDEV_LOG" ]; then
if [ "$UDEV_LOG" -ge 7 ]; then
set -x
fi
fi
RULES_FILE="/etc/udev/rules.d/70-persistent-cd.rules"
. /lib/udev/rule_generator.functions
find_next_available() {
raw_find_next_available "$(find_all_rules 'SYMLINK\+=' "$1")"
}
write_rule() {
local match="$1"
local link="$2"
local comment="$3"
{
if [ "$PRINT_HEADER" ]; then
PRINT_HEADER=
echo "# This file was automatically generated by the $0"
echo "# program, run by the cd-aliases-generator.rules rules file."
echo "#"
echo "# You can modify it, as long as you keep each rule on a single"
echo "# line, and set the \$GENERATED variable."
echo ""
fi
[ "$comment" ] && echo "# $comment"
echo "$match, SYMLINK+=\"$link\", ENV{GENERATED}=\"1\""
} >> $RULES_FILE
SYMLINKS="$SYMLINKS $link"
}
if [ -z "$DEVPATH" ]; then
echo "Missing \$DEVPATH." >&2
exit 1
fi
if [ -z "$ID_CDROM" ]; then
echo "$DEVPATH is not a CD reader." >&2
exit 1
fi
if [ "$1" ]; then
METHOD="$1"
else
METHOD='by-path'
fi
case "$METHOD" in
by-path)
if [ -z "$ID_PATH" ]; then
echo "$DEVPATH not supported by path_id. by-id may work." >&2
exit 1
fi
RULE="ENV{ID_PATH}==\"$ID_PATH\""
;;
by-id)
if [ "$ID_SERIAL" ]; then
RULE="ENV{ID_SERIAL}==\"$ID_SERIAL\""
elif [ "$ID_MODEL" -a "$ID_REVISION" ]; then
RULE="ENV{ID_MODEL}==\"$ID_MODEL\", ENV{ID_REVISION}==\"$ID_REVISION\""
else
echo "$DEVPATH not supported by ata_id. by-path may work." >&2
exit 1
fi
;;
*)
echo "Invalid argument (must be either by-path or by-id)." >&2
exit 1
;;
esac
# Prevent concurrent processes from modifying the file at the same time.
lock_rules_file
# Check if the rules file is writeable.
choose_rules_file
link_num=$(find_next_available 'cdrom[0-9]*')
match="SUBSYSTEM==\"block\", ENV{ID_CDROM}==\"?*\", $RULE"
comment="$ID_MODEL ($ID_PATH)"
write_rule "$match" "cdrom$link_num" "$comment"
[ "$ID_CDROM_CD_R" -o "$ID_CDROM_CD_RW" ] && \
write_rule "$match" "cdrw$link_num"
[ "$ID_CDROM_DVD" ] && \
write_rule "$match" "dvd$link_num"
[ "$ID_CDROM_DVD_R" -o "$ID_CDROM_DVD_RW" -o "$ID_CDROM_DVD_RAM" ] && \
write_rule "$match" "dvdrw$link_num"
echo >> $RULES_FILE
unlock_rules_file
echo $SYMLINKS
exit 0

View File

@ -1,141 +0,0 @@
#!/bin/sh -e
# This script is run to create persistent network device naming rules
# based on properties of the device.
# If the interface needs to be renamed, INTERFACE_NEW=<name> will be printed
# on stdout to allow udev to IMPORT it.
# variables used to communicate:
# MATCHADDR MAC address used for the match
# MATCHID bus_id used for the match
# MATCHDEVID dev_id used for the match
# MATCHDRV driver name used for the match
# MATCHIFTYPE interface type match
# COMMENT comment to add to the generated rule
# INTERFACE_NAME requested name supplied by external tool
# INTERFACE_NEW new interface name returned by rule writer
# Copyright (C) 2006 Marco d'Itri <md@Linux.IT>
# Copyright (C) 2007 Kay Sievers <kay.sievers@vrfy.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# debug, if UDEV_LOG=<debug>
if [ -n "$UDEV_LOG" ]; then
if [ "$UDEV_LOG" -ge 7 ]; then
set -x
fi
fi
RULES_FILE='/etc/udev/rules.d/70-persistent-net.rules'
. /lib/udev/rule_generator.functions
interface_name_taken() {
local value="$(find_all_rules 'NAME=' $INTERFACE)"
if [ "$value" ]; then
return 0
else
return 1
fi
}
find_next_available() {
raw_find_next_available "$(find_all_rules 'NAME=' "$1")"
}
write_rule() {
local match="$1"
local name="$2"
local comment="$3"
{
if [ "$PRINT_HEADER" ]; then
PRINT_HEADER=
echo "# This file was automatically generated by the $0"
echo "# program, run by the persistent-net-generator.rules rules file."
echo "#"
echo "# You can modify it, as long as you keep each rule on a single"
echo "# line, and change only the value of the NAME= key."
fi
echo ""
[ "$comment" ] && echo "# $comment"
echo "SUBSYSTEM==\"net\", ACTION==\"add\"$match, NAME=\"$name\""
} >> $RULES_FILE
}
if [ -z "$INTERFACE" ]; then
echo "missing \$INTERFACE" >&2
exit 1
fi
# Prevent concurrent processes from modifying the file at the same time.
lock_rules_file
# Check if the rules file is writeable.
choose_rules_file
# the DRIVERS key is needed to not match bridges and VLAN sub-interfaces
if [ "$MATCHADDR" ]; then
match="$match, DRIVERS==\"?*\", ATTR{address}==\"$MATCHADDR\""
fi
if [ "$MATCHDRV" ]; then
match="$match, DRIVERS==\"$MATCHDRV\""
fi
if [ "$MATCHDEVID" ]; then
match="$match, ATTR{dev_id}==\"$MATCHDEVID\""
fi
if [ "$MATCHID" ]; then
match="$match, KERNELS==\"$MATCHID\""
fi
if [ "$MATCHIFTYPE" ]; then
match="$match, ATTR{type}==\"$MATCHIFTYPE\""
fi
if [ -z "$match" ]; then
echo "missing valid match" >&2
unlock_rules_file
exit 1
fi
basename=${INTERFACE%%[0-9]*}
match="$match, KERNEL==\"$basename*\""
if [ "$INTERFACE_NAME" ]; then
# external tools may request a custom name
COMMENT="$COMMENT (custom name provided by external tool)"
if [ "$INTERFACE_NAME" != "$INTERFACE" ]; then
INTERFACE=$INTERFACE_NAME;
echo "INTERFACE_NEW=$INTERFACE"
fi
else
# if a rule using the current name already exists, find a new name
if interface_name_taken; then
INTERFACE="$basename$(find_next_available "$basename[0-9]*")"
# prevent INTERFACE from being "eth" instead of "eth0"
[ "$INTERFACE" = "${INTERFACE%%[ \[\]0-9]*}" ] && INTERFACE=${INTERFACE}0
echo "INTERFACE_NEW=$INTERFACE"
fi
fi
write_rule "$match" "$INTERFACE" "$COMMENT"
unlock_rules_file
exit 0