Skip to content

Instantly share code, notes, and snippets.

@colinbm
Created September 9, 2014 09:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save colinbm/d55444341005899b8a7b to your computer and use it in GitHub Desktop.
Save colinbm/d55444341005899b8a7b to your computer and use it in GitHub Desktop.
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