]> git.ipfire.org Git - people/arne_f/ipfire-3.x.git/blame - firewall/src/functions
Move all packages to root.
[people/arne_f/ipfire-3.x.git] / firewall / src / functions
CommitLineData
8838c71a
MT
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2009 Michael Tremer & Christian Schmidt #
6# #
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. #
11# #
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. #
16# #
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/>. #
19# #
20###############################################################################
21
2534973b 22DEBUG=
8838c71a
MT
23VERBOSE=
24TMPDIR=$(mktemp -d)
25
26BOLD="\\033[1;39m"
27NORMAL="\\033[0;39m"
28ERROR="\\033[1;31m"
29
2534973b
MT
30function debug() {
31 if [ -n "$1" ]; then
32 DEBUG=$1
33 verbose $1
34 return
35 else
36 if [ "$DEBUG" = "1" ]; then
37 return 0
38 else
39 return 1
40 fi
41 fi
42
43}
44
8838c71a
MT
45function verbose() {
46 if [ -n "$1" ]; then
47 VERBOSE=$1
48 return
49 else
50 if [ "$VERBOSE" = "1" ]; then
51 return 0
52 else
53 return 1
54 fi
55 fi
56}
57
2534973b
MT
58function decho() {
59 debug && echo -e "${ERROR}$@${NORMAL}"
60}
61
8838c71a
MT
62function vecho() {
63 verbose && echo -e "$@"
64}
65
66function error() {
67 echo -e "${ERROR}ERROR${NORMAL}: $@" >&2
68 _exit 1
69}
70
71function ifs() {
72 if [ -n "$1" ]; then
73 IFS_SAVE=$IFS
74 echo $1
75 else
76 echo $IFS_SAVE
77 fi
78}
79
80function uppercase() {
81 tr [a-z] [A-Z] <<< "$@"
82}
83
84include functions.commands
85include functions.config
86include functions.firewall
87include functions.ip
88include functions.iptables
89include functions.macros
90include functions.zones
91
92function _start() {
dbfeda6c
MT
93 local zone
94 local policy
95
8838c71a 96 firewall_init
2534973b
MT
97 zones_local_add
98
dbfeda6c
MT
99 for zone in $(network zone list); do
100 zone=$(basename ${zone})
101 policy=${zone%%[0-9]*}
102 zones_${policy}_add ${zone}
103 done
2534973b 104
8838c71a 105 iptables_commit
b5238f57
MT
106}
107
108function _stop() {
dbfeda6c
MT
109 iptables_flush
110 iptables_commit
8838c71a 111}