]>
git.ipfire.org Git - people/ms/network.git/blob - functions.config
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 # Load all global configuration files.
23 function config_read_globals
() {
28 function config_read
() {
29 local config_file
=${1}
30 assert isset config_file
32 if [ -e "${config_file}" ]; then
38 function config_write
() {
39 local config_file
=${1}
40 assert isset config_file
43 # Check if all values to be written are sane
46 log DEBUG
"Writing configuration file ${config_file}."
48 mkdir
-p $
(dirname ${config_file}) 2>/dev
/null
52 for param
in $
(listsort $@
); do
53 echo "${param}=\"${!param}\"" >> ${config_file}
57 function config_print() {
60 for param in $(listsort $@); do
61 printf "%-24s = %s
\n" "${param}" "${!param}"
65 function config_check() {
66 # If there is a function defined that is called __check
67 # we call that function
68 [ -n "$
(type -t _check
)" ] && _check
71 function config_header() {
77 echo "# This is a ${what}."
78 echo "# THIS FILE IS AUTOMATICALLY GENERATED AND WILL OVERWRITE"
79 echo "# ANY CUSTOM CHANGES!"
86 function config_hostname
() {
89 if [ -n "${hostname}" ]; then
90 echo "${hostname}" > ${CONFIG_HOSTNAME}
92 echo "$(<${CONFIG_HOSTNAME})"
96 function config_set
() {
97 while [ $# -gt 0 ]; do
100 log INFO
"Setting configuration option '${1}'".
104 warning
"Invalid parameter given: ${1}"
111 function network_config_read
() {
112 # Save state of DEBUG and restore it later.
115 config_read
${NETWORK_CONFIG_FILE}
117 if [ -n "${debug}" ]; then
122 function network_config_write
() {
123 config_write
${NETWORK_CONFIG_FILE} ${NETWORK_CONFIG_FILE_PARAMS}
125 # Update DNS configuration.
126 dns_generate_resolvconf
129 function network_config_print
() {
130 config_print
${NETWORK_CONFIG_FILE_PARAMS}
133 function firewall_config_read
() {
134 config_read
${FIREWALL_CONFIG_FILE}
137 function firewall_config_write
() {
138 config_write
${FIREWALL_CONFIG_FILE} \
139 ${FIREWALL_CONFIG_PARAMS}
142 function firewall_config_print
() {
143 config_print
${FIREWALL_CONFIG_PARAMS}