src/functions/functions.routing \
src/functions/functions.serial \
src/functions/functions.service \
+ src/functions/functions.settings \
src/functions/functions.stp \
src/functions/functions.sysctl \
src/functions/functions.teredo \
. /usr/lib/network/functions
-# Read firewall configuration.
-firewall_config_read
+# Read firewall settings
+firewall_settings_read
-firewall_cli_config "$@"
+firewall_cli_settings "$@"
exit ${EXIT_ERROR}
. /usr/lib/network/functions
-# Read firewall configuration.
-firewall_config_read
+# Read firewall settings
+firewall_settings_read
firewall_cli "ipv4" "$@"
. /usr/lib/network/functions
-# Read firewall configuration.
-firewall_config_read
+# Read firewall settings
+firewall_settings_read
firewall_cli "ipv6" "$@"
firewall_panic ${admin_hosts}
}
-function firewall_cli_config() {
+function firewall_cli_settings() {
if cli_help_requested $@; then
- cli_show_man firewall-config
+ cli_show_man firewall-settings
exit ${EXIT_OK}
fi
if [ -n "${1}" ]; then
- config_set "$@"
- firewall_config_write
+ settings_set "$@"
+ firewall_settings_write
else
- firewall_config_print
+ firewall_settings_print
fi
}
# #
###############################################################################
-function config_read() {
- local file=${1}
- assert isset file
- shift
-
- local valid_keys=$@
-
- # Exit if the file cannot be read.
- [ -r "${file}" ] || return ${EXIT_ERROR}
-
- local line key val
- while read -r line; do
- case "${line}" in
- *=*)
- key=$(cli_get_key ${line})
-
- # If valid keys is set, key must be in the list.
- if [ -n "${valid_keys}" ]; then
- if ! listmatch ${key} ${valid_keys}; then
- log DEBUG "Ignoring configuration setting: ${key}"
- continue
- fi
- fi
-
- val=$(cli_get_val ${line})
- val=$(config_strip ${val})
-
- # Assign variable.
- printf -v ${key} "%s" "${val}"
- ;;
- *)
- log DEBUG "Invalid line in configuration file: ${line}"
- ;;
- esac
- done < ${file}
-}
-
-function config_read_array() {
- local file=${1}
- assert isset file
- shift
-
- local array=${1}
- assert isset array
- shift
-
- local valid_keys=$@
-
- # Exit if the file cannot be read.
- [ -r "${file}" ] || return ${EXIT_ERROR}
-
- local line key val
- while read -r line; do
- case "${line}" in
- *=*)
- key=$(cli_get_key ${line})
-
- # If valid_keys is set, key must be in the list.
- if [ -n "${valid_keys}" ]; then
- if ! listmatch ${key} ${valid_keys}; then
- log DEBUG "Ignoring configuration setting: ${key}"
- continue
- fi
- fi
-
- val=$(cli_get_val ${line})
- val=$(config_strip ${val})
-
- # Assign variable.
- printf -v "${array}["${key}"]" "%s" "${val}"
- ;;
- *)
- log DEBUG "Invalid line in configuration file: ${line}"
- ;;
- esac
- done < ${file}
-}
-
-# Strip leading and trailing "s.
-function config_strip() {
- local var="$@"
-
- # Do nothing for strings that contain spaces.
- if contains_spaces ${var}; then
- print "${var}"
- return ${EXIT_OK}
- fi
-
- unquote "${var}"
-}
-
-function config_write() {
- local config_file=${1}
- assert isset config_file
- shift
-
- # Check if all values to be written are sane
- if ! config_check; then
- log CRITICAL "Configuration check failed. No config has been written."
- return ${EXIT_ERROR}
- fi
-
- log DEBUG "Writing configuration file ${config_file}."
-
- mkdir -p $(dirname ${config_file}) 2>/dev/null
- > ${config_file}
-
- local param
- for param in $(listsort $@); do
- echo "${param}=\"${!param}\"" >> ${config_file}
- done
-}
-
-function config_remove() {
- local config_file="${1}"
-
- local abspath="$(readlink -e "${config_file}")"
- if [ "${config_file}" != "${abspath}" ]; then
- log ERROR "Can only handle absolute paths"
- return ${EXIT_ERROR}
- fi
-
- rm -f "${config_file}"
-}
-
-function config_print() {
- local param
-
- for param in $(listsort $@); do
- printf "%-32s = %s\n" "${param}" "${!param}"
- done
-}
-
-function config_check() {
- # If there is a function defined that is called __check
- # we call that function
- if [ -n "$(type -t _check)" ]; then
- _check || return $?
- fi
-
- return ${EXIT_OK}
-}
-
function config_header() {
local what=${1}
assert isset what
# the domain part.
print "${hostname#*.}"
}
-
-function config_set() {
- while [ $# -gt 0 ]; do
- case "${1}" in
- *=*)
- local key=$(cli_get_key ${1})
- local val=$(cli_get_val ${1})
-
- log INFO "Setting configuration option '${key}=${val}'".
-
- printf -v ${key} "%s" "${val}"
- ;;
- *)
- warning "Invalid parameter given: ${1}"
- ;;
- esac
- shift
- done
-}
-
-function network_config_read() {
- local options=${NETWORK_CONFIG_FILE_PARAMS}
-
- # If the DEBUG variable has already been set,
- # don't overwrite it.
- if [ -n "${DEBUG}" ]; then
- list_remove options DEBUG
- fi
-
- config_read ${NETWORK_CONFIG_FILE} ${options}
-}
-
-function network_config_write() {
- config_write ${NETWORK_CONFIG_FILE} ${NETWORK_CONFIG_FILE_PARAMS}
-
- # Update DNS configuration.
- dns_generate_resolvconf
-}
-
-function network_config_print() {
- config_print ${NETWORK_CONFIG_FILE_PARAMS}
-}
-
-function firewall_config_read() {
- config_read "${FIREWALL_CONFIG_FILE}" "${FIREWALL_CONFIG_PARAMS}"
-}
-
-function firewall_config_write() {
- config_write "${FIREWALL_CONFIG_FILE}" "${FIREWALL_CONFIG_PARAMS}"
-}
-
-function firewall_config_print() {
- config_print "${FIREWALL_CONFIG_PARAMS}"
-}
NETWORK_HOOKS_DIR=/usr/lib/network/hooks
# Network file configuration.
-NETWORK_CONFIG_FILE=${NETWORK_CONFIG_DIR}/config
-NETWORK_CONFIG_FILE_PARAMS="DEBUG"
+NETWORK_SETTINGS_FILE=${NETWORK_CONFIG_DIR}/config
+NETWORK_SETTINGS_FILE_PARAMS="DEBUG"
CONFIG_HOSTNAME="/etc/hostname"
RED_DB_DIR=${RUN_DIR}/red
assert isset settings
dhcpd_global_settings_defaults ${proto}
- config_read ${file} ${settings}
+ settings_read ${file} ${settings}
}
function dhcpd_global_settings_write() {
local settings=$(dhcpd_settings ${proto})
assert isset settings
- config_write ${file} ${settings}
+ settings_write ${file} ${settings}
}
function dhcpd_global_options_read() {
local options_file=$(dhcpd_options_file ${proto})
local options_list=$(dhcpd_options_list ${proto})
- config_read_array ${options_file} options ${!options_list}
+ settings_read_array ${options_file} options ${!options_list}
# Check if domain-name is set.
if [ -z "${options["domain-name"]}" ]; then
# XXX Check for subnet collisions!
local file="$(dhcpd_subnet_path ${proto} ${id})/settings"
- config_write ${file} ${settings}
+ settings_write ${file} ${settings}
}
function dhcpd_subnet_remove() {
assert isset id
local file="$(dhcpd_subnet_path ${proto} ${id})/settings"
- config_read ${file}
+ settings_read ${file}
}
function dhcpd_subnet_range_path() {
local file=$(dhcpd_subnet_range_path ${proto} ${subnet_id} ${range_id})
assert isset file
- config_write ${file} ${settings}
+ settings_write ${file} ${settings}
}
function dhcpd_subnet_range_remove() {
assert isset range_id
local file=$(dhcpd_subnet_range_path ${proto} ${subnet_id} ${range_id})
- config_read ${file}
+ settings_read ${file}
}
function dhcpd_subnet_settings() {
local options_list=${2}
assert isset options_list
- config_read_array ${file} options ${!options_list}
+ setttings_read_array ${file} options ${!options_list}
}
function _dhcpd_write_subnet() {
# Set this to true if localhost should be added as the first DNS server.
DNS_USE_LOCAL_RESOLVER=true
-NETWORK_CONFIG_FILE_PARAMS="${NETWORK_CONFIG_FILE_PARAMS} DNS_USE_LOCAL_RESOLVER"
+NETWORK_SETTINGS_FILE_PARAMS="${NETWORK_SETTINGS_FILE_PARAMS} DNS_USE_LOCAL_RESOLVER"
# Set this option to true if the DNS servers should be queried in a random order.
# This is useful to load balance between multiple servers.
DNS_RANDOMIZE=false
-NETWORK_CONFIG_FILE_PARAMS="${NETWORK_CONFIG_FILE_PARAMS} DNS_RANDOMIZE"
+NETWORK_SETTINGS_FILE_PARAMS="${NETWORK_SETTINGS_FILE_PARAMS} DNS_RANDOMIZE"
DNS_SEARCH_DOMAINS=""
-NETWORK_CONFIG_FILE_PARAMS="${NETWORK_CONFIG_FILE_PARAMS} DNS_SEARCH_DOMAINS"
+NETWORK_SETTINGS_FILE_PARAMS="${NETWORK_SETTINGS_FILE_PARAMS} DNS_SEARCH_DOMAINS"
# Set this option to true if the DNS servers should be advertised by
# radvd.
local file=$(firewall_zone_config ${zone})
assert isset file
- config_read ${file} ${FIREWALL_ZONE_SETTINGS}
+ settings_read ${file} ${FIREWALL_ZONE_SETTINGS}
local arg default
for arg in ${FIREWALL_ZONE_SETTINGS}; do
local file=$(firewall_zone_config ${zone})
assert isset file
- config_write ${file} ${FIREWALL_ZONE_SETTINGS}
+ settings_write ${file} ${FIREWALL_ZONE_SETTINGS}
return ${EXIT_OK}
}
(
firewall_zone_read ${zone}
- config_print ${FIREWALL_ZONE_SETTINGS}
+ settings_print ${FIREWALL_ZONE_SETTINGS}
)
return ${EXIT_OK}
return ${EXIT_OK}
}
-function port_config_read() {
- local port=${1}
+function port_settings_read() {
+ local port="${1}"
assert isset port
+ shift
# Save the HOOK variable.
local hook="${HOOK}"
- config_read $(port_file ${port})
+ settings_read "$(port_file "${port}")" "$@"
# Restore hook.
HOOK="${hook}"
}
-function port_config_write() {
- local port=${1}
+function port_settings_write() {
+ local port="${1}"
assert isset port
+ shift
- config_write $(port_file ${port})
+ settings_write "$(port_file "${port}")" "$@"
}
function ports_get_all() {
}
function port_file() {
- local port=${1}
+ local port="${1}"
assert isset port
echo "$(port_dir)/${port}"
--- /dev/null
+#!/bin/bash
+###############################################################################
+# #
+# IPFire.org - A linux based firewall #
+# Copyright (C) 2014 IPFire Network Development Team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+function settings_read() {
+ local file=${1}
+ assert isset file
+ shift
+
+ local valid_keys=$@
+
+ # Exit if the file cannot be read.
+ [ -r "${file}" ] || return ${EXIT_ERROR}
+
+ local line key val
+ while read -r line; do
+ case "${line}" in
+ *=*)
+ key=$(cli_get_key ${line})
+
+ # If valid keys is set, key must be in the list.
+ if [ -n "${valid_keys}" ]; then
+ if ! listmatch ${key} ${valid_keys}; then
+ log DEBUG "Ignoring configuration setting: ${key}"
+ continue
+ fi
+ fi
+
+ val=$(cli_get_val ${line})
+ val=$(settings_strip ${val})
+
+ # Assign variable.
+ printf -v ${key} "%s" "${val}"
+ ;;
+ *)
+ log DEBUG "Invalid line in configuration file: ${line}"
+ ;;
+ esac
+ done < ${file}
+}
+
+function settings_read_array() {
+ local file=${1}
+ assert isset file
+ shift
+
+ local array=${1}
+ assert isset array
+ shift
+
+ local valid_keys=$@
+
+ # Exit if the file cannot be read.
+ [ -r "${file}" ] || return ${EXIT_ERROR}
+
+ local line key val
+ while read -r line; do
+ case "${line}" in
+ *=*)
+ key=$(cli_get_key ${line})
+
+ # If valid_keys is set, key must be in the list.
+ if [ -n "${valid_keys}" ]; then
+ if ! listmatch ${key} ${valid_keys}; then
+ log DEBUG "Ignoring configuration setting: ${key}"
+ continue
+ fi
+ fi
+
+ val=$(cli_get_val ${line})
+ val=$(settings_strip ${val})
+
+ # Assign variable.
+ printf -v "${array}["${key}"]" "%s" "${val}"
+ ;;
+ *)
+ log DEBUG "Invalid line in configuration file: ${line}"
+ ;;
+ esac
+ done < ${file}
+}
+
+# Strip leading and trailing "s.
+function settings_strip() {
+ local var="$@"
+
+ # Do nothing for strings that contain spaces.
+ if contains_spaces ${var}; then
+ print "${var}"
+ return ${EXIT_OK}
+ fi
+
+ unquote "${var}"
+}
+
+function settings_write() {
+ local settings_file=${1}
+ assert isset settings_file
+ shift
+
+ # Check if all values to be written are sane
+ if ! settings_check; then
+ log CRITICAL "Configuration check failed. No settings have been written."
+ return ${EXIT_ERROR}
+ fi
+
+ log DEBUG "Writing settings file ${settings_file}."
+
+ mkdir -p $(dirname ${settings_file}) 2>/dev/null
+ > ${settings_file}
+
+ local param
+ for param in $(listsort $@); do
+ echo "${param}=\"${!param}\"" >> ${settings_file}
+ done
+}
+
+function settings_remove() {
+ local settings_file="${1}"
+
+ local abspath="$(readlink -e "${settings_file}")"
+ if [ "${settings_file}" != "${abspath}" ]; then
+ log ERROR "Can only handle absolute paths"
+ return ${EXIT_ERROR}
+ fi
+
+ rm -f "${settings_file}"
+}
+
+function settings_print() {
+ local param
+
+ for param in $(listsort $@); do
+ printf "%-32s = %s\n" "${param}" "${!param}"
+ done
+}
+
+function settings_check() {
+ # If there is a function defined that is called __check
+ # we call that function
+ if [ -n "$(type -t _check)" ]; then
+ _check || return $?
+ fi
+
+ return ${EXIT_OK}
+}
+
+function settings_set() {
+ while [ $# -gt 0 ]; do
+ case "${1}" in
+ *=*)
+ local key=$(cli_get_key ${1})
+ local val=$(cli_get_val ${1})
+
+ log INFO "Setting configuration option '${key}=${val}'".
+
+ printf -v ${key} "%s" "${val}"
+ ;;
+ *)
+ warning "Invalid parameter given: ${1}"
+ ;;
+ esac
+ shift
+ done
+}
+
+function network_settings_read() {
+ local options="${NETWORK_SETTINGS_FILE_PARAMS}"
+
+ # If the DEBUG variable has already been set,
+ # don't overwrite it.
+ if [ -n "${DEBUG}" ]; then
+ list_remove options DEBUG
+ fi
+
+ settings_read "${NETWORK_SETTINGS_FILE}" ${options}
+}
+
+function network_settings_write() {
+ settings_write "${NETWORK_SETTINGS_FILE}" ${NETWORK_SETTINGS_FILE_PARAMS}
+
+ # Update DNS configuration.
+ dns_generate_resolvconf
+}
+
+function network_settings_print() {
+ settings_print ${NETWORK_SETTINGS_FILE_PARAMS}
+}
+
+function firewall_settings_read() {
+ settings_read "${FIREWALL_SETTINGS_FILE}" "${FIREWALL_SETTINGS_PARAMS}"
+}
+
+function firewall_settings_write() {
+ settings_write "${FIREWALL_SETTINGS_FILE}" "${FIREWALL_SETTINGS_PARAMS}"
+}
+
+function firewall_settings_print() {
+ settings_print "${FIREWALL_SETTINGS_PARAMS}"
+}
# Sets the global wireless country code. Default is 00 = world.
WIRELESS_REGULATORY_DOMAIN="00"
-NETWORK_CONFIG_FILE_PARAMS="${NETWORK_CONFIG_FILE_PARAMS} WIRELESS_REGULATORY_DOMAIN"
+NETWORK_SETTINGS_FILE_PARAMS="${NETWORK_SETTINGS_FILE_PARAMS} WIRELESS_REGULATORY_DOMAIN"
function wireless_create() {
local device=${1}
esac
}
-function zone_config_option() {
- local zone=${1}
- local option=${2}
- local default=${3}
- shift 2
-
- assert isset zone
- assert isset option
-
- (
- VALUE="${default}"
- zone_config_read ${zone}
-
- VALUE="${!option}"
- echo "${VALUE}"
- )
-}
-
function zone_config_create() {
- local zone=${1}
- shift
-
+ local zone="${1}"
assert isset zone
+ shift
- local hook=$(zone_get_hook ${zone})
-
+ local hook=$(zone_get_hook "${zone}")
assert isset hook
- hook_zone_exec ${hook} config_create ${zone} $@
+ hook_zone_exec "${hook}" "config_create" "${zone}" "$@"
}
function zone_show() {
echo "$(zone_dir ${zone})/settings"
}
-function zone_config_read() {
+function zone_settings_read() {
local zone=${1}
assert isset zone
# Save the HOOK variable.
local hook="${HOOK}"
- config_read $(zone_file ${zone})
+ settings_read $(zone_file ${zone})
# Restore hook.
HOOK="${hook}"
}
-function zone_config_write() {
+function zone_settings_write() {
local zone=${1}
assert isset zone
- config_write $(zone_file ${zone}) ${HOOK_SETTINGS}
+ settings_write $(zone_file ${zone}) ${HOOK_SETTINGS}
}
-function zone_config_set() {
+function zone_settings_set() {
local zone=${1}
shift
local args="$@"
assert isset zone
(
- zone_config_read ${zone}
+ zone_settings_read ${zone}
for arg in ${args}; do
eval "${arg}"
done
- zone_config_write ${zone}
+ zone_settings_write ${zone}
)
}
-function zone_config_get() {
+function zone_settings_get() {
local zone=${1}
local key=${2}
assert isset key
(
- zone_config_read ${zone}
+ zone_settings_read ${zone}
echo "${!key}"
)
}
+
+function zone_config_settings_read() {
+ assert [ $# -gt 2 ]
+
+ local zone="${1}"
+ local config="${2}"
+ shift 2
+
+ local path="$(zone_dir "${zone}")/configs/${config}"
+ settings_read "${path}" "$@"
+}
+
+function zone_config_settings_write() {
+ assert [ $# -gt 2 ]
+
+ local zone="${1}"
+ local config="${2}"
+ shift 2
+
+ local path="$(zone_dir "${zone}")/configs/${config}"
+ settings_write "${path}" "$@"
+}
+
+function zone_port_settings_read() {
+ assert [ $# -gt 2 ]
+
+ local zone="${1}"
+ local port="${2}"
+ shift 2
+
+ local path="$(zone_dir "${zone}")/ports/${port}"
+ settings_read "${path}" "$@"
+}
+
+function zone_port_settings_write() {
+ assert [ $# -gt 2 ]
+
+ local zone="${1}"
+ local port="${2}"
+ shift 2
+
+ local path="$(zone_dir "${zone}")/ports/${port}"
+ settings_write "${path}" "$@"
+}
+
+function zone_port_settings_remove() {
+ assert [ $# -eq 2 ]
+
+ local zone="${1}"
+ local port="${2}"
+
+ local path="$(zone_dir "${zone}")/ports/${port}"
+ settings_remove "${path}"
+}
assert isset port
shift
- config_read "$(port_file ${port})"
+ settings_read "$(port_file ${port})"
local key val
for key in PORT_PARENTS PORT_CHILDREN; do
assert isset zone
shift
- config_read $(zone_dir ${zone})/settings
+ settings_read $(zone_dir ${zone})/settings
hook_parse_cmdline $@
- config_write $(zone_dir ${zone})/settings ${HOOK_SETTINGS}
+ settings_write $(zone_dir ${zone})/settings ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
action="${1}"
assert isset action
case "${action}" in
create)
# Create the configuration file for this zone.
- zone_config_read ${zone}
+ zone_settings_read "${zone}"
config_dir="$(dirname ${config_file})"
mkdir -p ${config_dir}
. /usr/lib/network/functions
-# Read network configuration.
-network_config_read
+# Read network settings
+network_settings_read
zone=${1}
assert isset zone
exit ${EXIT_KERNEL_STP}
fi
-# Read zone configuration.
-zone_config_read ${zone}
+# Read zone settings
+zone_settings_read ${zone}
# Make sure STP is enabled for this zone.
assert enabled STP
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
action=${1}
assert isset action
. /usr/lib/network/functions
-# Read firewall configuration.
-firewall_config_read
+# Read firewall settings
+firewall_setttings_read
# Initialize kernel parameters for the firewall.
firewall_kernel_init
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
action="${1}"
assert isset action
case "${action}" in
create)
# Create the configuration file for this port.
- port_config_read ${port} || exit $?
+ port_settings_read ${port} || exit $?
hostapd_config_write ${port} ${config_file} \
--broadcast-ssid="${BROADCAST_SSID}" \
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
action="${1}"
assert isset action
case "${action}" in
create)
# Create the configuration file for this zone.
- zone_config_read ${zone}
+ zone_settings_read ${zone}
teredo_write_config ${zone} ${config_file} \
--server="${SERVER}"
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
action="${STATE}"
assert isset action
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
function main() {
local zone="${1}"
assert isset zone
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
zone="${1}"
assert isset zone
assert zone_exists ${zone}
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
action="${1}"
assert isset action
case "${action}" in
create)
# Create the configuration file for this zone.
- zone_config_read ${zone} || exit $?
+ zone_settings_read ${zone} || exit $?
wpa_supplicant_config_write ${zone} ${config_file} \
--mode="${ENCRYPTION}" \
shift
done
- config_write $(zone_dir ${zone})/configs/${HOOK} ${HOOK_SETTINGS}
+ zone_config_settings_write "${zone}" "${HOOK}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
error "Zone '${zone}' doesn't exist."
exit ${EXIT_ERROR}
fi
-
- config_read $(zone_dir ${zone})/configs/${config}
+
+ zone_config_settings_read "${zone}" "${config}" ${HOOK_SETTINGS}
local status
if dhclient_status ${zone} ipv4; then
fi
# XXX maybe we can add some hashing to identify a configuration again
- config_write $(zone_dir ${zone})/configs/${HOOK}.$(uuid) ${HOOK_SETTINGS}
+ zone_config_settings_write "${zone}" "${HOOK}.$(uuid)" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
exit ${EXIT_ERROR}
fi
- config_read $(zone_dir ${zone})/configs/${config}
+ zone_config_settings_read "${zone}" "${config}" ${HOOK_SETTINGS}
ip_address_add ${zone} ${ADDRESS}/${PREFIX}
exit ${EXIT_ERROR}
fi
- config_read $(zone_dir ${zone})/configs/${config}
+ zone_config_settings_read "${zone}" "${config}" ${HOOK_SETTINGS}
ip_address_del ${zone} ${ADDRESS}/${PREFIX}
error "Zone '${zone}' doesn't exist."
exit ${EXIT_ERROR}
fi
-
- config_read $(zone_dir ${zone})/configs/${config}
+
+ zone_config_settings_read "${zone}" "${config}" ${HOOK_SETTINGS}
local status
if zone_has_ip ${zone} ${ADDRESS}/${PREFIX}; then
GATEWAY=$(ipv6_implode ${GATEWAY})
fi
- config_write $(zone_dir ${zone})/configs/${HOOK}.$(ipv6_hash ${ADDRESS}).${PREFIX} ${HOOK_SETTINGS}
+ zone_config_settings_write "${zone}" "${HOOK}.$(ipv6_hash ${ADDRESS}).${PREFIX}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
exit ${EXIT_ERROR}
fi
- config_read $(zone_dir ${zone})/configs/${config}
+ zone_config_settings_read "${zone}" "${config}" ${HOOK_SETTINGS}
ip_address_add ${zone} ${ADDRESS}/${PREFIX}
# Remove routing information from database.
routing_db_remove ${zone} ipv6
- config_read $(zone_dir ${zone})/configs/${config}
+ zone_config_settings_read "${zone}" "${config}" ${HOOK_SETTINGS}
ip_address_del ${zone} ${ADDRESS}/${PREFIX}
exit ${EXIT_ERROR}
fi
- config_read $(zone_dir ${zone})/configs/${config}
+ zone_config_settings_read "${zone}" "${config}" ${HOOK_SETTINGS}
# Make sure ADDRESS is as short as possible.
ADDRESS=$(ipv6_implode ${ADDRESS})
shift
done
- config_write $(zone_dir ${zone})/configs/${HOOK} ${HOOK_SETTINGS}
+ zone_config_settings_write "${zone}" "${HOOK}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
error "Zone '${zone}' doesn't exist."
exit ${EXIT_ERROR}
fi
-
- config_read $(zone_dir ${zone})/configs/${config}
+
+ zone_config_settings_read "${zone}" "${config}" ${HOOK_SETTINGS}
local status
if pppoe_server_status ${zone}; then
local port=$(port_find_free ${PORT_PATTERN_BATMAN_ADV})
assert isset port
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
assert isset port
shift
- config_read $(port_file ${port})
+ port_settings_read "${port}"
while [ $# -gt 0 ]; do
case "${1}" in
shift
done
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
local port=${1}
assert isset port
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# This cannot be started manually, but is created automatically
# when a slave device is brought up and set up by _hotplug.
local port=${1}
assert isset port
- config_read $(port_file ${port})
+ port_settings_read "${port}"
local slave
for slave in ${SLAVES}; do
local port=$(port_find_free ${PORT_PATTERN_BATMAN_ADV_PORT})
assert isset port
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
assert isset port
shift
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
while [ $# -gt 0 ]; do
case "${1}" in
shift
done
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
local port=${1}
assert isset port
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# Check if the PHY is present.
local phy=$(phy_get ${PHY})
assert port_exists ${port}
# Read configuration of port.
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# Get the address of the phy.
local phy_address=$(phy_get_address ${phy})
# Remove any whitespace
SLAVES=$(echo ${SLAVES})
- port_config_write ${port} ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
local device=${1}
assert isset device
- port_config_read ${device}
+ port_settings_read "${device}" ${HOOK_SETTINGS}
if device_exists ${device}; then
log DEBUG "Bonding device '${device}' does already exist."
local port=$(port_find_free ${DUMMY_PORT_PATTERN})
assert isset port
- if config_write $(port_file ${port}) ${HOOK_SETTINGS}; then
+ if port_settings_write "${port}" ${HOOK_SETTINGS}; then
log INFO "New dummy port '${port}' has been created"
fi
assert isset port
shift
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
while [ $# -gt 0 ]; do
case "${1}" in
shift
done
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
local port=${1}
assert isset port
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# Create device if not already exists.
if ! device_exists ${port}; then
local device=${2}
assert isset device
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
if [ "${ADDRESS}" = "$(device_get_address ${device})" ]; then
log DEBUG "Device '${device}' equals port '${port}'."
ADDRESS=""
DEVICE=$(device_get_address ${port})
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
assert isset port
# Read in the confguration file.
- port_config_read ${port}
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# Check if the MAC address is the right one.
if isset ADDRESS; then
assert isset device
# Read in the conifguration file.
- port_config_read ${port}
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# Get the current MAC address of the device.
local address=$(device_get_address ${device})
local port=$(port_find_free "${PARENT}${MACVLAN_PORT_INTERFIX}N")
assert isset port
- if config_write $(port_file ${port}) ${HOOK_SETTINGS}; then
+ if port_settings_write "${port}" ${HOOK_SETTINGS}; then
log INFO "New macvlan port '${port}' has been created."
fi
assert isset port
shift
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
while [ $# -gt 0 ]; do
case "${1}" in
shift
done
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
local port=${1}
assert isset port
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# Create device if not already exists.
if ! device_exists ${port}; then
assert isset port
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
if ! device_exists ${port}; then
exit ${EXIT_OK}
local port="${PARENT_DEVICE}${VLAN_PORT_INTERFIX}${TAG}"
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
assert isset port
shift
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
while [ $# -gt 0 ]; do
case "${1}" in
shift
done
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
if ! device_exists ${port}; then
# Read configuration file.
- config_read $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_read "${port}" ${HOOK_SETTINGS}
vlan_create ${port} ${PARENT_DEVICE} ${TAG} ${ADDRESS}
fi
local port=$(port_find_free ${PORT_PATTERN_ACCESSPOINT})
assert isset port
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
assert isset port
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
while [ $# -gt 0 ]; do
case "${1}" in
shift
done
- config_write $(port_file ${port}) ${HOOK_SETTINGS}
+ port_settings_write "${port}" ${HOOK_SETTINGS}
exit ${EXIT_OK}
}
local port=${1}
assert isset port
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# Check if the PHY is present.
local phy=$(phy_get ${PHY})
assert port_exists ${port}
# Read configuration of port.
- config_read $(port_file ${port})
+ port_settings_read "${port}" ${HOOK_SETTINGS}
# Get the address of the phy.
local phy_address=$(phy_get_address ${phy})
LOCAL_ADDRESS="${PUBLIC_ADDRESS}"
fi
- assert isset LOCAL_ADDRESS
+ assert isset LOCAL_ADDRESS
# Check input.
if ! ipv6_is_valid "${SIX_RD_PREFIX}"; then
assert isset zone
# Read configuration options.
- zone_config_read "${zone}"
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# Configure the tunnel.
if ! device_exists "${zone}"; then
cli_device_headline ${zone}
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
local server_line="${SERVER_ADDRESS}"
local server_hostname=$(dns_get_hostname ${SERVER_ADDRESS})
assert isset zone
# Read configuration options.
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
if enabled AUTO_UPDATE_ENDPOINT; then
log DEBUG "Updating tunnel endpoint"
cli_device_headline ${zone}
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
local server_line="${SERVER_ADDRESS}"
local server_hostname=$(dns_get_hostname ${SERVER_ADDRESS})
cli_device_headline ${zone}
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
cli_headline 2 "Configuration"
cli_print_fmt1 2 "User" "${USERNAME}"
local zone=${1}
assert isset zone
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# Create the bridge if it does not already exist.
if ! device_exists ${zone}; then
__parse_cmdline_args "$@"
[ $? -eq ${EXIT_OK} ] || return ${EXIT_ERROR}
- config_write "$(zone_dir "${zone}")/ports/${port}" ${HOOK_PORT_SETTINGS}
+ zone_port_settings_write "${zone}" "${port}" ${HOOK_PORT_SETTINGS}
log INFO "Port '${port}' has been added to zone '${zone}'"
local port="${2}"
shift 2
- config_read "$(zone_dir "${zone}")/ports/${port}" ${HOOK_PORT_SETTINGS}
+ zone_port_settings_read "${zone}" "${port}" ${HOOK_PORT_SETTINGS}
__parse_cmdline_args "$@"
[ $? -eq ${EXIT_OK} ] || return ${EXIT_ERROR}
- config_write "$(zone_dir "${zone}")/ports/${port}" ${HOOK_PORT_SETTINGS}
+ zone_port_settings_write "${zone}" "${port}" ${HOOK_PORT_SETTINGS}
log INFO "Port '${port}' (member of zone '${zone}') has been edited"
port_down "${port}"
log INFO "Port '${port}' has been removed from zone '${zone}'"
- config_remove "$(zone_dir "${zone}")/ports/${port}"
+ zone_port_settings_remove "${zone}" "${port}"
exit ${EXIT_OK}
}
local zone="${1}"
local port="${2}"
- config_read "$(zone_dir "${zone}")/ports/${port}" ${HOOK_PORT_SETTINGS}
+ zone_port_settings_read "${zone}" "${port}" ${HOOK_PORT_SETTINGS}
port_up "${port}"
assert isset zone
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
assert [ -e "/dev/${DEVICE}" ]
cli_device_headline ${zone}
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
cli_headline 2 "Configuration:"
cli_print_fmt1 2 "User" "${USER}"
assert isset zone
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
assert [ -e "/dev/${DEVICE}" ]
cli_device_headline ${zone}
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
cli_headline " Configuration:"
printf "${DEVICE_PRINT_LINE1}" "User:" "${USER}"
assert isset zone
# Load configuration file.
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# If we have got a PIN, we try to unlock the device first.
if isset PIN; then
if ! modem_sim_auto_unlock "${DEVICE}" "${PIN}"; then
# Reset the PIN setting.
PIN=""
- config_write $(zone_dir ${zone})/settings ${HOOK_SETTINGS}
+ zone_settings_write "${zone}" ${HOOK_SETTINGS}
error "Could not unlock the SIM card. Removing PIN from settings."
fi
cli_device_headline ${zone}
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
cli_headline 2 "Configuration"
cli_print_fmt1 2 "Username" "${USERNAME}"
assert isset file
# Read in the configuration files.
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
pppd_write_config ${file} \
--interface="${zone}" \
local zone=${1}
assert isset zone
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# Bring up the port.
local port=$(__hook_get_port "${zone}")
local zone=${1}
assert isset zone
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# Stop the ppp daemon.
pppd_stop ${zone}
cli_device_headline ${zone}
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
cli_headline 2 "Configuration"
cli_print_fmt1 2 "Username" "${USERNAME}"
assert isset file
# Read in the configuration files.
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# A port has to be assigned for this action
local port=$(__hook_get_port "${zone}")
return ${EXIT_ERROR}
fi
- config_write "$(zone_dir "${zone}")/ports/${port}"
+ zone_port_settings_write "${zone}" "${port}"
log INFO "Port '${port}' has been added to zone '${zone}'"
exit ${EXIT_OK}
port_down "${port}"
log INFO "Port '${port}' has been removed from zone '${zone}'"
- config_remove "$(zone_dir "${zone}")/ports/${port}"
+ zone_port_settings_remove "${zone}" "${port}"
exit ${EXIT_OK}
}
error "PREFIX is greater than 30."
exit ${EXIT_ERROR}
fi
- fi
+ fi
# Check if the peer-address is valid.
if ! ipv4_is_valid "${PEER_ADDRESS}"; then
local zone="${1}"
assert isset zone
-
- zone_config_read "${zone}"
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# Check if a port will be used.
if isset PORT; then
-
# Bring up the port.
log DEBUG "Bringing up port '${PORT}'."
port_up "${PORT}"
local zone="${1}"
assert isset zone
- zone_config_read "${zone}"
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# Stop the ppp daemon.
pppd_stop "${zone}"
-
# Check if a port has been used.
if isset PORT; then
-
# Stop DHCP-Client or remove static IP address.
if enabled USE_DHCP; then
# Stop dhclient for IPv4 on this zone.
cli_device_headline "${zone}"
- zone_config_read "${zone}"
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# Display port configuration if a port is used.
if isset PORT; then
assert isset file
# Read in the configuration files.
- zone_config_read "${zone}"
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
# Prepare the command line options for the pptp plugin.
local pptp_commandline="pptp ${PEER_ADDRESS} --nolaunchpppd"
# Print a nice header.
cli_device_headline ${zone}
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
cli_headline 2 "Configuration"
cli_print_fmt1 2 "Server" "${SERVER}"
assert isset zone
# Read zone configuration.
- zone_config_read ${zone}
+ zone_settings_read "${zone}" ${HOOK_SETTINGS}
if ! device_exists ${zone}; then
# Create the wireless interface.
. /usr/lib/network/functions
-# Read network configuration.
-network_config_read
+# Read network settings
+network_settings_read
-function cli_config() {
+function cli_settings() {
if cli_help_requested $@; then
- cli_show_man network-config
+ cli_show_man network-settings
exit ${EXIT_OK}
fi
if [ -n "${1}" ]; then
- config_set $@
- network_config_write
+ settings_set $@
+ network_settings_write
else
- network_config_print
+ network_settings_print
fi
}
init_run
;;
- config|hostname|port|device|zone|start|stop|restart|status|reset|route)
+ settings|hostname|port|device|zone|start|stop|restart|status|reset|route)
cli_${action} $@
;;
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
log DEBUG "dialer called with arguments: $@"
# The zone is an optional argument.
# If we have the zone information, we will
# load the zone configuration.
if zone_exists ${ZONE}; then
- zone_config_read ${ZONE}
+ zone_settings_read "${ZONE}"
fi
# The default speaker settings is on.
LOG_FACILITY="pppoe-server"
. /usr/lib/network/functions
+# Read network settings
+network_settings_read
+
zone=${1}
assert zone_exists ${zone}
action=${2}
# Read the configuration file of this hook.
-config_read $(zone_dir ${zone})/configs/pppoe-server
+zone_config_settings_read "${zone}" "pppoe-server"
assert isset SUBNET
pppd_options="${RUN_DIR}/${zone}/pppoe-server-options"
. /usr/lib/network/functions
-# Read network configuration.
-network_config_read
+# Read network settings
+network_settings_read
# Setup logging.
LOG_FACILITY="network-hotplug"
. /usr/lib/network/functions
-# Read network configuration.
-network_config_read
+# Read network settings
+network_settings_read
# Setup the locking.
LOCKFILE="${RUN_DIR}/.rename_lock"
# Associated hooks.
ASSOCIATED_HOOKS="modem"
-# Read network configuration.
-network_config_read
+# Read network settings
+network_settings_read
log DEBUG "Called with ACTION='${ACTION}', DEVNAME='${DEVNAME}'."
list_match "${hook}" ${ASSOCIATED_HOOKS} || continue
# Read IMSI from zone configuration.
- zone_imsi="$(zone_config_option "${zone}" IMSI)"
+ zone_imsi="$(zone_settings_get "${zone}" IMSI)"
# If IMSIs match, we start that zone.
if [ "${zone_imsi}" = "${sim_imsi}" ]; then