-
-
Save anabelle/8baab5e0c24d80ce078bc9de3fa9a494 to your computer and use it in GitHub Desktop.
Pause or resume all your CloudFlare sites at once. Useful if CloudFlare is misbehaving.
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/env ruby | |
require 'cloudflare' | |
module CloudFlare | |
class Connection | |
public :send_req | |
end | |
end | |
if ARGV[0] != 'resume' && ARGV[0] != 'pause' | |
STDERR.puts "Pass 'pause' or 'resume as argument." | |
exit | |
end | |
action = ARGV[0] == 'pause' ? :zone_deactivate : :zone_reactivate | |
cloudflares = { | |
"[email protected]" => "APIKEY123456789", | |
"[email protected]" => "APIKEY123456789" | |
} | |
cloudflares.each do |email, key| | |
api = CloudFlare::connection(key, email) | |
api.zone_load_multi['response']['zones']['objs'].each do |zone| | |
print zone['zone_name'] + ': ' | |
begin | |
result = api.send_req({ | |
a: action, | |
z: zone['zone_name'] | |
}) | |
puts "complete" | |
rescue Exception => e | |
puts e.to_s.gsub /<\/?strong>/, '' | |
end | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment