97be5eb0fec9f017b307d9d8e40ef25f78ac0b89
[feed/routing.git] / bird-openwrt / bird4-openwrt / src / uci-defaults / 99-relocate-filters
1 #!/bin/sh
2
3 # This UCI-Defaults script will MOVE any pre-existing filter
4 # stored in a file and configured as an UCI item (deprecated)
5 # The script will try to match any "filter" Section, get its
6 # "file_path" property and move the file (if exists) to the
7 # new (v0.3+) default location: /etc/bird{4|6}/filters
8
9 [ $# -ne 1 ] && exit 1
10 BIRD="$1"
11
12 . /lib/functions.sh
13
14 # This function will move an existing folder configured on
15 # Bird as a "filter" to filters' folder.
16 mv_filter() {
17 local section="$1"
18 local file_path
19 config_get file_path ${section} file_path
20
21 if [ -f ${file_path} ]; then
22 mv ${file_path} /etc/${BIRD}/filters/
23 fi
24 uci delete ${BIRD}.${section}
25 }
26
27 if [ -f /etc/config/${BIRD} ]; then
28 config_load ${BIRD}
29 config_foreach mv_filter 'filter'
30 uci commit ${BIRD}
31 fi
32
33 exit 0