diff options
Diffstat (limited to 'bootscripts/contrib/lsb-v3/sysconfig')
8 files changed, 519 insertions, 0 deletions
diff --git a/bootscripts/contrib/lsb-v3/sysconfig/createfiles b/bootscripts/contrib/lsb-v3/sysconfig/createfiles new file mode 100644 index 000000000..8d1f89dc6 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sysconfig/createfiles @@ -0,0 +1,28 @@ +######################################################################## +# Begin /etc/sysconfig/createfiles +# +# Description : Createfiles script config file +# +# Authors : +# +# Version : 00.00 +# +# Notes : The syntax of this file is as follows: +# if type is equal to "file" or "dir" +# <filename> <type> <permissions> <user> <group> +# if type is equal to "dev" +# <filename> <type> <permissions> <user> <group> <devtype> <major> <minor> +# +# <filename> is the name of the file which is to be created +# <type> is either file, dir, or dev. +# file creates a new file +# dir creates a new directory +# dev creates a new device +# <devtype> is either block, char or pipe +# block creates a block device +# char creates a character deivce +# pipe creates a pipe, this will ignore the <major> and <minor> fields +# <major> and <minor> are the major and minor numbers used for the device. +######################################################################## + +# End /etc/sysconfig/createfiles diff --git a/bootscripts/contrib/lsb-v3/sysconfig/modules b/bootscripts/contrib/lsb-v3/sysconfig/modules new file mode 100644 index 000000000..1c8493d45 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sysconfig/modules @@ -0,0 +1,18 @@ +######################################################################## +# Begin /etc/sysconfig/modules +# +# Description : Module auto-loading configuration +# +# Authors : +# +# Version : 00.00 +# +# Notes : The syntax of this file is as follows: +# <module> [<arg1> <arg2> ...] +# +# Each module should be on it's own line, and any options that you want +# passed to the module should follow it. The line deliminator is either +# a space or a tab. +######################################################################## + +# End /etc/sysconfig/modules diff --git a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifdown b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifdown new file mode 100644 index 000000000..28d1f1813 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifdown @@ -0,0 +1,93 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/ifdown +# +# Description : Interface Down +# +# Authors : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.01 +# +# Notes : the IFCONFIG variable is passed to the scripts found +# in the services directory, to indicate what file the +# service should source to get environmental variables. +# +######################################################################## + +. /lib/lsb/init-functions + +# Collect a list of configuration files for our interface +if [ -n "${2}" ]; then + for file in ${@#$1}; do # All parameters except $1 + FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}" + done +elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then + FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*` +else + FILES="${NETWORK_DEVICES}/ifconfig.${1}" +fi + +# Reverse the order configuration files are processed in +for file in ${FILES}; do + FILES2="${file} ${FILES2}" +done +FILES=${FILES2} + +# Process each configuration file +for file in ${FILES}; do + # skip backup files + if [ "${file}" != "${file%""~""}" ]; then + continue + fi + + if [ ! -f "${file}" ]; then + message="${file} is not a network configuration file or directory." + log_warning_msg + fi + ( + . ${file} + + # Will not process this service if started by boot, and ONBOOT + # is not set to yes + if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then + continue + fi + + # Will not process this service if started by hotplug, and + # ONHOTPLUG is not set to yes + if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" ]; then + continue + fi + + # This will run the service script, if SERVICE is set + if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then + if ip link show ${1} > /dev/null 2>&1 + then + IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} down + else + message="Interface ${1} doesn't exist." + log_warning_msg + fi + else + echo -e "${FAILURE}Unable to process ${file}. Either" + echo -e "${FAILURE}the SERVICE variable was not set," + echo -e "${FAILURE}or the specified service cannot be executed." + message="" + log_failure_msg + fi + ) +done + +if [ -z "${2}" ]; then + link_status=`ip link show $1` + if [ -n "${link_status}" ]; then + if echo "${link_status}" | grep -q UP; then + message="Bringing down the ${1} interface..." + ip link set ${1} down + evaluate_retval standard + fi + fi +fi + +# End $NETWORK_DEVICES/ifdown diff --git a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifup b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifup new file mode 100644 index 000000000..50e173ca6 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/ifup @@ -0,0 +1,87 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/ifup +# +# Description : Interface Up +# +# Authors : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.00 +# +# Notes : the IFCONFIG variable is passed to the scripts found +# in the services directory, to indicate what file the +# service should source to get environmental variables. +# +######################################################################## + +. /lib/lsb/init-functions + +# Collect a list of configuration files for our interface +if [ -n "${2}" ]; then + for file in ${@#$1} # All parameters except $1 + do + FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}" + done +elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then + FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*` +else + FILES="${NETWORK_DEVICES}/ifconfig.${1}" +fi + +message="Bringing up the ${1} interface..." + +# Process each configruation file +for file in ${FILES}; do + # skip backup files + if [ "${file}" != "${file%""~""}" ]; then + continue + fi + + if [ ! -f "${file}" ]; then + log_warning_msg + message="${file} is not a network configuration file or directory." + log_warning_msg + fi + + ( + . ${file} + + # Will not process this service if started by boot, and ONBOOT + # is not set to yes + if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then + continue + fi + # Will not process this service if started by hotplug, and + # ONHOTPLUG is not set to yes + if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" -a "${HOSTNAME}" != "(none)" ]; then + continue + fi + + if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then + if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then + if ip link show ${1} > /dev/null 2>&1; then + link_status=`ip link show ${1}` + if [ -n "${link_status}" ]; then + if ! echo "${link_status}" | grep -q UP; then + ip link set ${1} up + evaluate_retval standard + fi + fi + else + message="${message}Interface ${1} doesn't exist." + log_warning_msg + fi + fi + IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} up + else + echo -e "${FAILURE}Unable to process ${file}. Either" + echo -e "${FAILURE}the SERVICE variable was not set," + echo -e "${FAILURE}or the specified service cannot be executed." + message="" + log_failure_msg + fi + ) +done + +# End $NETWORK_DEVICES/ifup diff --git a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static new file mode 100644 index 000000000..417d22de6 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static @@ -0,0 +1,80 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/services/ipv4-static +# +# Description : IPV4 Static Boot Script +# +# Authors : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.00 +# +# Notes : +# +######################################################################## + +. /lib/lsb/init-functions +. ${IFCONFIG} + +if [ -z "${IP}" ]; then + log_failure_msg "IP variable missing from ${IFCONFIG}, cannot continue." + exit 1 +fi + +if [ -z "${PREFIX}" -a -z "${PEER}" ]; then + log_warning_msg "PREFIX variable missing from ${IFCONFIG}, assuming 24." + PREFIX=24 + args="${args} ${IP}/${PREFIX}" +elif [ -n "${PREFIX}" -a -n "${PEER}" ]; then + log_failure_msg "PREFIX and PEER both specified in ${IFCONFIG}, cannot continue." + exit 1 +elif [ -n "${PREFIX}" ]; then + args="${args} ${IP}/${PREFIX}" +elif [ -n "${PEER}" ]; then + args="${args} ${IP} peer ${PEER}" +fi + +if [ -n "${BROADCAST}" ]; then + args="${args} broadcast ${BROADCAST}" +fi + +if [ -n "${SOURCE}" ]; then + args="${args} src ${SOURCE}" +fi + +case "${2}" in + up) + MESSAGE="Adding IPv4 address ${IP} to the ${1} interface..." + ip addr add ${args} dev ${1} + evaluate_retval + + if [ -n "${GATEWAY}" ]; then + if ip route | grep -q default; then + log_warning_msg "Gateway already setup; skipping." ${WARNING} + else + MESSAGE="Setting up default gateway..." + ip route add default via ${GATEWAY} dev ${1} + evaluate_retval + fi + fi + ;; + + down) + if [ -n "${GATEWAY}" ]; then + MESSAGE="Removing default gateway..." + ip route del default + evaluate_retval + fi + + MESSAGE="Removing IPv4 address ${IP} from the ${1} interface..." + ip addr del ${args} dev ${1} + evaluate_retval + ;; + + *) + echo "Usage: ${0} [interface] {up|down}" + exit 1 + ;; +esac + +# End $NETWORK_DEVICES/services/ipv4-static diff --git a/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static-route b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static-route new file mode 100644 index 000000000..4205a022d --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sysconfig/network-devices/services/ipv4-static-route @@ -0,0 +1,92 @@ +#!/bin/sh +######################################################################## +# Begin $NETWORK_DEVICES/services/ipv4-static-route +# +# Description : IPV4 Static Route Script +# +# Authors : Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 00.00 +# +# Notes : +# +######################################################################## + +. /lib/lsb/init-functions +. ${IFCONFIG} + +case "${TYPE}" in + ("" | "network") + need_ip=1 + need_gateway=1 + ;; + + ("default") + need_gateway=1 + args="${args} default" + desc="default" + ;; + + ("host") + need_ip=1 + ;; + + ("unreachable") + need_ip=1 + args="${args} unreachable" + desc="unreachable " + ;; + + (*) + boot_mesg "Unknown route type (${TYPE}) in ${IFCONFIG}, cannot continue." ${FAILURE} + echo_failure + exit 1 + ;; +esac + +if [ -n "${need_ip}" ]; then + if [ -z "${IP}" ]; then + boot_mesg "IP variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} + echo_failure + exit 1 + fi + + if [ -z "${PREFIX}" ]; then + boot_mesg "PREFIX variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} + echo_failure + exit 1 + fi + + args="${args} ${IP}/${PREFIX}" + desc="${desc}${IP}/${PREFIX}" +fi + +if [ -n "${need_gateway}" ]; then + if [ -z "${GATEWAY}" ]; then + boot_mesg "GATEWAY variable missing from ${IFCONFIG}, cannot continue." ${FAILURE} + echo_failure + exit 1 + fi + args="${args} via ${GATEWAY}" +fi + +case "${2}" in + up) + boot_mesg "Adding '${desc}' route to the ${1} interface..." + ip route add ${args} dev ${1} + evaluate_retval + ;; + + down) + boot_mesg "Removing '${desc}' route from the ${1} interface..." + ip route del ${args} dev ${1} + evaluate_retval + ;; + + *) + echo "Usage: ${0} [interface] {up|down}" + exit 1 + ;; +esac + +# End $NETWORK_DEVICES/services/ipv4-static-route diff --git a/bootscripts/contrib/lsb-v3/sysconfig/rc b/bootscripts/contrib/lsb-v3/sysconfig/rc new file mode 100644 index 000000000..ffb70d98c --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sysconfig/rc @@ -0,0 +1,52 @@ +# Begin /etc/sysconfig/rc + +# Author: DJ Lucas - dj@linuxfromscratch.org +# Version: 1.0 LSB V.3.1 + +# Global variable inherited by initscripts are in caps +# Local variables for the rc script are in lowercase + +# Source site specific rc configuration +. /etc/sysconfig/rc.site + +# This sets default terminal options. +# stty sane - this has been removed as nobody recalls +# the reason for it in the first place - if no problems arize, +# then it will be removed completely at a later date. + +# Setup default values for the environment +umask 022 +PATH="/bin:/sbin" + +# Find current screen size +if [ -z "${COLUMNS}" ]; then + COLUMNS=$(stty size) + COLUMNS=${COLUMNS##* } +fi + +# When using remote connections, such as a serial port, stty size returns 0 +if [ "${COLUMNS}" = "0" ]; then + COLUMNS=80 +fi + +## Measurements for positioning result messages +COL=$((${COLUMNS} - 8)) +WCOL=$((${COL} - 2)) + +# Set Cursur Position Commands, used via echo -e +SET_COL="\\033[${COL}G" # at the $COL char +SET_WCOL="\\033[${WCOL}G" # at the $WCOL char +CURS_UP="\\033[1A\\033[0G" # Up one line, at the 0'th char + +# Bootlogging and interactive startup require a valid tempfs mount +# if this mount is not present, disable them +if [ "${TEMPFS_MOUNT}" = "" -o ! -d "${TEMPFS_MOUNT}" ]; then + TEMPFS_MOUNT="" + iprompt="" + BOOTLOG_ENAB="" +fi + +# Export the environment variables so they are inherited by the scripts +export PATH SET_COL SET_WCOL CURS_UP TEMPFS_MOUNT BOOTLOG_ENAB RUNLEVEL + +# End /etc/sysconfig/rc diff --git a/bootscripts/contrib/lsb-v3/sysconfig/rc.site b/bootscripts/contrib/lsb-v3/sysconfig/rc.site new file mode 100644 index 000000000..cf58e2fd7 --- /dev/null +++ b/bootscripts/contrib/lsb-v3/sysconfig/rc.site @@ -0,0 +1,69 @@ +# Set base directory information +RC_BASE="/etc" +RC_FUNCTIONS="${RC_BASE}/init.d/lfs-functions" + +# Location of network device scripts and config files +NETWORK_DEVICES="/etc/sysconfig/network-devices" + +# Directory to store boot process accounting information +# Used for boot logging and interactive flag when rootfs +# is not writable +TEMPFS_MOUNT="${RC_BASE}/init.d/boottemp" + +# Bootlogging (requires a tempfs mount) +BOOTLOG_ENAB="yes" + +# Distro Information +DISTRO="Linux From Scratch" # The distro name +DISTRO_CONTACT="lfs-dev@linuxfromscratch.org" # Bug report address +DISTRO_MINI="lfs" # Short name used in filenames for distro config + +# Define custom colors used in messages printed to the screen +BRACKET="\\033[1;34m" # Blue +FAILURE="\\033[1;31m" # Red +INFO="\\033[1;36m" # Cyan +NORMAL="\\033[0;39m" # Grey +SUCCESS="\\033[1;32m" # Green +WARNING="\\033[1;33m" # Yellow + +# Prefix boot messages for easier reading on framebuffer consoles +PREFIX_SUCCESS=" ${SUCCESS}*${NORMAL} " +PREFIX_WARNING="${WARNING}**${NORMAL} " +PREFIX_FAILURE="${FAILURE}***${NORMAL}" + +# Export varialbles so that they are inherited by the initscripts +export RC_BASE RC_FUNCTIONS NETWORK_DEVICES TEMPFS_MOUNT BOOTLOG_ENAB +export DISTRO DISTRO_CONTACT DISTRO_MINI +export BRACKET FAILURE INFO NORMAL SUCCESS WARNING +export PREFIX_SUCCESS PREFIX_WARNING PREFIX_FAILURE + +# Interactive startup +iprompt="yes" # Wether to display the interactive boot promp +itime="2" # The ammount of time (in seconds) to display the prompt +dlen="29" # The total length of the distro welcome string +ilen="38" # The total length of the interactive message +welcome_message="Welcome to ${INFO}${DISTRO}${NORMAL}" +i_message="Press '${FAILURE}I${NORMAL}' to enter interactive startup" + +# Error message displayed when a script's exit value is not zero +print_error_msg() +{ + # ${link} and ${error_value} are defined by the rc script + echo -e "${FAILURE}FAILURE: You should not be reading this error message." + echo -e "" + echo -e -n "${FAILURE}It means that an unforseen error took place in" + echo -e -n "${INFO} ${link}" + echo -e "${FAILURE}," + echo -e "${FAILURE}which exited with a return value of ${error_value}." + echo -e "" + echo -e -n "${FAILURE}If you are able to track this error down to a bug" + echo -e "${FAILURE}in one of the files" + echo -e -n "provided by ${INFO}${DISTRO}${FAILURE}, " + echo -e -n "${FAILURE}please be so kind to inform us at " + echo -e "${INFO}${DISTRO_CONTACT}${FAILURE}.${NORMAL}" + echo -e "" + echo -e "${INFO}Press Enter to continue..." + echo -e "${NORMAL}" + read ENTER +} + |