-
-
Save elico/62dd7eed0979405efb91a218bcbfdb2c to your computer and use it in GitHub Desktop.
Helper script for RouterOS GeoIP managment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USERNAME="admin" | |
PASSWORD="testAdmin" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
ROUTEROS_ADDRESS="$1" | |
COUNTRY="$2" | |
CIDR_FILE="ipv4/${COUNTRY}.cidr" | |
current_time=$(date "+%Y.%m.%d-%H.%M.%S") | |
source .env | |
stat "${CIDR_FILE}" >/dev/null 2>&1 | |
if [ "$?" -gt "0" ];then | |
echo "Missing country file" | |
exit 1 | |
fi | |
cat "${CIDR_FILE}" | xargs -P 10 -l1 -n1 -I{} \ | |
curl -s -k -u "${USERNAME}:${PASSWORD}" -X PUT "https://${ROUTEROS_ADDRESS}/rest/ip/firewall/address-list" \ | |
--data "{ \"address\": \"{}\" ,\"list\":\"Country_${COUNTRY}\"}" \ | |
-H "content-type: application/json" | |
echo "" | |
echo "Finished Adding country enteries" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment