initial commit of file from CVS for smeserver-geoip on Sat Sep 7 20:26:07 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:26:07 +10:00
parent 668d7517d0
commit ca710f1de3
25 changed files with 1033 additions and 2 deletions

26
root/usr/bin/geocity.pl Executable file
View File

@@ -0,0 +1,26 @@
#!/usr/bin/perl
use GeoIP2::Database::Reader;
# GeoLite2-City.mmdb
if ( $ARGV[0] eq '-h' || $ARGV[0] eq '-help' || $ARGV[0] eq '' ) {
help();
exit;
}
my $reader = GeoIP2::Database::Reader->new(
file => '/usr/share/GeoIP/GeoLite2-City.mmdb',
locales => [ 'en', 'de', ]
);
my $city = $reader->city( ip => $ARGV[0] );
my $city_rec = $city->city();
print "City: ", $city_rec->name(), "\n";
my $country = $city->country();
print "Country: ", $country->iso_code(), "\n";
sub help {
print "Usage: ./geoipcity.pl 1.2.3.4\n";
}

22
root/usr/bin/geocountry.pl Executable file
View File

@@ -0,0 +1,22 @@
#!/usr/bin/perl
use GeoIP2::Database::Reader;
if ( $ARGV[0] eq '-h' || $ARGV[0] eq '-help' || $ARGV[0] eq '' ) {
help();
exit;
}
my $reader = GeoIP2::Database::Reader->new(
file => '/usr/share/GeoIP/GeoLite2-Country.mmdb',
locales => [ 'en', 'de', ]
);
my $country = $reader->country( ip => $ARGV[0] );
my $country_rec = $country->country();
print "Country ", $country_rec->iso_code(), "\n";
sub help {
print "Usage: ./geoipcountry.pl 1.2.3.4\n";
}

6
root/usr/bin/geoiplook Normal file
View File

@@ -0,0 +1,6 @@
#!/bin/bash
for var in "$@"
do
/usr/bin/mmdblookup --file /usr/share/GeoIP/GeoLite2-Country.mmdb --ip $1 country iso_code |cut -d\" -f2| tr -d '\n'
echo ""
done