25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/mysql_backup/install.rb', line 25
def install
begin
if File.exist?(CONF_FILE)
puts "\n \#{CONF_FILE} already exists. Remove it and try again.\n \n WARN\n\n exit\n end\n\n user, password, host, dir = ask_for_options\n\n File.open(CONF_FILE, 'w') do |file|\n template = File.read(File.join(File.dirname(__FILE__), 'mysql_backup.yml.example'))\n template.gsub!('USER', user)\n template.gsub!('PASS', password)\n template.gsub!('HOST', host)\n template.gsub!('DIR', dir)\n \n file << template\n end\n\n FileUtils.chmod(750, CONF_FILE)\n\n puts <<-ERR\n\n\n Configuration file \#{CONF_FILE} written.\n\n You can now backup all databases by running the following command:\n\n $ mysql_backup\n\n ERR\n\n rescue Errno::EACCES => e\n puts <<-ERR\n\n You need to run this command with sudo or as root.\n\n ERR\n exit\n end\nend\n"
|