Current File : //bin/pullrbllists
#!/usr/bin/perl

##########################################################################
# pullrbllists - A script that pulls down lists that can be used with RBLD
# Copyright 2006, Bluehost, Inc.
#
# Authors and Contributers:
#
# Spencer Candland  <spencer@bluehost.com>
# Cade Ekblad-Frank <cade@bluehost.com>
# Robert Lawrence   <robert@bluehost.com>
# Jacob Bushman     <jacob@bluehost.com>
# Ryan Chaudhry     <rchaudhry@bluehost.com>
# Erick Cantwell    <erick@bluehost.com>
#
# http://www.bluehost.com
# https://github.com/bluehost/rbld
#
##########################################################################
#
# This file is part of rbld
#
# Rbld is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307, USA.
#
##########################################################################

use strict;
use warnings;

use Getopt::Long;
use Data::Dumper;
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request::Common qw(GET);
use Proc::PID::File;
use File::Basename;
use File::Copy;
use YAML::Syck qw(LoadFile);

my $skip_sleep  = 0;
my $config_file = '/etc/rbld.d/pullrbllists.yml';
my $list        = {};
my $settings    = {};
my $pidpath;
my $home_dir;
my $listtype;
my $list_path;

# Get cli options
GetOptions (
    's|skip'        => \$skip_sleep,
    'c|config=s'    => \$config_file,
    'l|listpath=s'  => \$list_path,
    'd|homedir=s'   => \$home_dir,
    'r|pid=s'       => \$pidpath,
    't|type=s'      => \$listtype,
    'h|help'        => \&help,
) || &help;

# Read the configuration file
$settings = LoadFile($config_file);

# Merge configuration file with cli options
# cli options always win
if ($list_path) {
    $settings->{list_path} = $list_path;
}

if ($home_dir) {
    $settings->{home_dir} = $home_dir;
}

if ($pidpath) {
    $settings->{pid} = $pidpath;
}

# Validate that we have settings that we need
_validate_settings($settings);

# See if we can continue to run
my($pidfile, $piddir) = fileparse($settings->{pid});
exit 1 if Proc::PID::File->running(dir => $piddir, name => $pidfile);

# Delay requests to rbl list server to keep from overwhelming it
sleep int(rand(120)) unless ($skip_sleep);

# Loop through all of the lists and hopefully download them successfully
foreach my $ipurl (keys %{$settings->{lists}}) {
    if ($listtype) {
        unless ($settings->{lists}{$ipurl}{type} eq $listtype) {
            next;
        }
    }

    my $url        = $settings->{lists}{$ipurl}{url};
    my $local_file = $settings->{lists}{$ipurl}{local_file};
    my $savepath   = "$settings->{list_path}/$local_file";

    # See if we need to do basic authentication
    if ($settings->{lists}{$ipurl}{username}) {
        my $ua = LWP::UserAgent->new();
        my $req = GET "$url";
        $req->authorization_basic("$settings->{lists}{$ipurl}{username}", "$settings->{lists}{$ipurl}{password}");
        my $response = $ua->request($req);
        my $rc       = $response->code;
        if ($rc == 200) {
            my $body     = $response->content;
            open(TEMP, '>', "$savepath.temp");
            print TEMP $body;
            close(TEMP);
        } else {
            next;
        }
    } else {
        my $rc = getstore($url, "$savepath.temp");
        if ($rc != 200) {
            print STDERR "Could not download $url: Recieved $rc status\n";
            next;
        }
    }
    next if -z "$savepath.temp";
    move("$savepath.temp","$savepath") or ((print STDERR "Could not move file: $!\n") && (next));
}

# Help me
sub help {
  print <<EOF;

$0: Use this script to pull down preconfigured lists that can be used with rbld

usage:
        -s|--skip       Skip Random Sleep
        -c|--config     Path to configuration file (default is /etc/rbld.d/pullrbllists.yml)
        -l|--listpath   Final path to where lists should end up after being downloaded
        -d|--homedir    ENV HOME to use when looking for .wgetrc
        -r|--pid        Pidfile
        -t|--type       Only download lists of certain type
        -h|--help       Help
EOF
  exit;
}

# Method to handle configuration settings validation
sub _validate_settings {
    my $params = shift;

    my @neededVals = qw(list_path home_dir pid);
    for my $val (@neededVals) {
        if ($params->{$val}) {
            chomp($params->{$val});
            next;
        } else {
            print STDERR "$val not present, not safe to proceed\n";
            exit 1;
        }
    }

    # Make sure that we have lists
    unless ($params->{lists}) {
        print STDERR "No lists to download, not safe to proceed\n";
        exit 1;
    }
}
Seguro Celular
Home business sonyw300 6 de febrero de 2020
SEGURO PARA CUALQUIER MOMENTO
Evita cualquier situación con nuestro seguro para celular.

Contar con un seguro para celular te brinda una protección integral contra situaciones comunes como robo, accidentes y pérdida. No solo te ahorrará dinero en reparaciones o reemplazos, sino que también te proporcionará la tranquilidad de saber que estás respaldado en caso de cualquier eventualidad. Es una inversión inteligente para salvaguardar tu dispositivo, tus datos y tu tranquilidad.

De viaje
Protegido siempre ante cualquier imprevisto
Contratar ahora!
Robo
Asegura tu equipo ante un posible robo
Contratar ahora!
Accidentes
No pases un mal momento, protege tu dispositivo
Contratar ahora!
Previous slide
Next slide
¿Porqué seguro celular es para ti?
Nos comprometemos en brindarte la mejor protección para tu dispositivo
Cobertura mundial

Sea cual sea el problema estamos aquí para proteger tu inversión y brindarte la tranquilidad que necesitas.

Proceso de reclamación fácil y rápido

Sabemos que necesitas una solución rápida en caso de cualquier incidente.

Opciones personalizadas:

Ofrecemos opciones flexibles que se adaptan a tus requisitos individuales.

Atención al cliente excepcional

Estamos disponible para responder y brindarte asistencia personalizada en todo momento.

Tu tranquilidad está a
solo un clic de distancia

Protege tu dispositivo de cualquier imprevisto
TESTIMONIOS
¿Qué dicen nuestros
valiosos clientes?
"¡Increíble servicio de seguro para celular! Rápido, eficiente y confiable. Mi reclamo fue procesado sin problemas y recibí un reemplazo de mi teléfono en tiempo récord. ¡Gracias por brindar una excelente protección para mis dispositivos!"
male1085054890319
Herman Miller
"Me encanta la tranquilidad que me brinda su servicio de seguro para celular. Sé que mi dispositivo está protegido contra cualquier daño accidental o robo. Además, el proceso de reclamación es sencillo. Super recomendado!
female1021755931884
Sofia Millan
"Me ha salvado en más de una ocasión. El personal siempre está dispuesto a ayudar y resolver cualquier problema que surja. Gracias a su servicio, puedo disfrutar de mi teléfono sin preocupaciones.
male20131085934506012
Alexander Rodriguez