#!/bin/bash

UPDATE_INTERVAL="weekly"

# Get the latest location database from server.
/usr/bin/location update --cron=$UPDATE_INTERVAL
if [ $? -eq 0 ]; then
	# Call location and export all countries in an ipset compatible format
	/usr/bin/location export --directory=/var/lib/location/ipset --family=ipv4 --format=ipset
	if [ $? -eq 0 ]; then
		systemctl is-active --quiet firewalld.service
		if [ $? -eq 0 ]; then
			systemctl reload firewalld.service
		fi
	fi
fi
