software:linux_server:lfs:appendices:boot_and_sysconfig_scripts
Различия
Показаны различия между двумя версиями страницы.
Предыдущая версия справа и слеваПредыдущая версия | |||
software:linux_server:lfs:appendices:boot_and_sysconfig_scripts [2025/02/23 13:07] – vladpolskiy | software:linux_server:lfs:appendices:boot_and_sysconfig_scripts [Дата неизвестна] (текущий) – удалено - внешнее изменение (Дата неизвестна) 127.0.0.1 | ||
---|---|---|---|
Строка 1: | Строка 1: | ||
- | ======V. Приложения====== | ||
- | Содержание: | ||
- | * [[software: | ||
- | * [[software: | ||
- | * [[software: | ||
- | * [[software: | ||
- | * [[software: | ||
- | * [[software: | ||
- | =====D. Скрипты загрузки и sysconfig версии-20240825===== | ||
- | Скрипты в этом приложении перечислены по каталогу, | ||
- | |||
- | ====D.1. / | ||
- | Скрипт '' | ||
- | |||
- | #!/bin/bash | ||
- | ######################################################################## | ||
- | # Begin rc | ||
- | # | ||
- | # Description : Main Run Level Control Script | ||
- | # | ||
- | # Authors | ||
- | # : DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Updates | ||
- | # : Pierre Labastie - pierre AT linuxfromscratch D0T org | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : Updates March 24th, 2022: new semantics of S/K files | ||
- | # - Instead of testing that S scripts were K scripts in the | ||
- | # | ||
- | # - Instead of testing that K scripts were S scripts in the | ||
- | # | ||
- | # - S scripts in runlevel 0 or 6 are now run with | ||
- | # " | ||
- | ######################################################################## | ||
- | |||
- | . / | ||
- | |||
- | print_error_msg() | ||
- | { | ||
- | | ||
- | # $i is set when called | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | | ||
- | | ||
- | } | ||
- | |||
- | check_script_status() | ||
- | { | ||
- | # $i is set when called | ||
- | if [ ! -f ${i} ]; then | ||
- | log_warning_msg "${i} is not a valid symlink." | ||
- | SCRIPT_STAT=" | ||
- | fi | ||
- | |||
- | if [ ! -x ${i} ]; then | ||
- | log_warning_msg "${i} is not executable, skipping." | ||
- | SCRIPT_STAT=" | ||
- | fi | ||
- | } | ||
- | |||
- | run() | ||
- | { | ||
- | if [ -z $interactive ]; then | ||
- | ${1} ${2} | ||
- | return $? | ||
- | fi | ||
- | |||
- | while true; do | ||
- | read -p "Run ${1} ${2} (Yes/ | ||
- | echo | ||
- | |||
- | case ${runit} in | ||
- | c | C) | ||
- | interactive="" | ||
- | ${i} ${2} | ||
- | ret=${?} | ||
- | break; | ||
- | ;; | ||
- | |||
- | n | N) | ||
- | return 0 | ||
- | ;; | ||
- | |||
- | y | Y) | ||
- | ${i} ${2} | ||
- | ret=${?} | ||
- | break | ||
- | ;; | ||
- | esac | ||
- | done | ||
- | |||
- | | ||
- | } | ||
- | |||
- | # Read any local settings/ | ||
- | [ -r / | ||
- | |||
- | DISTRO=${DISTRO: | ||
- | DISTRO_CONTACT=${DISTRO_CONTACT: | ||
- | DISTRO_MINI=${DISTRO_MINI: | ||
- | IPROMPT=${IPROMPT: | ||
- | |||
- | # These 3 signals will not cause our script to exit | ||
- | trap "" | ||
- | |||
- | [ " | ||
- | |||
- | if [ " | ||
- | echo " | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | previous=${PREVLEVEL} | ||
- | [ " | ||
- | |||
- | if [ ! -d / | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | if [ " | ||
- | |||
- | # Note: In ${LOGLEVEL: | ||
- | if [ " | ||
- | [ -r / | ||
- | dmesg -n " | ||
- | fi | ||
- | |||
- | if [ " | ||
- | # The total length of the distro welcome string, without escape codes | ||
- | | ||
- | | ||
- | |||
- | # The total length of the interactive string, without escape codes | ||
- | | ||
- | | ||
- | |||
- | |||
- | # 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 | ||
- | | ||
- | | ||
- | | ||
- | |||
- | echo -e " | ||
- | echo -e " | ||
- | echo -e " | ||
- | echo "" | ||
- | read -t " | ||
- | fi | ||
- | |||
- | # Make lower case | ||
- | [ " | ||
- | [ " | ||
- | |||
- | # Read the state file if it exists from runlevel S | ||
- | [ -r / | ||
- | |||
- | # Stop all services marked as K, except if marked as K in the previous | ||
- | # runlevel: it is the responsibility of the script to not try to kill | ||
- | # a non running service | ||
- | if [ " | ||
- | for i in $(ls -v / | ||
- | do | ||
- | check_script_status | ||
- | if [ " | ||
- | | ||
- | | ||
- | fi | ||
- | |||
- | suffix=${i#/ | ||
- | [ -e / | ||
- | |||
- | run ${i} stop | ||
- | error_value=${? | ||
- | |||
- | if [ " | ||
- | done | ||
- | fi | ||
- | |||
- | if [ " | ||
- | |||
- | if [ " | ||
- | touch /fastboot | ||
- | fi | ||
- | |||
- | |||
- | # Start all services marked as S in this runlevel, except if marked as | ||
- | # S in the previous runlevel | ||
- | # it is the responsibility of the script to not try to start an already running | ||
- | # service | ||
- | for i in $( ls -v / | ||
- | do | ||
- | |||
- | if [ " | ||
- | suffix=${i#/ | ||
- | [ -e / | ||
- | fi | ||
- | |||
- | | ||
- | if [ " | ||
- | SCRIPT_STAT=" | ||
- | continue | ||
- | fi | ||
- | |||
- | run ${i} start | ||
- | |||
- | | ||
- | |||
- | if [ " | ||
- | done | ||
- | |||
- | # Store interactive variable on switch from runlevel S and remove if not | ||
- | if [ " | ||
- | echo " | ||
- | else | ||
- | rm -f / | ||
- | fi | ||
- | |||
- | # Copy the boot log on initial boot only | ||
- | if [ " | ||
- | cat $BOOTLOG >> / | ||
- | |||
- | # Mark the end of boot | ||
- | echo " | ||
- | |||
- | # Remove the temporary file | ||
- | rm -f $BOOTLOG 2> /dev/null | ||
- | fi | ||
- | |||
- | # End rc | ||
- | D.2. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # | ||
- | # Begin / | ||
- | # | ||
- | # Description : Run Level Control Functions | ||
- | # | ||
- | # Authors | ||
- | # : DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : With code based on Matthias Benkmann' | ||
- | # | ||
- | # | ||
- | # The file should be located in /lib/lsb | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ## Environmental setup | ||
- | # Setup default values for environment | ||
- | umask 022 | ||
- | export PATH="/ | ||
- | |||
- | ## Set color commands, used via echo | ||
- | # Please consult `man console_codes for more information | ||
- | # under the " | ||
- | # | ||
- | # 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=" | ||
- | SUCCESS=" | ||
- | WARNING=" | ||
- | FAILURE=" | ||
- | INFO=" | ||
- | BRACKET=" | ||
- | |||
- | # Use a colored prefix | ||
- | BMPREFIX=" | ||
- | SUCCESS_PREFIX=" | ||
- | FAILURE_PREFIX=" | ||
- | WARNING_PREFIX=" | ||
- | SKIP_PREFIX=" | ||
- | |||
- | SUCCESS_SUFFIX=" | ||
- | FAILURE_SUFFIX=" | ||
- | WARNING_SUFFIX=" | ||
- | SKIP_SUFFIX=" | ||
- | |||
- | BOOTLOG=/ | ||
- | KILLDELAY=3 | ||
- | SCRIPT_STAT=" | ||
- | |||
- | # Set any user specified environment variables e.g. HEADLESS | ||
- | [ -r / | ||
- | |||
- | # If HEADLESS is set, use that. | ||
- | # If file descriptor 1 or 2 (stdout and stderr) is not open or | ||
- | # does not refer to a terminal, consider the script headless. | ||
- | [ ! -t 1 -o ! -t 2 ] && HEADLESS=${HEADLESS: | ||
- | |||
- | if [ " | ||
- | then | ||
- | ## Screen Dimensions | ||
- | # Find current screen size | ||
- | if [ -z " | ||
- | COLUMNS=$(stty size) | ||
- | COLUMNS=${COLUMNS## | ||
- | fi | ||
- | else | ||
- | | ||
- | fi | ||
- | |||
- | # When using remote connections, | ||
- | if [ " | ||
- | | ||
- | fi | ||
- | |||
- | ## Measurements for positioning result messages | ||
- | COL=$((${COLUMNS} - 8)) | ||
- | WCOL=$((${COL} - 2)) | ||
- | |||
- | ## Set Cursor Position Commands, used via echo | ||
- | SET_COL=" | ||
- | SET_WCOL=" | ||
- | CURS_UP=" | ||
- | CURS_ZERO=" | ||
- | |||
- | ################################################################################ | ||
- | # 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. # | ||
- | # | ||
- | # 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=" | ||
- | local pidfile="" | ||
- | local pidlist="" | ||
- | local retval="" | ||
- | |||
- | # Process arguments | ||
- | while true | ||
- | do | ||
- | case " | ||
- | |||
- | -f) | ||
- | force=" | ||
- | shift 1 | ||
- | ;; | ||
- | |||
- | -n) | ||
- | nice=" | ||
- | shift 2 | ||
- | ;; | ||
- | |||
- | -p) | ||
- | pidfile=" | ||
- | shift 2 | ||
- | ;; | ||
- | |||
- | -*) | ||
- | return 2 | ||
- | ;; | ||
- | |||
- | *) | ||
- | program=" | ||
- | break | ||
- | ;; | ||
- | esac | ||
- | done | ||
- | |||
- | # Check for a valid program | ||
- | if [ ! -e " | ||
- | |||
- | # Execute | ||
- | if [ -z " | ||
- | if [ -z " | ||
- | # Determine the pid by discovery | ||
- | pidlist=`pidofproc " | ||
- | retval=" | ||
- | else | ||
- | # The PID file contains the needed PIDs | ||
- | # Note that by LSB requirement, | ||
- | # however, it is not used by the current implementation or standard. | ||
- | pidlist=`pidofproc -p " | ||
- | retval=" | ||
- | fi | ||
- | |||
- | # Return a value ONLY | ||
- | # It is the init script' | ||
- | # to log messages! | ||
- | case " | ||
- | |||
- | 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 " | ||
- | ;; | ||
- | |||
- | 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 " | ||
- | } | ||
- | |||
- | ################################################################################ | ||
- | # killproc() | ||
- | # Usage: killproc [-p pidfile] pathname [signal] | ||
- | # # | ||
- | # Purpose: Send control signals to running processes | ||
- | # # | ||
- | # Inputs: -p pidfile, uses the specified pidfile | ||
- | # | ||
- | # | ||
- | # # | ||
- | # Return values (as defined by LSB exit codes): | ||
- | # 0 - program (pathname) has stopped/is already stopped or a # | ||
- | # | ||
- | # | ||
- | # 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=" | ||
- | local fallback=" | ||
- | local nosig | ||
- | local pidlist | ||
- | local retval | ||
- | local pid | ||
- | local delay=" | ||
- | local piddead | ||
- | local dtime | ||
- | |||
- | # Process arguments | ||
- | while true; do | ||
- | case " | ||
- | -p) | ||
- | pidfile=" | ||
- | shift 2 | ||
- | ;; | ||
- | |||
- | *) | ||
- | | ||
- | if [ -n " | ||
- | | ||
- | | ||
- | else | ||
- | | ||
- | fi | ||
- | |||
- | # Error on additional arguments | ||
- | if [ -n " | ||
- | | ||
- | else | ||
- | break | ||
- | fi | ||
- | ;; | ||
- | esac | ||
- | done | ||
- | |||
- | # Check for a valid program | ||
- | if [ ! -e " | ||
- | |||
- | # Check for a valid signal | ||
- | check_signal " | ||
- | if [ " | ||
- | |||
- | # Get a list of pids | ||
- | if [ -z " | ||
- | # determine the pid by discovery | ||
- | pidlist=`pidofproc " | ||
- | retval=" | ||
- | else | ||
- | # The PID file contains the needed PIDs | ||
- | # Note that by LSB requirement, | ||
- | # however, it is not used by the current implementation or standard. | ||
- | pidlist=`pidofproc -p " | ||
- | retval=" | ||
- | fi | ||
- | |||
- | # Return a value ONLY | ||
- | # It is the init script' | ||
- | # to log messages! | ||
- | case " | ||
- | |||
- | 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. | ||
- | |||
- | progname=${program## | ||
- | |||
- | if [[ -e "/ | ||
- | pidfile="/ | ||
- | rm -f " | ||
- | fi | ||
- | |||
- | # This is only a success if no signal was passed. | ||
- | if [ -n " | ||
- | 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 " | ||
- | 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 " | ||
- | |||
- | if [ " | ||
- | |||
- | # Account for empty pidlist (pid file still exists and no | ||
- | # signal was given) | ||
- | if [ " | ||
- | |||
- | # Kill the list of pids | ||
- | for pid in ${pidlist}; do | ||
- | |||
- | kill -0 " | ||
- | |||
- | if [ " | ||
- | # Process is dead, continue to next and assume all is well | ||
- | continue | ||
- | else | ||
- | kill " | ||
- | |||
- | # Wait up to ${delay}/10 seconds to for " | ||
- | # terminate in 10ths of a second | ||
- | |||
- | while [ " | ||
- | kill -0 " | ||
- | if [ " | ||
- | sleep 0.1 | ||
- | delay=" | ||
- | done | ||
- | |||
- | # If a fallback is set, and program is still running, then | ||
- | # use the fallback | ||
- | if [ -n " | ||
- | kill " | ||
- | sleep 1 | ||
- | # Check again, and fail if still running | ||
- | kill -0 " | ||
- | fi | ||
- | fi | ||
- | done | ||
- | fi | ||
- | |||
- | # Check for and remove stale PID files. | ||
- | if [ -z " | ||
- | # Find the basename of $program | ||
- | prefix=`echo " | ||
- | progname=`echo " | ||
- | |||
- | if [ -e "/ | ||
- | rm -f "/ | ||
- | fi | ||
- | else | ||
- | if [ -e " | ||
- | fi | ||
- | |||
- | # For signals that do not expect a program to exit, simply | ||
- | # let kill do its job, and evaluate kill's return for value | ||
- | |||
- | else # check_sig_type - signal is not used to terminate program | ||
- | for pid in ${pidlist}; do | ||
- | kill " | ||
- | if [ " | ||
- | 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 # | ||
- | # | ||
- | # # | ||
- | # 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=" | ||
- | |||
- | # Process arguments | ||
- | while true; do | ||
- | case " | ||
- | |||
- | -p) | ||
- | pidfile=" | ||
- | shift 2 | ||
- | ;; | ||
- | |||
- | *) | ||
- | program=" | ||
- | if [ -n " | ||
- | # 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 " | ||
- | # Get the program' | ||
- | prefix=`echo " | ||
- | |||
- | if [ -z " | ||
- | | ||
- | else | ||
- | | ||
- | fi | ||
- | |||
- | # If a PID file exists with that name, assume that is it. | ||
- | if [ -e "/ | ||
- | pidfile="/ | ||
- | fi | ||
- | fi | ||
- | |||
- | # If a PID file is set and exists, use it. | ||
- | if [ -n " | ||
- | # Use the value in the first line of the pidfile | ||
- | pidlist=`/ | ||
- | else | ||
- | # Use pidof | ||
- | pidlist=`pidof " | ||
- | fi | ||
- | |||
- | # Figure out if all listed PIDs are running. | ||
- | for pid in ${pidlist}; do | ||
- | kill -0 ${pid} 2> /dev/null | ||
- | |||
- | if [ " | ||
- | lpids=" | ||
- | else | ||
- | exitstatus=" | ||
- | fi | ||
- | done | ||
- | |||
- | if [ -z " | ||
- | return 3 | ||
- | else | ||
- | echo " | ||
- | return " | ||
- | 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 # | ||
- | # | ||
- | # # | ||
- | # Return values: | ||
- | # 0 - Status printed | ||
- | # 1 - Input error. The daemon to check was not specified. | ||
- | ################################################################################ | ||
- | statusproc() | ||
- | { | ||
- | local pidfile | ||
- | local pidlist | ||
- | |||
- | if [ " | ||
- | echo " | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | # Process arguments | ||
- | while true; do | ||
- | case " | ||
- | |||
- | -p) | ||
- | | ||
- | shift 2 | ||
- | ;; | ||
- | |||
- | *) | ||
- | if [ -n " | ||
- | echo "Too many arguments" | ||
- | | ||
- | else | ||
- | break | ||
- | fi | ||
- | ;; | ||
- | esac | ||
- | done | ||
- | |||
- | if [ -n " | ||
- | pidlist=`pidofproc -p " | ||
- | else | ||
- | pidlist=`pidofproc $@` | ||
- | fi | ||
- | |||
- | # Trim trailing blanks | ||
- | | ||
- | |||
- | | ||
- | |||
- | if [ -n " | ||
- | /bin/echo -e " | ||
- | " | ||
- | else | ||
- | if [ -n " | ||
- | / | ||
- | "/ | ||
- | else | ||
- | if [ -n " | ||
- | /bin/echo -e " | ||
- | " | ||
- | else | ||
- | /bin/echo -e " | ||
- | 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() | ||
- | { | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | ################################################################################ | ||
- | # log_success_msg() | ||
- | # Usage: log_success_msg [" | ||
- | # # | ||
- | # Purpose: Print a successful status message to the screen and # | ||
- | # a boot log file. # | ||
- | # # | ||
- | # Inputs: $@ - Message | ||
- | # # | ||
- | # Return values: Not used # | ||
- | ################################################################################ | ||
- | log_success_msg() | ||
- | { | ||
- | if [ " | ||
- | then | ||
- | /bin/echo -n -e " | ||
- | /bin/echo -e " | ||
- | else | ||
- | logmessage=`echo " | ||
- | /bin/echo -e " | ||
- | fi | ||
- | # Strip non-printable characters from log file | ||
- | logmessage=`echo " | ||
- | |||
- | timespec | ||
- | /bin/echo -e " | ||
- | |||
- | return 0 | ||
- | } | ||
- | |||
- | log_success_msg2() | ||
- | { | ||
- | if [ " | ||
- | then | ||
- | /bin/echo -n -e " | ||
- | /bin/echo -e " | ||
- | else | ||
- | echo " OK" | ||
- | fi | ||
- | |||
- | echo " OK" >> ${BOOTLOG} | ||
- | |||
- | return 0 | ||
- | } | ||
- | |||
- | ################################################################################ | ||
- | # log_failure_msg() | ||
- | # Usage: log_failure_msg [" | ||
- | # # | ||
- | # Purpose: Print a failure status message to the screen and # | ||
- | # a boot log file. # | ||
- | # # | ||
- | # Inputs: $@ - Message | ||
- | # # | ||
- | # Return values: Not used # | ||
- | ################################################################################ | ||
- | log_failure_msg() | ||
- | { | ||
- | if [ " | ||
- | then | ||
- | /bin/echo -n -e " | ||
- | /bin/echo -e " | ||
- | else | ||
- | logmessage=`echo " | ||
- | /bin/echo -e " | ||
- | fi | ||
- | |||
- | # Strip non-printable characters from log file | ||
- | |||
- | timespec | ||
- | logmessage=`echo " | ||
- | /bin/echo -e " | ||
- | |||
- | return 0 | ||
- | } | ||
- | |||
- | log_failure_msg2() | ||
- | { | ||
- | if [ " | ||
- | then | ||
- | /bin/echo -n -e " | ||
- | /bin/echo -e " | ||
- | else | ||
- | echo " | ||
- | fi | ||
- | |||
- | echo " | ||
- | |||
- | return 0 | ||
- | } | ||
- | |||
- | ################################################################################ | ||
- | # log_warning_msg() | ||
- | # Usage: log_warning_msg [" | ||
- | # # | ||
- | # Purpose: Print a warning status message to the screen and # | ||
- | # a boot log file. # | ||
- | # # | ||
- | # Return values: Not used # | ||
- | ################################################################################ | ||
- | log_warning_msg() | ||
- | { | ||
- | if [ " | ||
- | then | ||
- | /bin/echo -n -e " | ||
- | /bin/echo -e " | ||
- | else | ||
- | logmessage=`echo " | ||
- | /bin/echo -e " | ||
- | fi | ||
- | |||
- | # Strip non-printable characters from log file | ||
- | logmessage=`echo " | ||
- | timespec | ||
- | /bin/echo -e " | ||
- | |||
- | return 0 | ||
- | } | ||
- | |||
- | log_skip_msg() | ||
- | { | ||
- | if [ " | ||
- | then | ||
- | /bin/echo -n -e " | ||
- | /bin/echo -e " | ||
- | else | ||
- | logmessage=`echo " | ||
- | /bin/echo " | ||
- | fi | ||
- | |||
- | # Strip non-printable characters from log file | ||
- | logmessage=`echo " | ||
- | /bin/echo " | ||
- | |||
- | 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() | ||
- | { | ||
- | if [ " | ||
- | then | ||
- | /bin/echo -n -e " | ||
- | else | ||
- | logmessage=`echo " | ||
- | /bin/echo -n -e " | ||
- | fi | ||
- | |||
- | # Strip non-printable characters from log file | ||
- | logmessage=`echo " | ||
- | timespec | ||
- | /bin/echo -n -e " | ||
- | |||
- | return 0 | ||
- | } | ||
- | |||
- | log_info_msg2() | ||
- | { | ||
- | if [ " | ||
- | then | ||
- | /bin/echo -n -e " | ||
- | else | ||
- | logmessage=`echo " | ||
- | /bin/echo -n -e " | ||
- | fi | ||
- | |||
- | # Strip non-printable characters from log file | ||
- | logmessage=`echo " | ||
- | /bin/echo -n -e " | ||
- | |||
- | return 0 | ||
- | } | ||
- | |||
- | ################################################################################ | ||
- | # evaluate_retval() | ||
- | # Usage: Evaluate a return value and print success or failure 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} ] # | ||
- | # # | ||
- | # Purpose: Check for a valid signal. | ||
- | # 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 of -{signal} | ||
- | # # | ||
- | # Return values: | ||
- | # 0 - Success (signal is valid # | ||
- | # 1 - Signal is not valid # | ||
- | ################################################################################ | ||
- | check_signal() | ||
- | { | ||
- | local valsig | ||
- | |||
- | # Add error handling for invalid signals | ||
- | valsig=" | ||
- | valsig=" | ||
- | valsig=" | ||
- | valsig=" | ||
- | valsig=" | ||
- | |||
- | echo " | ||
- | |||
- | if [ " | ||
- | 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=" | ||
- | |||
- | echo " | ||
- | |||
- | if [ " | ||
- | 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 | ||
- | [ " | ||
- | | ||
- | } | ||
- | |||
- | ################################################################################ | ||
- | # is_true() | ||
- | # # | ||
- | # Purpose: Utility to test if a variable is true | yes | 1 # | ||
- | # # | ||
- | ################################################################################ | ||
- | is_true() | ||
- | { | ||
- | [ " | ||
- | [ " | ||
- | } | ||
- | |||
- | # End / | ||
- | D.3. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin mountvirtfs | ||
- | # | ||
- | # Description : Ensure proc, sysfs, run, and dev are mounted | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # Xi Ruoyao - xry111@xry111.site | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # Mounts /run (tmpfs) and /dev (devtmpfs). | ||
- | # This is done only if they are not already mounted. | ||
- | # with the kernel config proposed in the book, dev | ||
- | # should be automatically mounted by the kernel. | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | # Make sure /run is available before logging any messages | ||
- | if ! mountpoint /run >/ | ||
- | mount /run || failed=1 | ||
- | fi | ||
- | |||
- | mkdir -p / | ||
- | chmod 1777 /run/lock | ||
- | |||
- | log_info_msg " | ||
- | |||
- | if ! mountpoint /proc >/ | ||
- | | ||
- | mount -o nosuid, | ||
- | fi | ||
- | |||
- | if ! mountpoint /sys >/ | ||
- | | ||
- | mount -o nosuid, | ||
- | fi | ||
- | |||
- | if ! mountpoint /dev >/ | ||
- | | ||
- | mount -o mode=0755, | ||
- | fi | ||
- | |||
- | mkdir -p /dev/shm | ||
- | log_info_msg2 " ${INFO}/ | ||
- | mount -o nosuid, | ||
- | |||
- | mkdir -p / | ||
- | log_info_msg2 " ${INFO}/ | ||
- | mount -o nosuid, | ||
- | |||
- | (exit ${failed}) | ||
- | evaluate_retval | ||
- | if [ " | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | log_info_msg " | ||
- | ln -sf / | ||
- | |||
- | log_info_msg2 " ${INFO}/ | ||
- | ln -sf / | ||
- | |||
- | log_info_msg2 " ${INFO}/ | ||
- | ln -sf / | ||
- | |||
- | log_info_msg2 " ${INFO}/ | ||
- | ln -sfn / | ||
- | |||
- | if [ -e /proc/kcore ]; then | ||
- | | ||
- | ln -sf / | ||
- | fi | ||
- | |||
- | (exit ${failed}) | ||
- | evaluate_retval | ||
- | exit $failed | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | # End mountvirtfs | ||
- | D.4. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin modules | ||
- | # | ||
- | # Description : Module auto-loading script | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | # Assure that the kernel has module support. | ||
- | [ -e / | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | # Exit if there' | ||
- | # valid entries | ||
- | [ -r / | ||
- | grep -E -qv ' | ||
- | |||
- | log_info_msg " | ||
- | |||
- | # 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 " | ||
- | "" | ||
- | esac | ||
- | |||
- | # Attempt to load the module, passing any arguments provided. | ||
- | | ||
- | |||
- | # Print the module name if successful, otherwise take note. | ||
- | if [ $? -eq 0 ]; then | ||
- | log_info_msg2 " ${module}" | ||
- | else | ||
- | failedmod=" | ||
- | fi | ||
- | done < / | ||
- | |||
- | # 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 " | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End modules | ||
- | D.5. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin udev | ||
- | # | ||
- | # Description : Udev cold-plugging script | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # Xi Ruoyao - xry111@xry111.site | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # Device nodes are created as defined by udev. | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | if ! grep -q ' | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | / | ||
- | fi | ||
- | |||
- | # Start the udev daemon to continually watch for, and act on, | ||
- | # uevents | ||
- | SYSTEMD_LOG_TARGET=kmsg /sbin/udevd --daemon | ||
- | |||
- | # Now traverse /sys in order to " | ||
- | # already been discovered | ||
- | / | ||
- | / | ||
- | / | ||
- | |||
- | # Now wait for udevd to process the uevents we triggered | ||
- | if ! is_true " | ||
- | / | ||
- | fi | ||
- | |||
- | # If any LVM based partitions are on the system, ensure they | ||
- | # are activated so they can be used. | ||
- | if [ -x / | ||
- | |||
- | log_success_msg2 | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo "Usage ${0} {start}" | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End udev | ||
- | D.6. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin swap | ||
- | # | ||
- | # Description : Swap Control Script | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # /etc/fstab. | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | swapon -a | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | stop) | ||
- | log_info_msg " | ||
- | swapoff -a | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | | ||
- | ${0} stop | ||
- | sleep 1 | ||
- | ${0} start | ||
- | ;; | ||
- | |||
- | | ||
- | log_success_msg " | ||
- | swapon -s | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End swap | ||
- | D.7. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin setclock | ||
- | # | ||
- | # Description : Setting Linux Clock | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # hardware clock can also be set on shutdown. | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | [ -r / | ||
- | |||
- | |||
- | case " | ||
- | | ||
- | CLOCKPARAMS=" | ||
- | ;; | ||
- | |||
- | | ||
- | CLOCKPARAMS=" | ||
- | ;; | ||
- | |||
- | esac | ||
- | |||
- | case ${1} in | ||
- | | ||
- | hwclock --hctosys ${CLOCKPARAMS} >/ | ||
- | ;; | ||
- | |||
- | stop) | ||
- | log_info_msg " | ||
- | hwclock --systohc ${CLOCKPARAMS} >/ | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | |||
- | esac | ||
- | |||
- | exit 0 | ||
- | D.8. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin checkfs | ||
- | # | ||
- | # Description : File System Check | ||
- | # | ||
- | # Authors | ||
- | # A. Luebke - luebke@users.sourceforge.net | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # 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: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | if [ -f /fastboot ]; then | ||
- | | ||
- | | ||
- | | ||
- | exit 0 | ||
- | fi | ||
- | |||
- | log_info_msg " | ||
- | mount -n -o remount,ro / >/ | ||
- | |||
- | if [ ${?} != 0 ]; then | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | | ||
- | | ||
- | / | ||
- | else | ||
- | | ||
- | fi | ||
- | |||
- | if [ -f /forcefsck ]; then | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | else | ||
- | | ||
- | fi | ||
- | |||
- | log_info_msg " | ||
- | # Note: -a option used to be -p; but this fails e.g. on fsck.minix | ||
- | if is_true " | ||
- | fsck ${options} -a -A -C -T | ||
- | else | ||
- | fsck ${options} -a -A -C -T >/ | ||
- | fi | ||
- | |||
- | error_value=${? | ||
- | |||
- | if [ " | ||
- | | ||
- | fi | ||
- | |||
- | if [ " | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | fi | ||
- | |||
- | if [ " | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | | ||
- | | ||
- | | ||
- | fi | ||
- | |||
- | if [ " | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | |||
- | | ||
- | | ||
- | / | ||
- | fi | ||
- | |||
- | if [ " | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | exit ${error_value} | ||
- | fi | ||
- | |||
- | exit 0 | ||
- | ;; | ||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | # End checkfs | ||
- | D.9. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin mountfs | ||
- | # | ||
- | # Description : File System Mount Script | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # remaining local filesystems defined in /etc/fstab on | ||
- | # start. | ||
- | # remaining filesystems on stop. | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | mount --options remount,rw / >/ | ||
- | evaluate_retval | ||
- | |||
- | # Remove fsck-related file system watermarks. | ||
- | rm -f /fastboot /forcefsck | ||
- | |||
- | # Make sure /dev/pts exists | ||
- | mkdir -p /dev/pts | ||
- | |||
- | # This will mount all filesystems that do not have _netdev in | ||
- | # their option list. _netdev denotes a network filesystem. | ||
- | |||
- | log_info_msg " | ||
- | failed=0 | ||
- | mount --all --test-opts no_netdev >/ | ||
- | evaluate_retval | ||
- | exit $failed | ||
- | ;; | ||
- | |||
- | stop) | ||
- | # Don't unmount virtual file systems like /run | ||
- | log_info_msg " | ||
- | # Ensure any loop devices are removed | ||
- | losetup -D | ||
- | umount --all --detach-loop --read-only \ | ||
- | | ||
- | evaluate_retval | ||
- | |||
- | # Make sure / is mounted read only (umount bug) | ||
- | mount --options remount,ro / | ||
- | |||
- | # Make all LVM volume groups unavailable, | ||
- | # This fails if swap or / are on an LVM partition | ||
- | #if [ -x / | ||
- | if [ -r / | ||
- | | ||
- | mdadm --wait-clean --scan | ||
- | | ||
- | fi | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | # End mountfs | ||
- | D.10. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin udev_retry | ||
- | # | ||
- | # Description : Udev cold-plugging script (retry) | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # Bryan Kadzban - | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # slow hardware initialization, | ||
- | # device nodes | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | |||
- | rundir=/ | ||
- | # From Debian: "copy the rules generated before / was mounted | ||
- | # read-write": | ||
- | |||
- | for file in ${rundir}/ | ||
- | | ||
- | [ " | ||
- | cat $file >> / | ||
- | rm -f $file | ||
- | done | ||
- | |||
- | # Re-trigger the uevents that may have failed, | ||
- | # in hope they will succeed now | ||
- | /bin/sed -e ' | ||
- | while read line ; do | ||
- | for subsystem in $line ; do | ||
- | / | ||
- | done | ||
- | done | ||
- | |||
- | # Now wait for udevd to process the uevents we triggered | ||
- | if ! is_true " | ||
- | / | ||
- | fi | ||
- | |||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo "Usage ${0} {start}" | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End udev_retry | ||
- | D.11. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin cleanfs | ||
- | # | ||
- | # Description : Clean file system | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # optionally, /tmp. cleanfs also creates /run/utmp | ||
- | # and any files defined in / | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | # Function to create files/ | ||
- | create_files() | ||
- | { | ||
- | # Input to file descriptor 9 and output to stdin (redirection) | ||
- | exec 9>&0 < / | ||
- | |||
- | while read name type perm usr grp dtype maj min junk | ||
- | do | ||
- | # Ignore comments and blank lines. | ||
- | case " | ||
- | "" | ||
- | esac | ||
- | |||
- | # Ignore existing files. | ||
- | if [ ! -e " | ||
- | # Create stuff based on its type. | ||
- | case " | ||
- | dir) | ||
- | mkdir " | ||
- | ;; | ||
- | file) | ||
- | :> " | ||
- | ;; | ||
- | dev) | ||
- | case " | ||
- | char) | ||
- | mknod " | ||
- | ;; | ||
- | block) | ||
- | mknod " | ||
- | ;; | ||
- | pipe) | ||
- | mknod " | ||
- | ;; | ||
- | *) | ||
- | | ||
- | ;; | ||
- | esac | ||
- | ;; | ||
- | *) | ||
- | | ||
- | | ||
- | ;; | ||
- | esac | ||
- | |||
- | # Set up the permissions, | ||
- | chown ${usr}: | ||
- | chmod ${perm} " | ||
- | fi | ||
- | done | ||
- | |||
- | # Close file descriptor 9 (end redirection) | ||
- | exec 0>&9 9>&- | ||
- | | ||
- | } | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | |||
- | if [ " | ||
- | | ||
- | cd /tmp && | ||
- | find . -xdev -mindepth 1 ! -name lost+found -delete || failed=1 | ||
- | fi | ||
- | |||
- | > /run/utmp | ||
- | |||
- | if grep -q ' | ||
- | chmod 664 /run/utmp | ||
- | chgrp utmp /run/utmp | ||
- | fi | ||
- | |||
- | (exit ${failed}) | ||
- | evaluate_retval | ||
- | |||
- | if grep -E -qv ' | ||
- | | ||
- | | ||
- | | ||
- | fi | ||
- | |||
- | exit $failed | ||
- | ;; | ||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | # End cleanfs | ||
- | D.12. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin console | ||
- | # | ||
- | # Description : Sets keymap and screen font | ||
- | # | ||
- | # Authors | ||
- | # | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # local as defined by / | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | # Native English speakers probably don't have / | ||
- | [ -r / | ||
- | |||
- | failed=0 | ||
- | |||
- | case " | ||
- | | ||
- | # See if we need to do anything | ||
- | if [ -z " | ||
- | [ -z " | ||
- | ! is_true " | ||
- | exit 0 | ||
- | fi | ||
- | |||
- | # There should be no bogus failures below this line! | ||
- | log_info_msg " | ||
- | |||
- | # Figure out if a framebuffer console is used | ||
- | [ -d / | ||
- | |||
- | # Figure out the command to set the console into the | ||
- | # desired mode | ||
- | is_true " | ||
- | | ||
- | | ||
- | |||
- | # On framebuffer consoles, font has to be set for each vt in | ||
- | # UTF-8 mode. This doesn' | ||
- | |||
- | ! is_true " | ||
- | | ||
- | |||
- | # Apply that command to all consoles mentioned in | ||
- | # / | ||
- | # 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 ' | ||
- | grep -o ' | ||
- | do | ||
- | | ||
- | /bin/sh -c " | ||
- | done | ||
- | |||
- | # Set the font (if not already set above) and the keymap | ||
- | [ " | ||
- | |||
- | [ -z " | ||
- | | ||
- | | ||
- | |||
- | [ -z " | ||
- | | ||
- | | ||
- | |||
- | # Convert the keymap from $LEGACY_CHARSET to UTF-8 | ||
- | [ -z " | ||
- | | ||
- | | ||
- | |||
- | # If any of the commands above failed, the trap at the | ||
- | # top would set $failed to 1 | ||
- | ( exit $failed ) | ||
- | evaluate_retval | ||
- | |||
- | exit $failed | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | # End console | ||
- | D.13. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin localnet | ||
- | # | ||
- | # Description : Loopback device | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # loopback interface. | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | [ -r / | ||
- | [ -r / | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | ip addr add 127.0.0.1/8 label lo dev lo | ||
- | ip link set lo up | ||
- | evaluate_retval | ||
- | |||
- | log_info_msg " | ||
- | hostname ${HOSTNAME} | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | stop) | ||
- | log_info_msg " | ||
- | ip link set lo down | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | | ||
- | ${0} stop | ||
- | sleep 1 | ||
- | ${0} start | ||
- | ;; | ||
- | |||
- | | ||
- | echo " | ||
- | ip link show lo | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End localnet | ||
- | D.14. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin sysctl | ||
- | # | ||
- | # Description : File uses / | ||
- | # | ||
- | # | ||
- | # Authors | ||
- | # | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # / | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | if [ -f "/ | ||
- | | ||
- | | ||
- | | ||
- | fi | ||
- | ;; | ||
- | |||
- | | ||
- | sysctl -a | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End sysctl | ||
- | D.15. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin sysklogd | ||
- | # | ||
- | # Description : Sysklogd loader | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # Update | ||
- | # | ||
- | # | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # /etc/fstab. | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | parms=${SYSKLOGD_PARMS-' | ||
- | start_daemon / | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | stop) | ||
- | log_info_msg " | ||
- | killproc / | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | | ||
- | log_info_msg " | ||
- | pid=`pidofproc syslogd` | ||
- | kill -HUP " | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | | ||
- | ${0} stop | ||
- | sleep 1 | ||
- | ${0} start | ||
- | ;; | ||
- | |||
- | | ||
- | statusproc / | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End sysklogd | ||
- | D.16. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin network | ||
- | # | ||
- | # Description : Network Control Script | ||
- | # | ||
- | # Authors | ||
- | # | ||
- | # Kevin P. Fleming - kpfleming@linuxfromscratch.org | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | case " | ||
- | | ||
- | # if the default route exists, network is already configured | ||
- | if ip route | grep -q " | ||
- | # Start all network interfaces | ||
- | for file in / | ||
- | do | ||
- | | ||
- | |||
- | # Skip if $file is * (because nothing was found) | ||
- | if [ " | ||
- | |||
- | / | ||
- | done | ||
- | ;; | ||
- | |||
- | stop) | ||
- | # Unmount any network mounted file systems | ||
- | | ||
- | |||
- | # Reverse list | ||
- | net_files="" | ||
- | for file in / | ||
- | do | ||
- | | ||
- | done | ||
- | |||
- | # Stop all network interfaces | ||
- | for file in ${net_files} | ||
- | do | ||
- | | ||
- | |||
- | # Skip if $file is * (because nothing was found) | ||
- | if [ " | ||
- | |||
- | # See if interface exists | ||
- | if [ ! -e / | ||
- | |||
- | # Is interface UP? | ||
- | ip link show $interface 2>/ | ||
- | if [ $? -ne 0 ]; then continue; fi | ||
- | |||
- | / | ||
- | done | ||
- | ;; | ||
- | |||
- | | ||
- | ${0} stop | ||
- | sleep 1 | ||
- | ${0} start | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End network | ||
- | D.17. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin sendsignals | ||
- | # | ||
- | # Description : Sendsignals Script | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | stop) | ||
- | omit=$(pidof mdmon) | ||
- | [ -n " | ||
- | |||
- | log_info_msg " | ||
- | killall5 -15 $omit | ||
- | error_value=${? | ||
- | |||
- | sleep ${KILLDELAY} | ||
- | |||
- | if [ " | ||
- | | ||
- | else | ||
- | | ||
- | fi | ||
- | |||
- | log_info_msg " | ||
- | killall5 -9 $omit | ||
- | error_value=${? | ||
- | |||
- | sleep ${KILLDELAY} | ||
- | |||
- | if [ " | ||
- | | ||
- | else | ||
- | | ||
- | fi | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | |||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End sendsignals | ||
- | D.18. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin reboot | ||
- | # | ||
- | # Description : Reboot Scripts | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Updates | ||
- | # : Pierre Labastie - pierre AT linuxfromscratch D0T org | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : Update March 24th, 2022: change " | ||
- | # Add the $last facility to Required-start | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | reboot -d -f -i | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | |||
- | esac | ||
- | |||
- | # End reboot | ||
- | D.19. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin halt | ||
- | # | ||
- | # Description : Halt Script | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # : Pierre Labastie - pierre AT linuxfromscratch D0T org | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : Update March 24th, 2022: change " | ||
- | # Add the $last facility to Required-start | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | case " | ||
- | | ||
- | halt -d -f -i -p | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | # End halt | ||
- | D.20. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin scriptname | ||
- | # | ||
- | # Description : | ||
- | # | ||
- | # Authors | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | ### BEGIN INIT INFO | ||
- | # Provides: | ||
- | # Required-Start: | ||
- | # Should-Start: | ||
- | # Required-Stop: | ||
- | # Should-Stop: | ||
- | # Default-Start: | ||
- | # Default-Stop: | ||
- | # Short-Description: | ||
- | # Description: | ||
- | # X-LFS-Provided-By: | ||
- | ### END INIT INFO | ||
- | |||
- | . / | ||
- | |||
- | case " | ||
- | | ||
- | log_info_msg " | ||
- | # if it is possible to use start_daemon | ||
- | start_daemon fully_qualified_path | ||
- | # if it is not possible to use start_daemon | ||
- | # (command to start the daemon is not simple enough) | ||
- | if ! pidofproc daemon_name_as_reported_by_ps >/ | ||
- | | ||
- | fi | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | stop) | ||
- | log_info_msg " | ||
- | # if it is possible to use killproc | ||
- | killproc fully_qualified_path | ||
- | # if it is not possible to use killproc | ||
- | # (the daemon shouldn' | ||
- | if pidofproc daemon_name_as_reported_by_ps >/ | ||
- | | ||
- | fi | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | | ||
- | ${0} stop | ||
- | sleep 1 | ||
- | ${0} start | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | exit 0 | ||
- | |||
- | # End scriptname | ||
- | D.21. / | ||
- | ######################################################################## | ||
- | # Begin / | ||
- | # | ||
- | # Description : Module auto-loading configuration | ||
- | # | ||
- | # Authors | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : The syntax of this file is as follows: | ||
- | # < | ||
- | # | ||
- | # Each module should be on its 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 / | ||
- | D.22. / | ||
- | ######################################################################## | ||
- | # Begin / | ||
- | # | ||
- | # Description : Createfiles script config file | ||
- | # | ||
- | # Authors | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : The syntax of this file is as follows: | ||
- | # if type is equal to " | ||
- | # < | ||
- | # if type is equal to " | ||
- | # < | ||
- | # < | ||
- | # | ||
- | # < | ||
- | # < | ||
- | # file creates a new file | ||
- | # dir creates a new directory | ||
- | # dev creates a new device | ||
- | # < | ||
- | # block creates a block device | ||
- | # char creates a character device | ||
- | # pipe creates a pipe, this will ignore the < | ||
- | # < | ||
- | # < | ||
- | # the device. | ||
- | ######################################################################## | ||
- | |||
- | # End / | ||
- | D.23. / | ||
- | ######################################################################## | ||
- | # Begin / | ||
- | # | ||
- | # Description : udev_retry script configuration | ||
- | # | ||
- | # Authors | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : Each subsystem that may need to be re-triggered after mountfs | ||
- | # runs should be listed in this file. Probable subsystems to be | ||
- | # | ||
- | # (due to both / | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | rtc | ||
- | |||
- | # End / | ||
- | D.24. /sbin/ifup | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin /sbin/ifup | ||
- | # | ||
- | # Description : Interface Up | ||
- | # | ||
- | # Authors | ||
- | # Kevin P. Fleming - kpfleming@linuxfromscratch.org | ||
- | # Update | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : The IFCONFIG variable is passed to the SERVICE script | ||
- | # in the / | ||
- | # | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | up() | ||
- | { | ||
- | log_info_msg " | ||
- | |||
- | if ip link show $1 > /dev/null 2>& | ||
- | | ||
- | |||
- | if [ -n " | ||
- | if ! echo " | ||
- | ip link set $1 up | ||
- | fi | ||
- | fi | ||
- | |||
- | else | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | evaluate_retval | ||
- | } | ||
- | |||
- | RELEASE=" | ||
- | |||
- | USAGE=" | ||
- | VERSTR=" | ||
- | |||
- | while [ $# -gt 0 ]; do | ||
- | case " | ||
- | --help | -h) | ||
- | |||
- | --version | -V) echo " | ||
- | |||
- | -*) echo "ifup: ${1}: invalid option" | ||
- | echo " | ||
- | exit 2 ;; | ||
- | |||
- | *) break ;; | ||
- | esac | ||
- | done | ||
- | |||
- | if [ -n " | ||
- | echo " | ||
- | echo " | ||
- | echo | ||
- | cat << HERE_EOF | ||
- | ifup is used to bring up a network interface. | ||
- | parameter, e.g. eth0 or eth0:2, must match the trailing part of the | ||
- | interface specifications file, e.g. / | ||
- | |||
- | HERE_EOF | ||
- | exit 0 | ||
- | fi | ||
- | |||
- | file=/ | ||
- | |||
- | # Skip backup files | ||
- | [ " | ||
- | |||
- | . / | ||
- | |||
- | if [ ! -r " | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | . $file | ||
- | |||
- | if [ " | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | # Do not process this service if started by boot, and ONBOOT | ||
- | # is not set to yes | ||
- | if [ " | ||
- | exit 0 | ||
- | fi | ||
- | |||
- | # Bring up the interface | ||
- | if [ " | ||
- | up ${IFACE} | ||
- | fi | ||
- | |||
- | for S in ${SERVICE}; do | ||
- | if [ ! -x "/ | ||
- | MSG=" | ||
- | MSG=" | ||
- | MSG=" | ||
- | log_failure_msg " | ||
- | exit 1 | ||
- | fi | ||
- | done | ||
- | |||
- | #if [ " | ||
- | |||
- | # Create/ | ||
- | for S in ${SERVICE}; do | ||
- | IFCONFIG=${file} / | ||
- | done | ||
- | |||
- | # Set link up virtual interfaces | ||
- | if [ " | ||
- | up ${IFACE} | ||
- | fi | ||
- | |||
- | # Bring up any additional interface components | ||
- | for I in $INTERFACE_COMPONENTS; | ||
- | |||
- | # Set MTU if requested. Check if MTU has a " | ||
- | if test -n " | ||
- | if [[ ${MTU} =~ ^[0-9]+$ ]] && [[ $MTU -ge 68 ]] ; then | ||
- | for I in $IFACE $INTERFACE_COMPONENTS; | ||
- | ip link set dev $I mtu $MTU; | ||
- | done | ||
- | else | ||
- | log_info_msg2 " | ||
- | fi | ||
- | fi | ||
- | |||
- | # Set the route default gateway if requested | ||
- | if [ -n " | ||
- | if ip route | grep -q default; then | ||
- | log_warning_msg " | ||
- | else | ||
- | log_info_msg " | ||
- | ip route add default via ${GATEWAY} dev ${IFACE} | ||
- | evaluate_retval | ||
- | fi | ||
- | fi | ||
- | |||
- | # End /sbin/ifup | ||
- | D.25. / | ||
- | #!/bin/bash | ||
- | ######################################################################## | ||
- | # Begin / | ||
- | # | ||
- | # Description : Interface Down | ||
- | # | ||
- | # Authors | ||
- | # Kevin P. Fleming - kpfleming@linuxfromscratch.org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | # Notes : the IFCONFIG variable is passed to the scripts found | ||
- | # in the / | ||
- | # | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | RELEASE=" | ||
- | |||
- | USAGE=" | ||
- | VERSTR=" | ||
- | |||
- | while [ $# -gt 0 ]; do | ||
- | case " | ||
- | --help | -h) | ||
- | |||
- | --version | -V) echo " | ||
- | |||
- | -*) echo "ifup: ${1}: invalid option" | ||
- | echo " | ||
- | exit 2 ;; | ||
- | |||
- | *) break ;; | ||
- | esac | ||
- | done | ||
- | |||
- | if [ -n " | ||
- | echo " | ||
- | echo " | ||
- | echo | ||
- | cat << HERE_EOF | ||
- | ifdown is used to bring down a network interface. | ||
- | parameter, e.g. eth0 or eth0:2, must match the trailing part of the | ||
- | interface specifications file, e.g. / | ||
- | |||
- | HERE_EOF | ||
- | exit 0 | ||
- | fi | ||
- | |||
- | file=/ | ||
- | |||
- | # Skip backup files | ||
- | [ " | ||
- | |||
- | . / | ||
- | |||
- | if [ ! -r " | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | . ${file} | ||
- | |||
- | if [ " | ||
- | | ||
- | 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>& | ||
- | if [ -n " | ||
- | | ||
- | else | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | else | ||
- | | ||
- | fi | ||
- | |||
- | # Leave the interface up if there are additional interfaces in the device | ||
- | link_status=`ip link show ${IFACE} 2>/ | ||
- | |||
- | if [ -n " | ||
- | if [ " | ||
- | if [ "$(ip addr show ${IFACE} | grep 'inet ' | ||
- | | ||
- | ip link set ${IFACE} down | ||
- | | ||
- | fi | ||
- | fi | ||
- | fi | ||
- | |||
- | # End / | ||
- | D.26. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin / | ||
- | # | ||
- | # Description : IPV4 Static Boot Script | ||
- | # | ||
- | # Authors | ||
- | # Kevin P. Fleming - kpfleming@linuxfromscratch.org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | . / | ||
- | . ${IFCONFIG} | ||
- | |||
- | if [ -z " | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | if [ -z " | ||
- | | ||
- | | ||
- | | ||
- | |||
- | elif [ -n " | ||
- | | ||
- | exit 1 | ||
- | |||
- | elif [ -n " | ||
- | | ||
- | |||
- | elif [ -n " | ||
- | | ||
- | fi | ||
- | |||
- | if [ -n " | ||
- | | ||
- | fi | ||
- | |||
- | if [ -n " | ||
- | | ||
- | fi | ||
- | |||
- | case " | ||
- | up) | ||
- | if [ "$(ip addr show ${1} 2>/ | ||
- | | ||
- | ip addr add ${args} dev ${1} | ||
- | | ||
- | else | ||
- | | ||
- | fi | ||
- | ;; | ||
- | |||
- | down) | ||
- | if [ "$(ip addr show ${1} 2>/ | ||
- | | ||
- | ip addr del ${args} dev ${1} | ||
- | | ||
- | fi | ||
- | |||
- | if [ -n " | ||
- | # Only remove the gateway if there are no remaining ipv4 addresses | ||
- | if [ "$(ip addr show ${1} 2>/ | ||
- | log_info_msg " | ||
- | ip route del default | ||
- | evaluate_retval | ||
- | fi | ||
- | fi | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | # End / | ||
- | D.27. / | ||
- | #!/bin/sh | ||
- | ######################################################################## | ||
- | # Begin / | ||
- | # | ||
- | # Description : IPV4 Static Route Script | ||
- | # | ||
- | # Authors | ||
- | # DJ Lucas - dj AT linuxfromscratch D0T org | ||
- | # Update | ||
- | # | ||
- | # Version | ||
- | # | ||
- | ######################################################################## | ||
- | |||
- | . / | ||
- | . ${IFCONFIG} | ||
- | |||
- | case " | ||
- | | ||
- | need_ip=1 | ||
- | need_gateway=1 | ||
- | ;; | ||
- | |||
- | | ||
- | need_gateway=1 | ||
- | args=" | ||
- | desc=" | ||
- | ;; | ||
- | |||
- | | ||
- | need_ip=1 | ||
- | ;; | ||
- | |||
- | | ||
- | need_ip=1 | ||
- | args=" | ||
- | desc=" | ||
- | ;; | ||
- | |||
- | (*) | ||
- | log_failure_msg " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | if [ -n " | ||
- | | ||
- | | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | if [ -n " | ||
- | if [ -z " | ||
- | log_failure_msg "IP variable missing from ${IFCONFIG}, | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | if [ -z " | ||
- | log_failure_msg " | ||
- | exit 1 | ||
- | fi | ||
- | |||
- | | ||
- | | ||
- | fi | ||
- | |||
- | if [ -n " | ||
- | if [ -z " | ||
- | log_failure_msg " | ||
- | exit 1 | ||
- | fi | ||
- | | ||
- | fi | ||
- | |||
- | if [ -n " | ||
- | args=" | ||
- | fi | ||
- | |||
- | case " | ||
- | up) | ||
- | log_info_msg " | ||
- | ip route add ${args} dev ${1} | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | down) | ||
- | log_info_msg " | ||
- | ip route del ${args} dev ${1} | ||
- | evaluate_retval | ||
- | ;; | ||
- | |||
- | *) | ||
- | echo " | ||
- | exit 1 | ||
- | ;; | ||
- | esac | ||
- | |||
- | # End / |
software/linux_server/lfs/appendices/boot_and_sysconfig_scripts.1740305265.txt.gz · Последнее изменение: — vladpolskiy