1#! /bin/sh
2
3###############################################################################
4### THIS SCRIPT IS A QUICK ENTRY TO MANAGE NET-WALL RULEs
5###
6###     Consider some times we need to add|delete|change firewall rules on
7###     urgent, and it's not easy to modify net-wall source code directly,
8###     so add this quick entry to manage firewall rules.
9###
10###     Each time when `net-wall start|restart` command executes, this script
11###     will be called with parameter "start", and of course, `net-wall stop`
12###     will call this script with parameter "stop".
13###
14### NOTE: THIS SCRIPT IS *JUST* A QUICK ENTRY, PLEASE MANAGE FIREWALL RULES
15### IN NET-WALL SOURCE CODE AS FAR AS POSSIBLE. AND PLEASE MOVE SOME CHANGES
16### IN THIS FILE INTO NET-WALL SOURCE CODE IN THE FUTURE TO KEEP THIS FILE
17### IS CONCISE TO REDUCE AFFECTS OF NET-WALL'S PERFORMANCE.
18###############################################################################
19
20IPTB=/usr/sbin/iptables
21CONFIG=${CONFIG:-/bin/config}
22
23LIBDIR=/etc/scripts/firewall
24
25get_configs()
26{
27	:
28}
29
30firewall_start()
31{
32	# start extra firewall rules
33	ls ${LIBDIR}/*.rule | while read rule
34	do
35		$SHELL $rule start
36	done
37}
38
39firewall_stop()
40{
41	# stop extra firewall rules
42	ls ${LIBDIR}/*.rule | while read rule
43	do
44		$SHELL $rule stop
45	done
46}
47
48get_configs
49case $1 in
50	"start"|"START")
51		firewall_start;;
52	"stop"|"STOP")
53		firewall_stop;;
54	*)
55		printf "Usage: ${0##*/} start|stop\n";;
56esac
57