Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Pause or resume all your CloudFlare sites at once. Useful if CloudFlare is misbehaving.
#!/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 = {
"email1@example.com" => "APIKEY123456789",
"email2@example.com" => "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
You can’t perform that action at this time.