Skip to content

Automatically update Geoblock files - #2663

Merged
enoch85 merged 15 commits into
mainfrom
geoblock-update
Sep 13, 2024
Merged

enoch85 merged 15 commits into
mainfrom
geoblock-update

Conversation

@enoch85

@enoch85 enoch85 commented Sep 12, 2024 •

Copy link
Copy Markdown
Member

@szaimen GeoIP is your implementation, but it doesn't automatically fetch latest geofile. To solve that, I made this.

I found that https://www.miyuru.lk/geoiplegacy actually posts the month and year it's been updated, so I thought that we could scrape that info with curl, and then compare with the current file on the system - and that's what this change does.

Please give your opinion. Maybe there's a smarter way?

@szaimen This is your implementation, but I think this would be possible.

I found that https://www.miyuru.lk/geoiplegacy actually posts the month and year it's been updated, so I thougt that we could scrape that info with curl, and then compare with the current file on the system - and that's what this script does.

Please give your opinion.

Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
@enoch85

enoch85 commented Sep 13, 2024

Copy link
Copy Markdown
Member Author

Note to self: check connectivity before proceeding.

Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
Signed-off-by: Daniel Hansson <[email protected]>
@enoch85

enoch85 commented Sep 13, 2024

Copy link
Copy Markdown
Member Author

Tested and works, I'll merge this now!

@enoch85
enoch85 merged commit 9d7f90c into main Sep 13, 2024
@enoch85
enoch85 deleted the geoblock-update branch September 13, 2024 16:17
@szaimen

szaimen commented Sep 15, 2024 •

Copy link
Copy Markdown
Collaborator

Hi @enoch85,

sorry for coming back to you so late. I was very busy.

The reason why I did not implement it like this was this warning on https://www.miyuru.lk/geoiplegacy:
image
So I used Github as a relay basically.

@szaimen

szaimen commented Sep 15, 2024

Copy link
Copy Markdown
Collaborator

Btw, yesterday was my server automatically updated and it ran into the following issue:
image
This lead to ipv4 connections not working correctly anymore.
So it seems like there is something wrong with your implementation.
Shall I open a bug report?

@enoch85

enoch85 commented Sep 15, 2024

Copy link
Copy Markdown
Member Author

Hi @enoch85,

sorry for coming back to you so late. I was very busy.

The reason why I did not implement it like this was this warning on [image] So I used Github as a relay basically.

Valid point. I actually asked the owner of the website myself, and he's fine with it! :)

This lead to ipv4 connections not working correctly anymore.

So the filename has to be GeoIP.dat? I find it strange that you can't set you own name in the config...

@szaimen

szaimen commented Sep 15, 2024 •

Copy link
Copy Markdown
Collaborator

This lead to ipv4 connections not working correctly anymore.

So the filename has to be GeoIP.dat? I find it strange that you can't set you own name in the config...

No, the problem is that the geoip file that is on my system does not match the apache config. Somehow this got messed up after your PR...

@enoch85

enoch85 commented Sep 15, 2024

Copy link
Copy Markdown
Member Author

So, what's the output of:

ls -l /usr/share/GeoIP
cat /etc/apache2/apache2.conf

@szaimen

szaimen commented Sep 15, 2024

Copy link
Copy Markdown
Collaborator

I posted the information in the screenshot above already...

@enoch85

enoch85 commented Sep 15, 2024

Copy link
Copy Markdown
Member Author

Sorry...

I'll have another look and check if we can fix it, probably an easy fix. :)

@enoch85

enoch85 commented Sep 15, 2024

Copy link
Copy Markdown
Member Author

Can you try to run this:

#!/bin/bash
source /var/scripts/fetch_lib.sh

# Get newest dat files for geoblock.sh
if grep -q "^#Geoip-block" /etc/apache2/apache2.conf
then
    if get_newest_dat_files
    then
        if grep -c GeoIP.dat /etc/apache2/apache2.conf
        then
            if [ ! -f /usr/share/GeoIP/GeoIPv4.dat ]
            then
                if download_geoip_dat 4 v4
                then
                    sed -i "s|GeoIPDBFile /usr/share/GeoIP/GeoIP.dat|GeoIPDBFile /usr/share/GeoIP/GeoIPv4.dat|g" /etc/apache2/apache2.conf
                fi
            fi
        fi
        check_command systemctl restart apache2
    fi
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants