| 1 |
## -*- mode: shell-script; -*- |
| 2 |
## |
| 3 |
## To be able to make changes to the part of configuration created |
| 4 |
## from this configlet you need to copy this file to the directory |
| 5 |
## fwbuilder/configlets/sveasoft/ in your home directory and modify it. |
| 6 |
## Double "##" comments are removed during processing but single "#" |
| 7 |
## comments are be retained and appear in the generated script. Empty |
| 8 |
## lines are removed as well. |
| 9 |
## |
| 10 |
## Configlets support simple macro language with these constructs: |
| 11 |
## {{$var}} is variable expansion |
| 12 |
## {{if var}} is conditional operator. |
| 13 |
## |
| 14 |
## Note that /bin/sh on Sveasoft (busybox) does not like empty shell |
| 15 |
## functions and fails with an error "36: Syntax error: "}" unexpected" |
| 16 |
## Will call /bin/true as a placeholder so that if some other |
| 17 |
## commands are added to the function body during template expansion, |
| 18 |
## they are executed after /bin/true and their return code is |
| 19 |
## preserved. If no commands are added, then the function body won't |
| 20 |
## be empty and will return success. |
| 21 |
{{$top_comment}} |
| 22 |
|
| 23 |
{{$shell_debug}} |
| 24 |
|
| 25 |
{{$path}} |
| 26 |
|
| 27 |
{{$constants}} |
| 28 |
|
| 29 |
{{$tools}} |
| 30 |
|
| 31 |
{{$shell_functions}} |
| 32 |
|
| 33 |
{{$run_time_address_tables}} |
| 34 |
|
| 35 |
load_modules() { |
| 36 |
: |
| 37 |
{{$load_modules}} |
| 38 |
} |
| 39 |
|
| 40 |
verify_interfaces() { |
| 41 |
: |
| 42 |
{{$verify_interfaces}} |
| 43 |
} |
| 44 |
|
| 45 |
prolog_commands() { |
| 46 |
: |
| 47 |
{{$prolog_script}} |
| 48 |
} |
| 49 |
|
| 50 |
epilog_commands() { |
| 51 |
: |
| 52 |
{{$epilog_script}} |
| 53 |
} |
| 54 |
|
| 55 |
run_epilog_and_exit() { |
| 56 |
epilog_commands |
| 57 |
exit $1 |
| 58 |
} |
| 59 |
|
| 60 |
configure_interfaces() { |
| 61 |
: |
| 62 |
{{$configure_interfaces}} |
| 63 |
} |
| 64 |
|
| 65 |
script_body() { |
| 66 |
{{$script_body}} |
| 67 |
} |
| 68 |
|
| 69 |
ip_forward() { |
| 70 |
: |
| 71 |
{{$ip_forward_commands}} |
| 72 |
} |
| 73 |
|
| 74 |
reset_all() { |
| 75 |
: |
| 76 |
{{$reset_all}} |
| 77 |
} |
| 78 |
|
| 79 |
log "Activating firewall script generated {{$timestamp}} by {{$user}}" |
| 80 |
check_tools |
| 81 |
{{if prolog_top}}prolog_commands{{endif}} |
| 82 |
check_run_time_address_table_files |
| 83 |
{{if using_ipset}} |
| 84 |
check_module_ipset |
| 85 |
load_run_time_address_table_files |
| 86 |
{{endif}} |
| 87 |
load_modules |
| 88 |
configure_interfaces |
| 89 |
verify_interfaces |
| 90 |
{{if prolog_after_interfaces}}prolog_commands{{endif}} |
| 91 |
{{if not_using_iptables_restore}} reset_all {{endif}} |
| 92 |
{{if prolog_after_flush}}prolog_commands{{endif}} |
| 93 |
script_body |
| 94 |
ip_forward |
| 95 |
epilog_commands |