summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--op-mode-definitions/geoip.xml.in15
-rwxr-xr-xsrc/helpers/geoip-update.py17
2 files changed, 23 insertions, 9 deletions
diff --git a/op-mode-definitions/geoip.xml.in b/op-mode-definitions/geoip.xml.in
index eb9d65ea9..8c51817f2 100644
--- a/op-mode-definitions/geoip.xml.in
+++ b/op-mode-definitions/geoip.xml.in
@@ -2,12 +2,23 @@
<interfaceDefinition>
<node name="update">
<children>
- <leafNode name="geoip">
+ <node name="geoip">
<properties>
<help>Update GeoIP database and firewall sets</help>
</properties>
+ <children>
+ <tagNode name="vrf">
+ <properties>
+ <help>VRF to use for GeoIP update</help>
+ <completionHelp>
+ <path>vrf name</path>
+ </completionHelp>
+ </properties>
+ <command>sudo ip vrf exec $4 ${vyos_libexec_dir}/geoip-update.py</command>
+ </tagNode>
+ </children>
<command>sudo ${vyos_libexec_dir}/geoip-update.py</command>
- </leafNode>
+ </node>
</children>
</node>
</interfaceDefinition>
diff --git a/src/helpers/geoip-update.py b/src/helpers/geoip-update.py
index 8a414267e..18ad0ecb8 100755
--- a/src/helpers/geoip-update.py
+++ b/src/helpers/geoip-update.py
@@ -13,6 +13,8 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# Note: script is used both in opmode and by build hook `40-init-geoip-database.chroot`
import argparse
import sys
@@ -26,12 +28,7 @@ from vyos.geoip import db_import_dbip_ranges
from vyos.geoip import db_import_maxmind_ranges
from vyos.geoip import geoip_update
-def get_config(config=None):
- if config:
- conf = config
- else:
- conf = ConfigTreeQuery()
-
+def get_config(conf):
return (
conf.get_config_dict(['firewall', 'global-options', 'geoip'], key_mangling=('-', '_'), get_first_key=True,
no_tag_node_value_mangle=True, with_defaults=True),
@@ -51,7 +48,13 @@ if __name__ == '__main__':
db_import_dbip_ranges(delete_file=True)
sys.exit(0)
- options, firewall, policy = get_config()
+ conf = ConfigTreeQuery()
+
+ if not conf.exists(['system', 'name-server']):
+ print('There are no system name-servers configured')
+ sys.exit(1)
+
+ options, firewall, policy = get_config(conf)
if not db_is_initialised():
db_initialise()