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}
31 log DEBUG
"Reading configuration: ${config_file}"
33 if [ -e "${config_file}" ]; then
39 function config_write
() {
40 local config_file
=${1}
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 "%-16s = %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_hostname() {
74 if [ -n "${hostname}" ]; then
75 echo "${hostname}" > ${CONFIG_HOSTNAME}
77 echo "$
(<${CONFIG_HOSTNAME})"
81 function config_set() {
82 while [ $# -gt 0 ]; do
85 log INFO "Setting configuration option
'${1}'".
89 warning "Invalid parameter given
: ${1}"
96 function network_config_read() {
97 # Save state of DEBUG and restore it later.
100 config_read ${CONFIG_FILE}
102 if [ -n "${debug}" ]; then
107 function network_config_write() {
108 config_write ${CONFIG_FILE} ${CONFIG_FILE_PARAMS}
111 function network_config_print() {
112 config_print ${CONFIG_FILE_PARAMS}
115 function firewall_config_read() {
116 config_read ${FIREWALL_CONFIG_FILE}
119 function firewall_config_write() {
120 config_write ${FIREWALL_CONFIG_FILE} \
121 ${FIREWALL_CONFIG_PARAMS}
124 function firewall_config_print() {
125 config_print ${FIREWALL_CONFIG_PARAMS}