From e9df08ad7a55a403ebd4f36b7d249b9bf27b276c Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 4 Sep 2014 20:13:15 +0200 Subject: [PATCH] Rename all "config" to "settings" --- Makefile.am | 1 + src/firewall-config | 6 +- src/firewall4 | 4 +- src/firewall6 | 4 +- src/functions/functions.cli.firewall | 10 +- src/functions/functions.config | 197 -------------------- src/functions/functions.constants | 4 +- src/functions/functions.dhcpd | 16 +- src/functions/functions.dns | 6 +- src/functions/functions.firewall-zones | 6 +- src/functions/functions.ports | 16 +- src/functions/functions.settings | 217 +++++++++++++++++++++++ src/functions/functions.wireless | 2 +- src/functions/functions.zone | 100 +++++++---- src/header-port | 2 +- src/header-zone | 4 +- src/helpers/aiccu-config-helper | 5 +- src/helpers/bridge-stp | 8 +- src/helpers/dhcpd-config-helper | 3 + src/helpers/firewall-kernel-init | 4 +- src/helpers/hostapd-config-helper | 5 +- src/helpers/miredo-config-helper | 5 +- src/helpers/miredo-helper | 3 + src/helpers/pppd-angel | 3 + src/helpers/wpa_supplicant | 3 + src/helpers/wpa_supplicant-config-helper | 5 +- src/hooks/configs/ipv4-dhcp | 6 +- src/hooks/configs/ipv4-static | 10 +- src/hooks/configs/ipv6-static | 8 +- src/hooks/configs/pppoe-server | 6 +- src/hooks/ports/batman-adv | 10 +- src/hooks/ports/batman-adv-port | 10 +- src/hooks/ports/bonding | 4 +- src/hooks/ports/dummy | 10 +- src/hooks/ports/ethernet | 6 +- src/hooks/ports/macvlan | 10 +- src/hooks/ports/vlan | 8 +- src/hooks/ports/wireless-ap | 10 +- src/hooks/zones/6rd | 6 +- src/hooks/zones/6to4-tunnel | 4 +- src/hooks/zones/aiccu | 2 +- src/hooks/zones/bridge | 12 +- src/hooks/zones/isdn | 4 +- src/hooks/zones/isdn-server | 4 +- src/hooks/zones/modem | 8 +- src/hooks/zones/pppoe | 12 +- src/hooks/zones/pptp | 14 +- src/hooks/zones/teredo | 2 +- src/hooks/zones/wireless | 2 +- src/network | 16 +- src/ppp/dialer | 5 +- src/ppp/pppoe-server | 5 +- src/udev/network-hotplug | 4 +- src/udev/network-hotplug-rename | 4 +- src/udev/network-hotplug-serial | 6 +- 55 files changed, 465 insertions(+), 382 deletions(-) create mode 100644 src/functions/functions.settings diff --git a/Makefile.am b/Makefile.am index d49d37ba..bd39d6d5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -142,6 +142,7 @@ dist_network_SCRIPTS = \ 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 \ diff --git a/src/firewall-config b/src/firewall-config index d8d8d4f2..53ec1754 100644 --- a/src/firewall-config +++ b/src/firewall-config @@ -21,9 +21,9 @@ . /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} diff --git a/src/firewall4 b/src/firewall4 index 5de6bfa9..55eed2c3 100644 --- a/src/firewall4 +++ b/src/firewall4 @@ -21,8 +21,8 @@ . /usr/lib/network/functions -# Read firewall configuration. -firewall_config_read +# Read firewall settings +firewall_settings_read firewall_cli "ipv4" "$@" diff --git a/src/firewall6 b/src/firewall6 index 70ae2ffe..db7284cd 100644 --- a/src/firewall6 +++ b/src/firewall6 @@ -21,8 +21,8 @@ . /usr/lib/network/functions -# Read firewall configuration. -firewall_config_read +# Read firewall settings +firewall_settings_read firewall_cli "ipv6" "$@" diff --git a/src/functions/functions.cli.firewall b/src/functions/functions.cli.firewall index 7d3557d2..9e99f31a 100644 --- a/src/functions/functions.cli.firewall +++ b/src/functions/functions.cli.firewall @@ -103,17 +103,17 @@ function firewall_cli_panic() { 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 } diff --git a/src/functions/functions.config b/src/functions/functions.config index a625c0fd..ab1dadc4 100644 --- a/src/functions/functions.config +++ b/src/functions/functions.config @@ -19,149 +19,6 @@ # # ############################################################################### -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 @@ -194,57 +51,3 @@ function config_domainname() { # 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}" -} diff --git a/src/functions/functions.constants b/src/functions/functions.constants index 3f570ea5..c9ad263a 100644 --- a/src/functions/functions.constants +++ b/src/functions/functions.constants @@ -34,8 +34,8 @@ NETWORK_ZONE_DIR="${NETWORK_CONFIG_DIR}" 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 diff --git a/src/functions/functions.dhcpd b/src/functions/functions.dhcpd index 75153eaf..51272e90 100644 --- a/src/functions/functions.dhcpd +++ b/src/functions/functions.dhcpd @@ -359,7 +359,7 @@ function dhcpd_global_settings_read() { assert isset settings dhcpd_global_settings_defaults ${proto} - config_read ${file} ${settings} + settings_read ${file} ${settings} } function dhcpd_global_settings_write() { @@ -372,7 +372,7 @@ 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() { @@ -382,7 +382,7 @@ 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 @@ -566,7 +566,7 @@ function dhcpd_subnet_edit() { # 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() { @@ -610,7 +610,7 @@ function dhcpd_subnet_read() { assert isset id local file="$(dhcpd_subnet_path ${proto} ${id})/settings" - config_read ${file} + settings_read ${file} } function dhcpd_subnet_range_path() { @@ -773,7 +773,7 @@ function dhcpd_subnet_range_edit() { 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() { @@ -815,7 +815,7 @@ function dhcpd_subnet_range_read() { 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() { @@ -931,7 +931,7 @@ function _dhcpd_read_options() { 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() { diff --git a/src/functions/functions.dns b/src/functions/functions.dns index 2563f9ca..5f2e370f 100644 --- a/src/functions/functions.dns +++ b/src/functions/functions.dns @@ -21,15 +21,15 @@ # 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. diff --git a/src/functions/functions.firewall-zones b/src/functions/functions.firewall-zones index 69129e38..397b2bd0 100644 --- a/src/functions/functions.firewall-zones +++ b/src/functions/functions.firewall-zones @@ -56,7 +56,7 @@ function firewall_zone_read() { 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 @@ -76,7 +76,7 @@ function firewall_zone_write() { local file=$(firewall_zone_config ${zone}) assert isset file - config_write ${file} ${FIREWALL_ZONE_SETTINGS} + settings_write ${file} ${FIREWALL_ZONE_SETTINGS} return ${EXIT_OK} } @@ -86,7 +86,7 @@ function firewall_zone_print() { ( firewall_zone_read ${zone} - config_print ${FIREWALL_ZONE_SETTINGS} + settings_print ${FIREWALL_ZONE_SETTINGS} ) return ${EXIT_OK} diff --git a/src/functions/functions.ports b/src/functions/functions.ports index 198a08ba..836a3779 100644 --- a/src/functions/functions.ports +++ b/src/functions/functions.ports @@ -37,24 +37,26 @@ function port_config_dir() { 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() { @@ -68,7 +70,7 @@ function ports_get_all() { } function port_file() { - local port=${1} + local port="${1}" assert isset port echo "$(port_dir)/${port}" diff --git a/src/functions/functions.settings b/src/functions/functions.settings new file mode 100644 index 00000000..52e519b9 --- /dev/null +++ b/src/functions/functions.settings @@ -0,0 +1,217 @@ +#!/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 . # +# # +############################################################################### + +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}" +} diff --git a/src/functions/functions.wireless b/src/functions/functions.wireless index 9090056d..50358816 100644 --- a/src/functions/functions.wireless +++ b/src/functions/functions.wireless @@ -21,7 +21,7 @@ # 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} diff --git a/src/functions/functions.zone b/src/functions/functions.zone index 51351172..55ca681d 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -543,35 +543,15 @@ function zone_config() { 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() { @@ -792,7 +772,7 @@ function zone_file() { echo "$(zone_dir ${zone})/settings" } -function zone_config_read() { +function zone_settings_read() { local zone=${1} assert isset zone @@ -800,21 +780,21 @@ function zone_config_read() { # 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="$@" @@ -822,17 +802,17 @@ function zone_config_set() { 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} @@ -840,8 +820,62 @@ function zone_config_get() { 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}" +} diff --git a/src/header-port b/src/header-port index 2e166a11..cf4ef0de 100644 --- a/src/header-port +++ b/src/header-port @@ -47,7 +47,7 @@ function hook_info() { 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 diff --git a/src/header-zone b/src/header-zone index eaebd1b6..b5ab3704 100644 --- a/src/header-zone +++ b/src/header-zone @@ -28,11 +28,11 @@ function hook_create() { 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} } diff --git a/src/helpers/aiccu-config-helper b/src/helpers/aiccu-config-helper index a01e7cd3..bd6d9746 100644 --- a/src/helpers/aiccu-config-helper +++ b/src/helpers/aiccu-config-helper @@ -21,6 +21,9 @@ . /usr/lib/network/functions +# Read network settings +network_settings_read + action="${1}" assert isset action @@ -33,7 +36,7 @@ config_file="${RUN_DIR}/${zone}/aiccu.conf" 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} diff --git a/src/helpers/bridge-stp b/src/helpers/bridge-stp index c98d6a1b..720324ca 100644 --- a/src/helpers/bridge-stp +++ b/src/helpers/bridge-stp @@ -27,8 +27,8 @@ LOG_FACILITY=$(basename ${0}) . /usr/lib/network/functions -# Read network configuration. -network_config_read +# Read network settings +network_settings_read zone=${1} assert isset zone @@ -42,8 +42,8 @@ if ! zone_exists ${zone}; then 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 diff --git a/src/helpers/dhcpd-config-helper b/src/helpers/dhcpd-config-helper index 80692b03..d02e1481 100644 --- a/src/helpers/dhcpd-config-helper +++ b/src/helpers/dhcpd-config-helper @@ -21,6 +21,9 @@ . /usr/lib/network/functions +# Read network settings +network_settings_read + action=${1} assert isset action diff --git a/src/helpers/firewall-kernel-init b/src/helpers/firewall-kernel-init index dba615d3..aea82c41 100644 --- a/src/helpers/firewall-kernel-init +++ b/src/helpers/firewall-kernel-init @@ -21,8 +21,8 @@ . /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 diff --git a/src/helpers/hostapd-config-helper b/src/helpers/hostapd-config-helper index 5ad2d761..cb12af0a 100644 --- a/src/helpers/hostapd-config-helper +++ b/src/helpers/hostapd-config-helper @@ -21,6 +21,9 @@ . /usr/lib/network/functions +# Read network settings +network_settings_read + action="${1}" assert isset action @@ -32,7 +35,7 @@ config_file="$(port_config_dir ${port})/hostapd.conf" 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}" \ diff --git a/src/helpers/miredo-config-helper b/src/helpers/miredo-config-helper index 6f522ca8..9fb17258 100644 --- a/src/helpers/miredo-config-helper +++ b/src/helpers/miredo-config-helper @@ -21,6 +21,9 @@ . /usr/lib/network/functions +# Read network settings +network_settings_read + action="${1}" assert isset action @@ -33,7 +36,7 @@ config_file="${RUN_DIR}/miredo/${zone}/client.conf" 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}" diff --git a/src/helpers/miredo-helper b/src/helpers/miredo-helper index 456fa66d..c8b42b53 100644 --- a/src/helpers/miredo-helper +++ b/src/helpers/miredo-helper @@ -23,6 +23,9 @@ LOG_FACILITY="miredo-helper" . /usr/lib/network/functions +# Read network settings +network_settings_read + action="${STATE}" assert isset action diff --git a/src/helpers/pppd-angel b/src/helpers/pppd-angel index b2489d1b..678bf919 100644 --- a/src/helpers/pppd-angel +++ b/src/helpers/pppd-angel @@ -21,6 +21,9 @@ . /usr/lib/network/functions +# Read network settings +network_settings_read + function main() { local zone="${1}" assert isset zone diff --git a/src/helpers/wpa_supplicant b/src/helpers/wpa_supplicant index 3d1aa947..e0465d0f 100644 --- a/src/helpers/wpa_supplicant +++ b/src/helpers/wpa_supplicant @@ -21,6 +21,9 @@ . /usr/lib/network/functions +# Read network settings +network_settings_read + zone="${1}" assert isset zone assert zone_exists ${zone} diff --git a/src/helpers/wpa_supplicant-config-helper b/src/helpers/wpa_supplicant-config-helper index 26805a97..97f15aa7 100644 --- a/src/helpers/wpa_supplicant-config-helper +++ b/src/helpers/wpa_supplicant-config-helper @@ -21,6 +21,9 @@ . /usr/lib/network/functions +# Read network settings +network_settings_read + action="${1}" assert isset action @@ -33,7 +36,7 @@ config_file="$(wpa_supplicant_config_dir ${zone})/wpa_supplicant.conf" 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}" \ diff --git a/src/hooks/configs/ipv4-dhcp b/src/hooks/configs/ipv4-dhcp index 783c1226..b24cb11c 100644 --- a/src/hooks/configs/ipv4-dhcp +++ b/src/hooks/configs/ipv4-dhcp @@ -44,7 +44,7 @@ function hook_create() { shift done - config_write $(zone_dir ${zone})/configs/${HOOK} ${HOOK_SETTINGS} + zone_config_settings_write "${zone}" "${HOOK}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -90,8 +90,8 @@ function hook_status() { 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 diff --git a/src/hooks/configs/ipv4-static b/src/hooks/configs/ipv4-static index f56a5551..9f9b3de3 100644 --- a/src/hooks/configs/ipv4-static +++ b/src/hooks/configs/ipv4-static @@ -60,7 +60,7 @@ function hook_create() { 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} } @@ -75,7 +75,7 @@ function hook_up() { 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} @@ -101,7 +101,7 @@ function hook_down() { 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} @@ -120,8 +120,8 @@ function hook_status() { 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 diff --git a/src/hooks/configs/ipv6-static b/src/hooks/configs/ipv6-static index fb5513e0..c64ec8b0 100644 --- a/src/hooks/configs/ipv6-static +++ b/src/hooks/configs/ipv6-static @@ -59,7 +59,7 @@ function hook_create() { 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} } @@ -74,7 +74,7 @@ function hook_up() { 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} @@ -99,7 +99,7 @@ function hook_down() { # 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} @@ -119,7 +119,7 @@ function hook_status() { 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}) diff --git a/src/hooks/configs/pppoe-server b/src/hooks/configs/pppoe-server index 9bf279a9..f50ffbeb 100644 --- a/src/hooks/configs/pppoe-server +++ b/src/hooks/configs/pppoe-server @@ -65,7 +65,7 @@ function hook_create() { shift done - config_write $(zone_dir ${zone})/configs/${HOOK} ${HOOK_SETTINGS} + zone_config_settings_write "${zone}" "${HOOK}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -106,8 +106,8 @@ function hook_status() { 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 diff --git a/src/hooks/ports/batman-adv b/src/hooks/ports/batman-adv index 76e9250e..27cfd9f3 100644 --- a/src/hooks/ports/batman-adv +++ b/src/hooks/ports/batman-adv @@ -52,7 +52,7 @@ function hook_create() { 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} } @@ -62,7 +62,7 @@ function hook_edit() { assert isset port shift - config_read $(port_file ${port}) + port_settings_read "${port}" while [ $# -gt 0 ]; do case "${1}" in @@ -89,7 +89,7 @@ function hook_edit() { shift done - config_write $(port_file ${port}) ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -98,7 +98,7 @@ function hook_up() { 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. @@ -124,7 +124,7 @@ function hook_down() { local port=${1} assert isset port - config_read $(port_file ${port}) + port_settings_read "${port}" local slave for slave in ${SLAVES}; do diff --git a/src/hooks/ports/batman-adv-port b/src/hooks/ports/batman-adv-port index b14351e0..129acb72 100644 --- a/src/hooks/ports/batman-adv-port +++ b/src/hooks/ports/batman-adv-port @@ -75,7 +75,7 @@ function hook_create() { 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} } @@ -85,7 +85,7 @@ function hook_edit() { assert isset port shift - config_read $(port_file ${port}) + port_settings_read "${port}" ${HOOK_SETTINGS} while [ $# -gt 0 ]; do case "${1}" in @@ -105,7 +105,7 @@ function hook_edit() { shift done - config_write $(port_file ${port}) ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -114,7 +114,7 @@ function hook_up() { 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}) @@ -175,7 +175,7 @@ function hook_hotplug() { 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}) diff --git a/src/hooks/ports/bonding b/src/hooks/ports/bonding index 355eece1..f21cebf9 100644 --- a/src/hooks/ports/bonding +++ b/src/hooks/ports/bonding @@ -90,7 +90,7 @@ function hook_edit() { # Remove any whitespace SLAVES=$(echo ${SLAVES}) - port_config_write ${port} ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -99,7 +99,7 @@ function hook_up() { 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." diff --git a/src/hooks/ports/dummy b/src/hooks/ports/dummy index 3af50cd0..41b830b5 100644 --- a/src/hooks/ports/dummy +++ b/src/hooks/ports/dummy @@ -48,7 +48,7 @@ function hook_create() { 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 @@ -60,7 +60,7 @@ function hook_edit() { assert isset port shift - config_read $(port_file ${port}) + port_settings_read "${port}" ${HOOK_SETTINGS} while [ $# -gt 0 ]; do case "${1}" in @@ -74,7 +74,7 @@ function hook_edit() { shift done - config_write $(port_file ${port}) ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -83,7 +83,7 @@ function hook_up() { 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 @@ -120,7 +120,7 @@ function hook_hotplug_rename() { 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}'." diff --git a/src/hooks/ports/ethernet b/src/hooks/ports/ethernet index 35a90bf9..35cc8eb3 100644 --- a/src/hooks/ports/ethernet +++ b/src/hooks/ports/ethernet @@ -42,7 +42,7 @@ function hook_create() { ADDRESS="" DEVICE=$(device_get_address ${port}) - config_write $(port_file ${port}) ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -52,7 +52,7 @@ function hook_up() { 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 @@ -83,7 +83,7 @@ function hook_hotplug_rename() { 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}) diff --git a/src/hooks/ports/macvlan b/src/hooks/ports/macvlan index 0214465a..a4ce6850 100644 --- a/src/hooks/ports/macvlan +++ b/src/hooks/ports/macvlan @@ -51,7 +51,7 @@ function hook_create() { 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 @@ -63,7 +63,7 @@ function hook_edit() { assert isset port shift - config_read $(port_file ${port}) + port_settings_read "${port}" ${HOOK_SETTINGS} while [ $# -gt 0 ]; do case "${1}" in @@ -77,7 +77,7 @@ function hook_edit() { shift done - config_write $(port_file ${port}) ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -86,7 +86,7 @@ function hook_up() { 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 @@ -101,7 +101,7 @@ function hook_down() { assert isset port - config_read $(port_file ${port}) + port_settings_read "${port}" ${HOOK_SETTINGS} if ! device_exists ${port}; then exit ${EXIT_OK} diff --git a/src/hooks/ports/vlan b/src/hooks/ports/vlan index 20550077..5457c544 100644 --- a/src/hooks/ports/vlan +++ b/src/hooks/ports/vlan @@ -68,7 +68,7 @@ function hook_create() { local port="${PARENT_DEVICE}${VLAN_PORT_INTERFIX}${TAG}" - config_write $(port_file ${port}) ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -78,7 +78,7 @@ function hook_edit() { assert isset port shift - config_read $(port_file ${port}) + port_settings_read "${port}" ${HOOK_SETTINGS} while [ $# -gt 0 ]; do case "${1}" in @@ -92,7 +92,7 @@ function hook_edit() { shift done - config_write $(port_file ${port}) ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -103,7 +103,7 @@ function hook_up() { 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 diff --git a/src/hooks/ports/wireless-ap b/src/hooks/ports/wireless-ap index ba8a7fd5..90a72d09 100644 --- a/src/hooks/ports/wireless-ap +++ b/src/hooks/ports/wireless-ap @@ -94,7 +94,7 @@ function hook_create() { 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} } @@ -105,7 +105,7 @@ function hook_edit() { assert isset port - config_read $(port_file ${port}) + port_settings_read "${port}" ${HOOK_SETTINGS} while [ $# -gt 0 ]; do case "${1}" in @@ -134,7 +134,7 @@ function hook_edit() { shift done - config_write $(port_file ${port}) ${HOOK_SETTINGS} + port_settings_write "${port}" ${HOOK_SETTINGS} exit ${EXIT_OK} } @@ -143,7 +143,7 @@ function hook_up() { 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}) @@ -195,7 +195,7 @@ function hook_hotplug() { 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}) diff --git a/src/hooks/zones/6rd b/src/hooks/zones/6rd index 8dc94a88..2777c907 100644 --- a/src/hooks/zones/6rd +++ b/src/hooks/zones/6rd @@ -46,7 +46,7 @@ function hook_check() { LOCAL_ADDRESS="${PUBLIC_ADDRESS}" fi - assert isset LOCAL_ADDRESS + assert isset LOCAL_ADDRESS # Check input. if ! ipv6_is_valid "${SIX_RD_PREFIX}"; then @@ -101,7 +101,7 @@ function hook_up() { assert isset zone # Read configuration options. - zone_config_read "${zone}" + zone_settings_read "${zone}" ${HOOK_SETTINGS} # Configure the tunnel. if ! device_exists "${zone}"; then @@ -150,7 +150,7 @@ function hook_status() { 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}) diff --git a/src/hooks/zones/6to4-tunnel b/src/hooks/zones/6to4-tunnel index 450b7b93..898d8985 100644 --- a/src/hooks/zones/6to4-tunnel +++ b/src/hooks/zones/6to4-tunnel @@ -102,7 +102,7 @@ function hook_up() { 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" @@ -156,7 +156,7 @@ function hook_status() { 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}) diff --git a/src/hooks/zones/aiccu b/src/hooks/zones/aiccu index e31f8977..86030a4b 100644 --- a/src/hooks/zones/aiccu +++ b/src/hooks/zones/aiccu @@ -109,7 +109,7 @@ function hook_status() { cli_device_headline ${zone} - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} cli_headline 2 "Configuration" cli_print_fmt1 2 "User" "${USERNAME}" diff --git a/src/hooks/zones/bridge b/src/hooks/zones/bridge index e0a56ea6..ed3fd42f 100644 --- a/src/hooks/zones/bridge +++ b/src/hooks/zones/bridge @@ -84,7 +84,7 @@ function hook_up() { 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 @@ -236,7 +236,7 @@ function hook_port_add() { __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}'" @@ -250,12 +250,12 @@ function hook_port_edit() { 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" @@ -272,7 +272,7 @@ function hook_port_remove() { 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} } @@ -283,7 +283,7 @@ function hook_port_up() { 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}" diff --git a/src/hooks/zones/isdn b/src/hooks/zones/isdn index d0070681..37f337bb 100644 --- a/src/hooks/zones/isdn +++ b/src/hooks/zones/isdn @@ -123,7 +123,7 @@ function hook_up() { assert isset zone - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} assert [ -e "/dev/${DEVICE}" ] @@ -175,7 +175,7 @@ function hook_status() { cli_device_headline ${zone} - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} cli_headline 2 "Configuration:" cli_print_fmt1 2 "User" "${USER}" diff --git a/src/hooks/zones/isdn-server b/src/hooks/zones/isdn-server index e9d12cde..9c2adcd0 100644 --- a/src/hooks/zones/isdn-server +++ b/src/hooks/zones/isdn-server @@ -118,7 +118,7 @@ function hook_up() { assert isset zone - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} assert [ -e "/dev/${DEVICE}" ] @@ -191,7 +191,7 @@ function hook_status() { cli_device_headline ${zone} - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} cli_headline " Configuration:" printf "${DEVICE_PRINT_LINE1}" "User:" "${USER}" diff --git a/src/hooks/zones/modem b/src/hooks/zones/modem index e1ffa2a9..7e2e6882 100644 --- a/src/hooks/zones/modem +++ b/src/hooks/zones/modem @@ -140,14 +140,14 @@ function hook_up() { 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 @@ -179,7 +179,7 @@ function hook_status() { cli_device_headline ${zone} - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} cli_headline 2 "Configuration" cli_print_fmt1 2 "Username" "${USERNAME}" @@ -272,7 +272,7 @@ function hook_ppp_write_config() { assert isset file # Read in the configuration files. - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} pppd_write_config ${file} \ --interface="${zone}" \ diff --git a/src/hooks/zones/pppoe b/src/hooks/zones/pppoe index 3882a2b3..a72a2a85 100644 --- a/src/hooks/zones/pppoe +++ b/src/hooks/zones/pppoe @@ -105,7 +105,7 @@ function hook_up() { 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}") @@ -121,7 +121,7 @@ function hook_down() { local zone=${1} assert isset zone - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} # Stop the ppp daemon. pppd_stop ${zone} @@ -169,7 +169,7 @@ function hook_status() { cli_device_headline ${zone} - zone_config_read ${zone} + zone_settings_read "${zone}" ${HOOK_SETTINGS} cli_headline 2 "Configuration" cli_print_fmt1 2 "Username" "${USERNAME}" @@ -227,7 +227,7 @@ function hook_ppp_write_config() { 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}") @@ -295,7 +295,7 @@ function hook_port_add() { 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} @@ -311,7 +311,7 @@ function hook_port_remove() { 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} } diff --git a/src/hooks/zones/pptp b/src/hooks/zones/pptp index f4121fa5..5902a5b5 100644 --- a/src/hooks/zones/pptp +++ b/src/hooks/zones/pptp @@ -86,7 +86,7 @@ function hook_check() { 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 @@ -167,12 +167,10 @@ function hook_up() { 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}" @@ -197,15 +195,13 @@ function hook_down() { 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. @@ -229,7 +225,7 @@ function hook_status() { 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 @@ -287,7 +283,7 @@ function hook_ppp_write_config() { 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" diff --git a/src/hooks/zones/teredo b/src/hooks/zones/teredo index ece306de..6c5abe00 100644 --- a/src/hooks/zones/teredo +++ b/src/hooks/zones/teredo @@ -71,7 +71,7 @@ function hook_status() { # 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}" diff --git a/src/hooks/zones/wireless b/src/hooks/zones/wireless index f4b853a4..e376ab0c 100644 --- a/src/hooks/zones/wireless +++ b/src/hooks/zones/wireless @@ -81,7 +81,7 @@ function hook_up() { 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. diff --git a/src/network b/src/network index 0425d7af..336e9c38 100644 --- a/src/network +++ b/src/network @@ -35,20 +35,20 @@ done . /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 } @@ -1154,7 +1154,7 @@ case "${action}" in 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} $@ ;; diff --git a/src/ppp/dialer b/src/ppp/dialer index ccec5a27..640ad74b 100644 --- a/src/ppp/dialer +++ b/src/ppp/dialer @@ -26,6 +26,9 @@ LOG_DISABLE_STDOUT="true" . /usr/lib/network/functions +# Read network settings +network_settings_read + log DEBUG "dialer called with arguments: $@" # The zone is an optional argument. @@ -35,7 +38,7 @@ assert isset ZONE # 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. diff --git a/src/ppp/pppoe-server b/src/ppp/pppoe-server index 33da580e..75dac188 100644 --- a/src/ppp/pppoe-server +++ b/src/ppp/pppoe-server @@ -25,13 +25,16 @@ 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" diff --git a/src/udev/network-hotplug b/src/udev/network-hotplug index 1b79bd0a..df791d38 100644 --- a/src/udev/network-hotplug +++ b/src/udev/network-hotplug @@ -21,8 +21,8 @@ . /usr/lib/network/functions -# Read network configuration. -network_config_read +# Read network settings +network_settings_read # Setup logging. LOG_FACILITY="network-hotplug" diff --git a/src/udev/network-hotplug-rename b/src/udev/network-hotplug-rename index 5aa2f64b..84c03ded 100644 --- a/src/udev/network-hotplug-rename +++ b/src/udev/network-hotplug-rename @@ -25,8 +25,8 @@ LOG_DISABLE_STDOUT="true" . /usr/lib/network/functions -# Read network configuration. -network_config_read +# Read network settings +network_settings_read # Setup the locking. LOCKFILE="${RUN_DIR}/.rename_lock" diff --git a/src/udev/network-hotplug-serial b/src/udev/network-hotplug-serial index cb40768e..61337022 100644 --- a/src/udev/network-hotplug-serial +++ b/src/udev/network-hotplug-serial @@ -27,8 +27,8 @@ LOG_FACILITY="network-hotplug-serial" # 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}'." @@ -97,7 +97,7 @@ case "${ACTION}" in 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 -- 2.39.2