Last active
August 4, 2016 07:53
-
-
Save etipton/8dead5a3397f6bd7edb2 to your computer and use it in GitHub Desktop.
Specify settings in mysql launchctl plist file
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
#!/usr/bin/env ruby | |
plist_file = File.expand_path('~/Library/LaunchAgents/homebrew.mxcl.mysql.plist') | |
File.open(plist_file, 'r+') do |f| | |
contents = f.read | |
args_end = ' </array>' # this is kinda brittle, but whatever | |
charset_opt = ' <string>--character-set-server=latin1</string>' | |
collate_opt = ' <string>--collation-server=latin1_swedish_ci</string>' | |
sql_mode_opt = ' <string>--sql-mode=NO_ENGINE_SUBSTITUTION</string>' | |
contents.sub!(args_end, [charset_opt, args_end].join("\n")) unless contents.include?('character-set-server') | |
contents.sub!(args_end, [collate_opt, args_end].join("\n")) unless contents.include?('collation-server') | |
contents.sub!(args_end, [sql_mode_opt, args_end].join("\n")) unless contents.include?('sql-mode') | |
f.rewind | |
f.write(contents) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment