Debian Codegraph @

src/res/configlets/dd-wrt-jffs/script_skeleton

raw
1 ## -*- mode: shell-script; -*-
2 ##
3 ## Double '##' comments are removed when configlet is processed.
4 ## Single '#' comments stay.
5 ##
6 ## Some shells (not bash) do not like empty functions. Placing a comment
7 ## inside the function does not help. Using dummy ":" as a placeholder.
8 ##
9 {{$top_comment}}
10
11 {{$errors_and_warnings}}
12
13 {{$shell_debug}}
14 FWBDEBUG=""
15
16 {{$path}}
17
18 {{$constants}}
19
20 {{$tools}}
21
22 {{$shell_functions}}
23
24 {{$run_time_address_tables}}
25
26 load_modules() {
27 :
28 {{$load_modules}}
29 }
30
31 verify_interfaces() {
32 :
33 {{$verify_interfaces}}
34 }
35
36 prolog_commands() {
37 echo "Running prolog script"
38 {{$prolog_script}}
39 }
40
41 epilog_commands() {
42 echo "Running epilog script"
43 {{$epilog_script}}
44 }
45
46 run_epilog_and_exit() {
47 epilog_commands
48 exit $1
49 }
50
51 configure_interfaces() {
52 :
53 {{$configure_interfaces}}
54 }
55
56 script_body() {
57 {{$script_body}}
58 }
59
60 ip_forward() {
61 :
62 {{$ip_forward_commands}}
63 }
64
65 reset_all() {
66 :
67 {{$reset_all}}
68 }
69
70 {{$block_action}}
71
72 {{$stop_action}}
73
74 {{$status_action}}
75
76 # See how we were called.
77 # For backwards compatibility missing argument is equivalent to 'start'
78
79 cmd=$1
80 test -z "$cmd" && {
81 cmd="start"
82 }
83
84 case "$cmd" in
85 start)
86 log "Activating firewall script generated {{$timestamp}} by {{$user}}"
87 check_tools
88 {{if prolog_top}} prolog_commands {{endif}}
89 check_run_time_address_table_files
90 {{if using_ipset}}
91 check_module_ipset
92 load_run_time_address_table_files
93 {{endif}}
94 load_modules "{{$load_modules_with_nat}} {{$load_modules_with_ipv6}}"
95 configure_interfaces
96 verify_interfaces
97 {{if prolog_after_interfaces}} prolog_commands {{endif}}
98 {{if not_using_iptables_restore}} reset_all {{endif}}
99 {{if prolog_after_flush}} prolog_commands {{endif}}
100 script_body
101 ip_forward
102 epilog_commands
103 RETVAL=$?
104 ;;
105
106 stop)
107 stop_action
108 RETVAL=$?
109 ;;
110
111 status)
112 status_action
113 RETVAL=$?
114 ;;
115
116 block)
117 block_action
118 RETVAL=$?
119 ;;
120
121 reload)
122 $0 stop
123 $0 start
124 RETVAL=$?
125 ;;
126
127 interfaces)
128 configure_interfaces
129 RETVAL=$?
130 ;;
131
132 test_interfaces)
133 FWBDEBUG="echo"
134 configure_interfaces
135 RETVAL=$?
136 ;;
137
138 {{if using_ipset}}
139 ## Usage: script.fw reload_address_table <address_table_name> <file_name>
140 reload_address_table)
141 reload_address_table $2 $3
142 ;;
143
144 ## Usage: script.fw add_to_address_table <address_table_name> <file_name> <address>
145 add_to_address_table)
146 add_to_address_table $2 $3 $4
147 ;;
148
149 ## Usage: script.fw remove_from_address_table <address_table_name> <file_name> <address>
150 remove_from_address_table)
151 remove_from_address_table $2 $3 $4
152 ;;
153
154 ## Usage: script.fw test_address_table <address_table_name> <address>
155 test_address_table)
156 test_address_table $2 $3
157 ;;
158 {{endif}}
159
160 *)
161 echo "Usage $0 [start|stop|status|block|reload|interfaces|test_interfaces{{if using_ipset}}|reload_address_table|add_to_address_table|remove_from_address_table|test_address_table{{endif}}]"
162 ;;
163
164 esac
165
166 exit $RETVAL