Created
March 27, 2015 15:53
-
-
Save EntropyWorks/045b19b0d2688d05adbe to your computer and use it in GitHub Desktop.
trying to make this only run only if a file does not exisit
This file contains hidden or 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
if File.exists?('user-data.master') && ARGV[0].eql?('up') || File.exists?('user-data.master.yml') | |
require 'open-uri' | |
token = open('https://discovery.etcd.io/new').read | |
file_names = ['user-data.master'] | |
file_names.each do |file_name| | |
text = File.read(file_name) | |
new_contents = text.gsub(/AUTO_REPLACED_WITH_DISCOVERY_URL/, token ) | |
# To merely print the contents of the file, use: | |
puts token | |
# To write changes to the file, use: | |
File.open(file_name + '.yaml', "w") {|file| file.puts new_contents } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment