mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-07-01 17:49:25 +01:00
Import new bootscripts package.
git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/systemd/BOOK@10278 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
parent
c46ee65dc7
commit
01479e657a
27
Makefile
27
Makefile
@ -39,7 +39,7 @@ lfs: validate profile-html
|
|||||||
sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
||||||
done;
|
done;
|
||||||
|
|
||||||
$(Q)$(MAKE) wget-list
|
$(Q)$(MAKE) $(BASEDIR)/wget-list $(BASEDIR)/md5sums
|
||||||
|
|
||||||
pdf: validate
|
pdf: validate
|
||||||
@echo "Generating profiled XML for PDF..."
|
@echo "Generating profiled XML for PDF..."
|
||||||
@ -72,11 +72,9 @@ nochunks: validate profile-html
|
|||||||
$(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
$(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
||||||
@echo "Running obfuscate.sh..."
|
@echo "Running obfuscate.sh..."
|
||||||
$(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
$(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
||||||
$(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
|
$(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
||||||
$(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
$(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
||||||
$(Q)sed -i -e "s@../wget-list@wget-list@" \
|
$(Q)$(MAKE) $(BASEDIR)/wget-list $(BASEDIR)/md5sums
|
||||||
$(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
|
||||||
$(Q)$(MAKE) wget-list
|
|
||||||
|
|
||||||
tmpdir:
|
tmpdir:
|
||||||
@echo "Creating and cleaning $(RENDERTMP)"
|
@echo "Creating and cleaning $(RENDERTMP)"
|
||||||
@ -85,9 +83,13 @@ tmpdir:
|
|||||||
$(Q)rm -f $(RENDERTMP)/lfs-pdf.fo
|
$(Q)rm -f $(RENDERTMP)/lfs-pdf.fo
|
||||||
|
|
||||||
validate: tmpdir
|
validate: tmpdir
|
||||||
|
@echo "Processing bootscripts..."
|
||||||
|
$(Q)bash process-scripts.sh
|
||||||
@echo "Validating the book..."
|
@echo "Validating the book..."
|
||||||
$(Q)xmllint --nonet --noent --xinclude --postvalid \
|
$(Q)xmllint --nonet --noent --xinclude --postvalid \
|
||||||
-o $(RENDERTMP)/lfs-full.xml index.xml
|
-o $(RENDERTMP)/lfs-full.xml index.xml
|
||||||
|
$(Q)rm -f appendices/*.script
|
||||||
|
$(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
|
||||||
@echo "Validation complete."
|
@echo "Validation complete."
|
||||||
|
|
||||||
profile-html: validate
|
profile-html: validate
|
||||||
@ -96,17 +98,20 @@ profile-html: validate
|
|||||||
--output $(RENDERTMP)/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
|
--output $(RENDERTMP)/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
|
||||||
$(RENDERTMP)/lfs-full.xml
|
$(RENDERTMP)/lfs-full.xml
|
||||||
|
|
||||||
wget-list:
|
$(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent
|
||||||
@echo "Generating wget list..."
|
@echo "Generating wget list..."
|
||||||
$(Q)mkdir -p $(BASEDIR)
|
$(Q)mkdir -p $(BASEDIR)
|
||||||
$(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
|
$(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
|
||||||
stylesheets/wget-list.xsl chapter03/chapter03.xml
|
stylesheets/wget-list.xsl chapter03/chapter03.xml
|
||||||
|
|
||||||
md5sums:
|
$(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent
|
||||||
@echo "Generating md5sum file..."
|
@echo "Generating md5sum file..."
|
||||||
$(Q)mkdir -p $(BASEDIR)
|
$(Q)mkdir -p $(BASEDIR)
|
||||||
$(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/md5sums \
|
$(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/md5sums \
|
||||||
stylesheets/md5sum.xsl chapter03/chapter03.xml
|
stylesheets/md5sum.xsl chapter03/chapter03.xml
|
||||||
|
$(Q)sed -i -e \
|
||||||
|
"s/LFS-UNITS-MD5SUM/$(shell md5sum lfs-systemd-units*.tar.bz2 | cut -d' ' -f1)/" \
|
||||||
|
$(BASEDIR)/md5sums
|
||||||
|
|
||||||
dump-commands: validate
|
dump-commands: validate
|
||||||
@echo "Dumping book commands..."
|
@echo "Dumping book commands..."
|
||||||
@ -114,7 +119,7 @@ dump-commands: validate
|
|||||||
stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
|
stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
|
||||||
|
|
||||||
|
|
||||||
all: lfs nochunks pdf dump-commands md5sums
|
all: lfs nochunks pdf dump-commands
|
||||||
|
|
||||||
|
.PHONY : all dump-commands lfs nochunks pdf profile-html tmpdir validate
|
||||||
|
|
||||||
.PHONY : all dump-commands lfs nochunks pdf profile-html tmpdir validate \
|
|
||||||
validate wget-list maketar md5sums
|
|
||||||
|
30
aux-file-data.sh
Executable file
30
aux-file-data.sh
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/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-systemd-units*.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/LFS-UNITS-SIZE/$bootsize/ \
|
||||||
|
-e s/LFS-UNITS-INSTALL-KB/$bootinstallsize/ \
|
||||||
|
-e s/LFS-UNITS-MD5SUM/$bootmd5/ $FILE
|
||||||
|
|
@ -356,6 +356,15 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>LFS-Systemd-Units (&lfs-systemd-units-version;) - <token>&lfs-systemd-units-size;</token>:</term>
|
||||||
|
<listitem>
|
||||||
|
<para>Home page: <ulink url="&lfs-systemd-units-home;"/></para>
|
||||||
|
<para>Download: <ulink url="&lfs-systemd-units-url;"/></para>
|
||||||
|
<para>MD5 sum: <literal>&lfs-systemd-units-md5;</literal></para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>Libcap (&libcap-version;) - <token>&libcap-size;</token>:</term>
|
<term>Libcap (&libcap-version;) - <token>&libcap-size;</token>:</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
11
make-aux-files.sh
Executable file
11
make-aux-files.sh
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
rm -f lfs-systemd-units*.tar.bz2
|
||||||
|
|
||||||
|
# Get base file name and move bootscripts directory to that name
|
||||||
|
version=`grep "ENTITY lfs-systemd-units-version" packages.ent |cut -d'"' -f2`
|
||||||
|
mv systemd-units lfs-systemd-units-$version
|
||||||
|
|
||||||
|
# Create the tarball and clean up
|
||||||
|
tar -cjf lfs-systemd-units-$version.tar.bz2 --exclude .svn lfs-systemd-units-$version
|
||||||
|
mv lfs-systemd-units-$version systemd-units
|
@ -350,6 +350,14 @@
|
|||||||
<!ENTITY less-ch6-du "3.6 MB">
|
<!ENTITY less-ch6-du "3.6 MB">
|
||||||
<!ENTITY less-ch6-sbu "less than 0.1 SBU">
|
<!ENTITY less-ch6-sbu "less than 0.1 SBU">
|
||||||
|
|
||||||
|
<!ENTITY lfs-systemd-units-version "20130518"> <!-- Scripts depend on this format -->
|
||||||
|
<!ENTITY lfs-systemd-units-size "LFS-UNITS-SIZE KB"> <!-- Updated in Makefile -->
|
||||||
|
<!ENTITY lfs-systemd-units-url "&downloads-root;lfs-systemd-units-&lfs-systemd-units-version;.tar.bz2">
|
||||||
|
<!ENTITY lfs-systemd-units-md5 "LFS-UNITS-MD5SUM"> <!-- Updated in Makefile -->
|
||||||
|
<!ENTITY lfs-systemd-units-home " ">
|
||||||
|
<!ENTITY lfs-systemd-units-ch7-du "LFS-UNITS-INSTALL-KB KB"> <!-- Updated in Makefile -->
|
||||||
|
<!ENTITY lfs-systemd-units-ch7-sbu "less than 0.1 SBU">
|
||||||
|
|
||||||
<!ENTITY libcap-version "2.22">
|
<!ENTITY libcap-version "2.22">
|
||||||
<!ENTITY libcap-size "66 KB">
|
<!ENTITY libcap-size "66 KB">
|
||||||
<!ENTITY libcap-url "http://ftp.de.debian.org/debian/pool/main/libc/libcap2/libcap2_&libcap-version;.orig.tar.gz">
|
<!ENTITY libcap-url "http://ftp.de.debian.org/debian/pool/main/libc/libcap2/libcap2_&libcap-version;.orig.tar.gz">
|
||||||
|
17
process-scripts.sh
Normal file
17
process-scripts.sh
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Boot scripts
|
||||||
|
for s in systemd-units/lfs/lib/services/* \
|
||||||
|
systemd-units/lfs/sbin/* \
|
||||||
|
systemd-units/lfs/tmpfiles/* \
|
||||||
|
systemd-units/lfs/units/*
|
||||||
|
do
|
||||||
|
script=$(basename $s)
|
||||||
|
|
||||||
|
# Skip directories
|
||||||
|
[ $script == 'network-devices' ] && continue
|
||||||
|
|
||||||
|
sed -e 's/\&/\&\;/g' -e 's/</\<\;/g' -e 's/>/\>\;/g' \
|
||||||
|
-e "s/'/\&apos\;/g" -e 's/"/\"\;/g' -e 's/\t/ /g' \
|
||||||
|
$s > appendices/${script}.script
|
||||||
|
done
|
1103
systemd-units/ChangeLog
Normal file
1103
systemd-units/ChangeLog
Normal file
File diff suppressed because it is too large
Load Diff
40
systemd-units/Makefile
Normal file
40
systemd-units/Makefile
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
EXTDIR=${DESTDIR}/etc
|
||||||
|
TMPFILESDIR=${EXTDIR}/tmpfiles.d
|
||||||
|
LIBDIR=${DESTDIR}/lib
|
||||||
|
SERVICEDIR=${LIBDIR}/services
|
||||||
|
UNITDIR=${LIBDIR}/systemd/system
|
||||||
|
MAN8=${DESTDIR}/usr/share/man/man8
|
||||||
|
SBIN=${DESTDIR}/sbin
|
||||||
|
MODE=755
|
||||||
|
DIRMODE=755
|
||||||
|
CONFMODE=644
|
||||||
|
|
||||||
|
install: files
|
||||||
|
|
||||||
|
create-dirs:
|
||||||
|
install -d -m ${DIRMODE} ${EXTDIR}/sysconfig
|
||||||
|
install -d -m ${DIRMODE} ${TMPFILESDIR}
|
||||||
|
install -d -m ${DIRMODE} ${SERVICEDIR}
|
||||||
|
install -d -m ${DIRMODE} ${UNITDIR}
|
||||||
|
install -d -m ${DIRMODE} ${MAN8}
|
||||||
|
install -d -m ${DIRMODE} ${SBIN}
|
||||||
|
ln -sfn services ${LIBDIR}/lsb
|
||||||
|
|
||||||
|
files: create-dirs
|
||||||
|
install -m ${CONFMODE} lfs/tmpfiles/nscd.conf ${TMPFILESDIR}
|
||||||
|
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 ${SERVICEDIR}
|
||||||
|
install -m ${MODE} lfs/lib/services/ipv4-static ${SERVICEDIR}
|
||||||
|
install -m ${CONFMODE} lfs/lib/services/init-functions ${SERVICEDIR}
|
||||||
|
install -m ${CONFMODE} lfs/units/ifupdownat.service ${UNITDIR}/ifupdown@.service
|
||||||
|
install -m ${CONFMODE} lfs/units/nscd.service ${UNITDIR}
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -rf ${TMPFILESDIR}/nscd.conf ${SERVICEDIR} ${LIBDIR}/lsb \
|
||||||
|
${UNITDIR}/ifupdown@.service ${UNITDIR}/nscd.service ${SBIN}/ifup \
|
||||||
|
${SBIN}/ifdown ${MAN8}/ifup.8 ${MAN8}/ifdown.8
|
||||||
|
|
||||||
|
.PHONY: all create-dirs install files uninstall
|
27
systemd-units/README
Normal file
27
systemd-units/README
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
Network Configuration:
|
||||||
|
Script Files:
|
||||||
|
/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
|
||||||
|
|
||||||
|
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)
|
800
systemd-units/lfs/lib/services/init-functions
Normal file
800
systemd-units/lfs/lib/services/init-functions
Normal file
@ -0,0 +1,800 @@
|
|||||||
|
#!/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}"
|
||||||
|
|
||||||
|
ENABLE_LOG=0
|
||||||
|
BOOTLOG=/run/var/bootlog
|
||||||
|
KILLDELAY=3
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# start_daemon() #
|
||||||
|
# Usage: start_daemon [-f] [-n nicelevel] [-p pidfile] pathname [args...] #
|
||||||
|
# #
|
||||||
|
# Purpose: This runs the specified program as a daemon #
|
||||||
|
# #
|
||||||
|
# Inputs: -f: (force) run the program even if it is already running. #
|
||||||
|
# -n nicelevel: specify a nice level. See 'man nice(1)'. #
|
||||||
|
# -p pidfile: use the specified file to determine PIDs. #
|
||||||
|
# pathname: the complete path to the specified program #
|
||||||
|
# args: additional arguments passed to the program (pathname) #
|
||||||
|
# #
|
||||||
|
# Return values (as defined by LSB exit codes): #
|
||||||
|
# 0 - program is running or service is OK #
|
||||||
|
# 1 - generic or unspecified error #
|
||||||
|
# 2 - invalid or excessive argument(s) #
|
||||||
|
# 5 - program is not installed #
|
||||||
|
################################################################################
|
||||||
|
start_daemon()
|
||||||
|
{
|
||||||
|
local force=""
|
||||||
|
local nice="0"
|
||||||
|
local pidfile=""
|
||||||
|
local pidlist=""
|
||||||
|
local retval=""
|
||||||
|
|
||||||
|
# Process arguments
|
||||||
|
while true
|
||||||
|
do
|
||||||
|
case "${1}" in
|
||||||
|
|
||||||
|
-f)
|
||||||
|
force="1"
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
|
|
||||||
|
-n)
|
||||||
|
nice="${2}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
|
||||||
|
-p)
|
||||||
|
pidfile="${2}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
|
||||||
|
-*)
|
||||||
|
return 2
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
program="${1}"
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check for a valid program
|
||||||
|
if [ ! -e "${program}" ]; then return 5; fi
|
||||||
|
|
||||||
|
# Execute
|
||||||
|
if [ -z "${force}" ]; then
|
||||||
|
if [ -z "${pidfile}" ]; then
|
||||||
|
# Determine the pid by discovery
|
||||||
|
pidlist=`pidofproc "${1}"`
|
||||||
|
retval="${?}"
|
||||||
|
else
|
||||||
|
# The PID file contains the needed PIDs
|
||||||
|
# Note that by LSB requirement, the path must be given to pidofproc,
|
||||||
|
# however, it is not used by the current implementation or standard.
|
||||||
|
pidlist=`pidofproc -p "${pidfile}" "${1}"`
|
||||||
|
retval="${?}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Return a value ONLY
|
||||||
|
# It is the init script's (or distribution's functions) responsibilty
|
||||||
|
# to log messages!
|
||||||
|
case "${retval}" in
|
||||||
|
|
||||||
|
0)
|
||||||
|
# Program is already running correctly, this is a
|
||||||
|
# successful start.
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
1)
|
||||||
|
# Program is not running, but an invalid pid file exists
|
||||||
|
# remove the pid file and continue
|
||||||
|
rm -f "${pidfile}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
3)
|
||||||
|
# Program is not running and no pidfile exists
|
||||||
|
# do nothing here, let start_deamon continue.
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# Others as returned by status values shall not be interpreted
|
||||||
|
# and returned as an unspecified error.
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Do the start!
|
||||||
|
nice -n "${nice}" "${@}"
|
||||||
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# killproc() #
|
||||||
|
# Usage: killproc [-p pidfile] pathname [signal] #
|
||||||
|
# #
|
||||||
|
# Purpose: Send control signals to running processes #
|
||||||
|
# #
|
||||||
|
# Inputs: -p pidfile, uses the specified pidfile #
|
||||||
|
# pathname, pathname to the specified program #
|
||||||
|
# signal, send this signal to pathname #
|
||||||
|
# #
|
||||||
|
# Return values (as defined by LSB exit codes): #
|
||||||
|
# 0 - program (pathname) has stopped/is already stopped or a #
|
||||||
|
# running program has been sent specified signal and stopped #
|
||||||
|
# successfully #
|
||||||
|
# 1 - generic or unspecified error #
|
||||||
|
# 2 - invalid or excessive argument(s) #
|
||||||
|
# 5 - program is not installed #
|
||||||
|
# 7 - program is not running and a signal was supplied #
|
||||||
|
################################################################################
|
||||||
|
killproc()
|
||||||
|
{
|
||||||
|
local pidfile
|
||||||
|
local program
|
||||||
|
local prefix
|
||||||
|
local progname
|
||||||
|
local signal="-TERM"
|
||||||
|
local fallback="-KILL"
|
||||||
|
local nosig
|
||||||
|
local pidlist
|
||||||
|
local retval
|
||||||
|
local pid
|
||||||
|
local delay="30"
|
||||||
|
local piddead
|
||||||
|
local dtime
|
||||||
|
|
||||||
|
# Process arguments
|
||||||
|
while true; do
|
||||||
|
case "${1}" in
|
||||||
|
-p)
|
||||||
|
pidfile="${2}"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
program="${1}"
|
||||||
|
if [ -n "${2}" ]; then
|
||||||
|
signal="${2}"
|
||||||
|
fallback=""
|
||||||
|
else
|
||||||
|
nosig=1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Error on additional arguments
|
||||||
|
if [ -n "${3}" ]; then
|
||||||
|
return 2
|
||||||
|
else
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# Check for a valid program
|
||||||
|
if [ ! -e "${program}" ]; then return 5; fi
|
||||||
|
|
||||||
|
# Check for a valid signal
|
||||||
|
check_signal "${signal}"
|
||||||
|
if [ "${?}" -ne "0" ]; then return 2; fi
|
||||||
|
|
||||||
|
# Get a list of pids
|
||||||
|
if [ -z "${pidfile}" ]; then
|
||||||
|
# determine the pid by discovery
|
||||||
|
pidlist=`pidofproc "${1}"`
|
||||||
|
retval="${?}"
|
||||||
|
else
|
||||||
|
# The PID file contains the needed PIDs
|
||||||
|
# Note that by LSB requirement, the path must be given to pidofproc,
|
||||||
|
# however, it is not used by the current implementation or standard.
|
||||||
|
pidlist=`pidofproc -p "${pidfile}" "${1}"`
|
||||||
|
retval="${?}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Return a value ONLY
|
||||||
|
# It is the init script's (or distribution's functions) responsibilty
|
||||||
|
# to log messages!
|
||||||
|
case "${retval}" in
|
||||||
|
|
||||||
|
0)
|
||||||
|
# Program is running correctly
|
||||||
|
# Do nothing here, let killproc continue.
|
||||||
|
;;
|
||||||
|
|
||||||
|
1)
|
||||||
|
# Program is not running, but an invalid pid file exists
|
||||||
|
# Remove the pid file.
|
||||||
|
rm -f "${pidfile}"
|
||||||
|
|
||||||
|
# This is only a success if no signal was passed.
|
||||||
|
if [ -n "${nosig}" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 7
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
3)
|
||||||
|
# Program is not running and no pidfile exists
|
||||||
|
# This is only a success if no signal was passed.
|
||||||
|
if [ -n "${nosig}" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 7
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# Others as returned by status values shall not be interpreted
|
||||||
|
# and returned as an unspecified error.
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Perform different actions for exit signals and control signals
|
||||||
|
check_sig_type "${signal}"
|
||||||
|
|
||||||
|
if [ "${?}" -eq "0" ]; then # Signal is used to terminate the program
|
||||||
|
|
||||||
|
# Account for empty pidlist (pid file still exists and no
|
||||||
|
# signal was given)
|
||||||
|
if [ "${pidlist}" != "" ]; then
|
||||||
|
|
||||||
|
# Kill the list of pids
|
||||||
|
for pid in ${pidlist}; do
|
||||||
|
|
||||||
|
kill -0 "${pid}" 2> /dev/null
|
||||||
|
|
||||||
|
if [ "${?}" -ne "0" ]; then
|
||||||
|
# Process is dead, continue to next and assume all is well
|
||||||
|
continue
|
||||||
|
else
|
||||||
|
kill "${signal}" "${pid}" 2> /dev/null
|
||||||
|
|
||||||
|
# Wait up to ${delay}/10 seconds to for "${pid}" to
|
||||||
|
# terminate in 10ths of a second
|
||||||
|
|
||||||
|
while [ "${delay}" -ne "0" ]; do
|
||||||
|
kill -0 "${pid}" 2> /dev/null || piddead="1"
|
||||||
|
if [ "${piddead}" = "1" ]; then break; fi
|
||||||
|
sleep 0.1
|
||||||
|
delay="$(( ${delay} - 1 ))"
|
||||||
|
done
|
||||||
|
|
||||||
|
# If a fallback is set, and program is still running, then
|
||||||
|
# use the fallback
|
||||||
|
if [ -n "${fallback}" -a "${piddead}" != "1" ]; then
|
||||||
|
kill "${fallback}" "${pid}" 2> /dev/null
|
||||||
|
sleep 1
|
||||||
|
# Check again, and fail if still running
|
||||||
|
kill -0 "${pid}" 2> /dev/null && return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check for and remove stale PID files.
|
||||||
|
if [ -z "${pidfile}" ]; then
|
||||||
|
# Find the basename of $program
|
||||||
|
prefix=`echo "${program}" | sed 's/[^/]*$//'`
|
||||||
|
progname=`echo "${program}" | sed "s@${prefix}@@"`
|
||||||
|
|
||||||
|
if [ -e "/var/run/${progname}.pid" ]; then
|
||||||
|
rm -f "/var/run/${progname}.pid" 2> /dev/null
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ -e "${pidfile}" ]; then rm -f "${pidfile}" 2> /dev/null; fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# For signals that do not expect a program to exit, simply
|
||||||
|
# let kill do 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'`
|
||||||
|
|
||||||
|
if [ "${ENABLE_LOG}" = "1" ]; then
|
||||||
|
timespec
|
||||||
|
/bin/echo -e "${STAMP} ${logmessage} OK" >> ${BOOTLOG}
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
log_success_msg2()
|
||||||
|
{
|
||||||
|
/bin/echo -n -e "${BMPREFIX}${@}"
|
||||||
|
/bin/echo -e "${CURS_ZERO}${SUCCESS_PREFIX}${SET_COL}${SUCCESS_SUFFIX}"
|
||||||
|
|
||||||
|
if [ "${ENABLE_LOG}" = "1" ]; then
|
||||||
|
echo " OK" >> ${BOOTLOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
if [ "${ENABLE_LOG}" = "1" ]; then
|
||||||
|
timespec
|
||||||
|
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
|
||||||
|
/bin/echo -e "${STAMP} ${logmessage} FAIL" >> ${BOOTLOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
log_failure_msg2()
|
||||||
|
{
|
||||||
|
/bin/echo -n -e "${BMPREFIX}${@}"
|
||||||
|
/bin/echo -e "${CURS_ZERO}${FAILURE_PREFIX}${SET_COL}${FAILURE_SUFFIX}"
|
||||||
|
|
||||||
|
if [ "${ENABLE_LOG}" = "1" ]; then
|
||||||
|
echo "FAIL" >> ${BOOTLOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
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}"
|
||||||
|
|
||||||
|
if [ "${ENABLE_LOG}" = "1" ]; then
|
||||||
|
# Strip non-printable characters from log file
|
||||||
|
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
|
||||||
|
timespec
|
||||||
|
/bin/echo -e "${STAMP} ${logmessage} WARN" >> ${BOOTLOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
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}${@}"
|
||||||
|
|
||||||
|
if [ "${ENABLE_LOG}" = "1" ]; then
|
||||||
|
# Strip non-printable characters from log file
|
||||||
|
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
|
||||||
|
timespec
|
||||||
|
/bin/echo -n -e "${STAMP} ${logmessage}" >> ${BOOTLOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info_msg2()
|
||||||
|
{
|
||||||
|
/bin/echo -n -e "${@}"
|
||||||
|
|
||||||
|
if [ "${ENABLE_LOG}" = "1" ]; then
|
||||||
|
# Strip non-printable characters from log file
|
||||||
|
logmessage=`echo "${@}" | sed 's/\\\033[^a-zA-Z]*.//g'`
|
||||||
|
/bin/echo -n -e "${logmessage}" >> ${BOOTLOG}
|
||||||
|
fi
|
||||||
|
|
||||||
|
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
|
83
systemd-units/lfs/lib/services/ipv4-static
Executable file
83
systemd-units/lfs/lib/services/ipv4-static
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
#!/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
|
92
systemd-units/lfs/lib/services/ipv4-static-route
Executable file
92
systemd-units/lfs/lib/services/ipv4-static-route
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/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
|
100
systemd-units/lfs/sbin/ifdown
Executable file
100
systemd-units/lfs/sbin/ifdown
Executable file
@ -0,0 +1,100 @@
|
|||||||
|
#!/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
|
136
systemd-units/lfs/sbin/ifup
Executable file
136
systemd-units/lfs/sbin/ifup
Executable file
@ -0,0 +1,136 @@
|
|||||||
|
#!/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
|
174
systemd-units/lfs/sbin/ifup.8
Normal file
174
systemd-units/lfs/sbin/ifup.8
Normal file
@ -0,0 +1,174 @@
|
|||||||
|
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)
|
2
systemd-units/lfs/tmpfiles/nscd.conf
Normal file
2
systemd-units/lfs/tmpfiles/nscd.conf
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
d /run/nscd 755 root root -
|
||||||
|
|
12
systemd-units/lfs/units/ifupdownat.service
Normal file
12
systemd-units/lfs/units/ifupdownat.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Start ifupdown for %i
|
||||||
|
Requires=sys-subsystem-net-devices-%i.device
|
||||||
|
After=sys-subsystem-net-devices-%i.device
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/sbin/ifup %i
|
||||||
|
ExecStop=/sbin/ifdown %i
|
||||||
|
RemainAfterExit=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
16
systemd-units/lfs/units/nscd.service
Normal file
16
systemd-units/lfs/units/nscd.service
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Name Service Cache Daemon
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
ExecStart=/usr/sbin/nscd
|
||||||
|
ExecStop=/usr/sbin/nscd --shutdown
|
||||||
|
ExecReload=/usr/sbin/nscd -i passwd
|
||||||
|
ExecReload=/usr/sbin/nscd -i group
|
||||||
|
ExecReload=/usr/sbin/nscd -i hosts
|
||||||
|
ExecReload=/usr/sbin/nscd -i services
|
||||||
|
Restart=always
|
||||||
|
PIDFile=/run/nscd/nscd.pid
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user