]>
Commit | Line | Data |
---|---|---|
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 | ||
22 | ############################################################################### | |
23 | # This is the script, that is runned by the user to contol the firewall # | |
24 | # We only do some actions here and call the functions from the libs. # | |
25 | # # | |
26 | # Actions (as known at the moment): # | |
27 | # - start/stop/restart/reload # | |
28 | # - show # | |
29 | # - running? # | |
30 | # - serveral config # | |
31 | # - calc (cidr|subnets|...) # | |
32 | # - ... # | |
33 | # # | |
34 | ############################################################################### | |
35 | ||
b5238f57 MT |
36 | PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin |
37 | ||
8838c71a MT |
38 | LIBDIR=/usr/lib/firewall |
39 | ||
40 | function include() { | |
41 | local file=$1 | |
42 | local path | |
43 | for path in $LIBDIR .; do | |
44 | if [ -f "$path/$file" ]; then | |
45 | . $path/$file | |
46 | return # found | |
47 | fi | |
48 | done | |
49 | echo "Couldn't include $file. File was not found!" >&2 | |
50 | _exit 1 | |
51 | } | |
52 | ||
53 | function usage() { | |
54 | echo "Usage: $0 [global options] command [command options]" | |
55 | echo | |
56 | _exit ${1-1} | |
57 | } | |
58 | ||
59 | include functions | |
60 | ||
61 | while [ "$#" -gt 0 ]; do | |
2534973b MT |
62 | arg=$1 |
63 | shift | |
64 | case "$arg" in | |
65 | --debug|-d) | |
66 | debug 1 | |
67 | decho "Debug mode is enabled." | |
68 | ;; | |
8838c71a MT |
69 | --verbose|-v) |
70 | verbose 1 | |
71 | vecho "${BOLD}Verbose mode is enabled.${NORMAL}" | |
72 | ;; | |
73 | calc) | |
74 | shift | |
75 | case "$1" in | |
76 | mask2cidr) | |
2534973b | 77 | mask_to_cidr $@ |
8838c71a MT |
78 | _exit $? |
79 | ;; | |
80 | *) | |
81 | usage | |
82 | ;; | |
83 | esac | |
84 | ;; | |
85 | config) | |
2534973b | 86 | config_load $@ |
8838c71a MT |
87 | _exit $? |
88 | ;; | |
89 | help|-h|--help) | |
90 | usage 0 | |
91 | ;; | |
92 | notify) | |
93 | ;; | |
94 | reload) | |
95 | ;; | |
dbfeda6c | 96 | start|restart) |
8838c71a | 97 | _start |
2534973b | 98 | _exit $@ |
8838c71a MT |
99 | ;; |
100 | stop) | |
b5238f57 MT |
101 | _stop |
102 | _exit $@ | |
8838c71a MT |
103 | ;; |
104 | *) | |
105 | usage | |
106 | ;; | |
107 | esac | |
8838c71a MT |
108 | done |
109 | ||
110 | error "No command was given." | |
111 | usage |