]> git.ipfire.org Git - people/ms/network.git/blame - firewall
util: Make a shortcut for "which".
[people/ms/network.git] / firewall
CommitLineData
98146c00
MT
1#!/bin/bash
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2012 IPFire Network Development Team #
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. /usr/lib/network/functions
23
24function cli_start() {
25 firewall_start
26}
27
28function cli_stop() {
29 firewall_stop
30}
31
3647b19f
MT
32function cli_config() {
33 if cli_help_requested $@; then
34 cli_usage root-config
35 exit ${EXIT_OK}
36 fi
37
38 if [ -n "${1}" ]; then
39 config_set $@
40 firewall_config_write
41 else
42 firewall_config_print
43 fi
44}
45
98146c00
MT
46# Parse the command line
47while [ $# -gt 0 ]; do
48 case "${1}" in
49 -d|--debug)
50 DEBUG=1
51 log DEBUG "Enabled debugging mode"
52 ;;
53 *)
54 action=${1}
55 ;;
56 esac
57 shift
58 [ -n "${action}" ] && break
59done
60
61# Process the given action
62case "${action}" in
63 start|restart|reload)
64 cli_start $@
65 ;;
66
67 stop)
68 cli_stop $@
69 ;;
70
3647b19f
MT
71 config)
72 cli_config $@
73 ;;
74
98146c00
MT
75 ""|help|--help|-h)
76 cli_usage root
77 exit ${EXIT_OK}
78 ;;
79
80 *)
81 error "Invalid command given: ${action}"
82 cli_usage usage
83 exit ${EXIT_CONF_ERROR}
84 ;;
85esac
86
87exit ${EXIT_OK}