Created
June 19, 2019 04:28
-
-
Save briandfoy/8b6bf162a5eea7f11e1016273ecdbb14 to your computer and use it in GitHub Desktop.
A Mojo script to pause cloudflare sites
This file contains 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/perl | |
use v5.10; | |
use strict; | |
use Mojo::UserAgent; | |
my $ua = Mojo::UserAgent->new; | |
# Translate the first command-line argument to the Mojo::JSON method to use | |
my $pause = $ARGV[0] ? 'true' : 'false'; | |
# Go through all of your domains and copy their Zone IDs into this hash. | |
# The key doesn't really matter. | |
my %api_keys = ( | |
'some_site' => '..zone_id..', | |
... | |
); | |
foreach my $site ( sort keys %api_keys ) { | |
my $url = 'https://api.cloudflare.com/client/v4/zones/' . $api_keys{$site}; | |
my $tx = $ua->patch( $url => { | |
'X-Auth-Email' => $ENV{CLOUDFLARE_EMAIL}, | |
'X-Auth-Key' => $ENV{CLOUDFLARE_AUTH_KEY}, | |
'Content-Type' => 'application/json' | |
}, | |
json => { paused => Mojo::JSON->$pause() } | |
); | |
say $tx->result->code, ' ', $site; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment