| 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/dd-wrt-nvram/ 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 |
## |
| 15 |
## These are commands built-in policy installer runs on the firewall if |
| 16 |
## installation is performed using root account for authentication |
| 17 |
## |
| 18 |
## Variables: |
| 19 |
## |
| 20 |
## {{$fwbpromp}} -- "magic" prompt that installer uses to detect when it is logged in |
| 21 |
## {{$fwdir}} -- directory on the firewall |
| 22 |
## {{$fwscript}} -- script name on the firewall |
| 23 |
## {{$rbtimeout}} -- rollback timeout (min) |
| 24 |
## {{$rbtimeout_sec}} -- rollback timeout (sec) |
| 25 |
## |
| 26 |
## {{$firewall_name}} -- the name of the firewall object |
| 27 |
## |
| 28 |
|
| 29 |
|
| 30 |
{{if run}} |
| 31 |
|
| 32 |
{{if with_compression}} |
| 33 |
echo '{{$fwbprompt}}'; |
| 34 |
mv /tmp/{{$fwscript}} /tmp/fwb; |
| 35 |
/usr/sbin/nvram unset rc_firewall; |
| 36 |
/usr/sbin/nvram set rc_firewall="/usr/sbin/nvram get fwb|uudecode|gzip -dc|sh"; |
| 37 |
/usr/sbin/nvram unset fwb; |
| 38 |
/usr/sbin/nvram set fwb="`cat /tmp/fwb|gzip|uuencode -`" || exit 1; |
| 39 |
rm /tmp/fwb; |
| 40 |
echo "Saving data to flash memory"; |
| 41 |
/usr/sbin/nvram commit || exit 1; |
| 42 |
echo "Flash memory:"; |
| 43 |
/usr/sbin/nvram show >/dev/null; |
| 44 |
echo "Activating policy"; |
| 45 |
/usr/sbin/nvram get fwb|uudecode|gzip -dc|sh && echo 'Policy activated' |
| 46 |
{{endif}} |
| 47 |
|
| 48 |
{{if no_compression}} |
| 49 |
echo '{{$fwbprompt}}'; |
| 50 |
mv /tmp/{{$fwscript}} /tmp/fwb; |
| 51 |
/usr/sbin/nvram set rc_firewall="/usr/sbin/nvram get fwb|sh"; |
| 52 |
/usr/sbin/nvram unset fwb; |
| 53 |
/usr/sbin/nvram set fwb="`cat /tmp/fwb`" || exit 1; |
| 54 |
rm /tmp/fwb; |
| 55 |
echo "Saving data to flash memory"; |
| 56 |
/usr/sbin/nvram commit || exit 1; |
| 57 |
echo "Flash memory:"; |
| 58 |
/usr/sbin/nvram show >/dev/null; |
| 59 |
echo "Activating policy"; |
| 60 |
/usr/sbin/nvram get fwb|sh && echo 'Policy activated' |
| 61 |
{{endif}} |
| 62 |
|
| 63 |
{{endif}} |
| 64 |
|
| 65 |
|
| 66 |
|