Fix to make update.sh runnable from anywhere

This commit is contained in:
Dan Church 2021-01-29 21:36:14 -06:00
parent c6f800c04a
commit d1edd1d520
Signed by: h3xx
GPG Key ID: EA2BF379CD2CDBD0
1 changed files with 5 additions and 2 deletions

View File

@ -4,6 +4,7 @@ use strict;
use warnings; use warnings;
use Getopt::Long qw/ GetOptions :config no_ignore_case /; use Getopt::Long qw/ GetOptions :config no_ignore_case /;
use File::Basename qw/ dirname /;
my %domains; my %domains;
my $dupes = 0; my $dupes = 0;
@ -54,6 +55,7 @@ sub add_host_file {
MAIN: { MAIN: {
my $out = 'block.list'; my $out = 'block.list';
my $block_ip = '0.0.0.0'; my $block_ip = '0.0.0.0';
my $workdir = &dirname($0);
unless (&GetOptions( unless (&GetOptions(
'out=s' => \$out, 'out=s' => \$out,
@ -63,8 +65,9 @@ MAIN: {
)) { )) {
exit 2; exit 2;
} }
my @domain_lists = glob 'lists/*.domains';
my @hosts_lists = glob 'lists/*.hosts'; my @domain_lists = glob "$workdir/lists/*.domains";
my @hosts_lists = glob "$workdir/lists/*.hosts";
foreach my $listfile (@domain_lists) { foreach my $listfile (@domain_lists) {
&add_domain_list($listfile); &add_domain_list($listfile);