Last active
August 29, 2015 14:24
-
-
Save justinleveck/ec7e1ce155830401d34f to your computer and use it in GitHub Desktop.
Script to set CS-Cart config.local.php values using environment variable values
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 | |
file_names = ['path/to/config.local.php'] | |
config_values = [ | |
'CS_CART_DB_HOST', | |
'CS_CART_DB_NAME', | |
'CS_CART_DB_USER', | |
'CS_CART_DB_PASSWORD', | |
'CS_CART_HTTP_HOST', | |
'CS_CART_HTTP_PATH', | |
'CS_CART_HTTPS_HOST', | |
'CS_CART_HTTPS_PATH', | |
'CS_CART_CUSTOMER_INDEX', | |
'CS_CART_ADMIN_INDEX' | |
] | |
file_names.each do |file_name| | |
text = File.read(file_name) | |
config_values.each do |config_value| | |
search_regexp = /%#{Regexp.quote(config_value)}%/ | |
next if ENV[config_value].nil? | |
p ENV[config_value] | |
text = text.gsub(search_regexp, ENV[config_value]) | |
end | |
# To write changes to the file, use: | |
File.open(file_name, "w") {|file| file.puts text } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment