## -*- mode: shell-script; -*- 
##
## To be able to make changes to the part of configuration created
## from this configlet you need to copy this file to the directory
## fwbuilder/configlets/sveasoft/ in your home directory and modify it.
## Double "##" comments are removed during processing but single "#"
## comments are be retained and appear in the generated script. Empty
## lines are removed as well.  
##
## Configlets support simple macro language with these constructs:
## {{$var}} is variable expansion
## {{if var}} is conditional operator.
##
## Note that /bin/sh on Sveasoft (busybox) does not like empty shell
## functions and fails with an error "36: Syntax error: "}" unexpected"
## Will call /bin/true as a placeholder so that if some other
## commands are added to the function body during template expansion,
## they are executed after /bin/true and their return code is
## preserved. If no commands are added, then the function body won't
## be empty and will return success.
{{$top_comment}}

{{$shell_debug}}

{{$path}}

{{$constants}}

{{$tools}}

{{$shell_functions}}

## we do not load modules on Sveasoft
load_modules() {
    :
}

verify_interfaces() {
    :
    {{$verify_interfaces}}
}

prolog_commands() {
    :
    {{$prolog_script}}
}

epilog_commands() {
    :
    {{$epilog_script}}
}

run_epilog_and_exit() {
    epilog_commands
    exit $1
}

configure_interfaces() {
    :
    {{$configure_interfaces}}
}

script_body() {
    {{$script_body}}
}

ip_forward() {
    :
    {{$ip_forward_commands}}
}

reset_all() {
    :
    {{$reset_all}}
}

{{$stop_action}}

log "Activating firewall script generated {{$timestamp}} by {{$user}}"
check_tools
{{if prolog_top}}prolog_commands{{endif}}
load_modules
configure_interfaces
verify_interfaces
{{if prolog_after_interfaces}}prolog_commands{{endif}}
{{if not_using_iptables_restore}} reset_all {{endif}}
{{if prolog_after_flush}}prolog_commands{{endif}}
script_body
ip_forward
epilog_commands
