@@ -9,7 +9,12 @@ class RedisRunner
99 end
1010
1111 def self . redisconfdir
12- '/etc/redis.conf'
12+ server_dir = File . dirname ( `which redis-server` )
13+ conf_file = "#{ server_dir } /../etc/redis.conf"
14+ unless File . exists? conf_file
15+ conf_file = "#{ server_dir } /../../etc/redis.conf"
16+ end
17+ conf_file
1318 end
1419
1520 def self . dtach_socket
@@ -65,17 +70,19 @@ namespace :redis do
6570 RedisRunner . attach
6671 end
6772
68- desc 'Install the lastest verison of Redis from Github (requires git, duh)'
73+ desc 'Install the latest verison of Redis from Github (requires git, duh)'
6974 task :install => [ :about , :download , :make ] do
75+ ENV [ 'PREFIX' ] and bin_dir = "#{ ENV [ 'PREFIX' ] } /bin" or bin_dir = '/usr/bin'
7076 %w( redis-benchmark redis-cli redis-server ) . each do |bin |
71- sh "sudo cp /tmp/redis/#{ bin } /usr/bin/ "
77+ sh "cp /tmp/redis/#{ bin } #{ bin_dir } "
7278 end
7379
74- puts "Installed redis-benchmark, redis-cli and redis-server to /usr/bin/ "
80+ puts "Installed redis-benchmark, redis-cli and redis-server to #{ bin_dir } "
7581
76- unless File . exists? ( '/etc/redis.conf' )
77- sh 'sudo cp /tmp/redis/redis.conf /etc/'
78- puts "Installed redis.conf to /etc/ \n You should look at this file!"
82+ ENV [ 'PREFIX' ] and conf_dir = "#{ ENV [ 'PREFIX' ] } /etc" or conf_dir = '/etc'
83+ unless File . exists? ( "#{ conf_dir } " )
84+ sh "cp /tmp/redis/redis.conf #{ conf_dir } "
85+ puts "Installed redis.conf to #{ conf_dir } \n You should look at this file!"
7986 end
8087 end
8188
@@ -115,11 +122,12 @@ namespace :dtach do
115122 system ( 'tar xzf dtach-0.8.tar.gz' )
116123 end
117124
125+ ENV [ 'PREFIX' ] and bin_dir = "#{ ENV [ 'PREFIX' ] } /bin" or bin_dir = "/usr/bin"
118126 Dir . chdir ( '/tmp/dtach-0.8/' )
119127 sh 'cd /tmp/dtach-0.8/ && ./configure && make'
120- sh 'sudo cp /tmp/dtach-0.8/dtach /usr/bin/'
128+ sh " cp /tmp/dtach-0.8/dtach #{ bin_dir } "
121129
122- puts ' Dtach successfully installed to /usr/bin.'
130+ puts " Dtach successfully installed to #{ bin_dir } "
123131 end
124132end
125133
0 commit comments