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 ###############################################################################
27 # Parse the command line
28 while [ $# -gt 0 ]; do
32 log DEBUG
"Enabled debugging mode"
39 [ -n "${action}" ] && break
42 # Process the given action
45 firewall_start
"${protocol}" "$@"
49 firewall_stop
"${protocol}" "$@"
53 firewall_show
"${protocol}" "$@"
57 firewall_cli_panic
"${protocol}" "$@"
61 firewall_cli_zone
"$@"
70 error
"Invalid command given: ${action}"
72 exit ${EXIT_CONF_ERROR}
79 firewall_cli_panic
() {
84 if cli_help_requested
"$@"; then
85 cli_show_man firewall-panic
90 while [ $# -gt 0 ]; do
93 if ip_is_valid
${1}; then
94 admin_hosts
="${admin_hosts} ${1}"
96 warning
"Invalid IP address: ${1}"
103 firewall_panic
${admin_hosts}
106 firewall_cli_settings
() {
107 if cli_help_requested
"$@"; then
108 cli_show_man firewall-settings
112 if [ -n "${1}" ]; then
114 firewall_settings_write
116 firewall_settings_print
120 firewall_cli_zone
() {
121 local protocol
="${1}"
122 assert isset protocol
125 if cli_help_requested
"$@"; then
126 cli_show_man firewall-zone
130 if zone_name_is_valid
${1}; then
135 # Check if the given zone exists.
136 if ! zone_exists
${zone}; then
137 error
"Zone '${zone}' does not exist."
138 cli_run_help firewall zone
143 # Process the given action.
146 firewall_cli_zone_edit
${zone} "$@"
149 firewall_cli_zone_status
${zone} "$@"
152 # Print the raw configuration settings.
154 firewall_zone_print
${zone} "$@"
159 error
"Unrecognized action: ${action}"
160 cli_run_help firewall zone
171 firewall_zone_reset
"$@"
176 error
"Unrecognized action: ${action}"
177 cli_run_help firewall zone
185 # Show firewall zone conifguration.
186 firewall_cli_zone_status
() {
191 firewall_zone_read
${zone}
193 cli_headline
1 "Zone ${zone} (policy ${POLICY})"
194 cli_print_fmt1
1 "Masquerade" "$(cli_print_bool ${MASQUERADE})"
202 # Edit firewall zone configuration.
203 firewall_cli_zone_edit
() {
204 firewall_zone_edit
"$@"