Skip to content
Browse files

Merge pull request #3 from carlosms/fork

oneconf: ask for sudo password in system-wide installations
  • Loading branch information...
2 parents d80f7f2 + 0e72a65 commit 9ecabbf6701699f416e6ed208ff7f59be442f292 @jmelis committed
Showing with 9 additions and 0 deletions.
  1. +9 −0 oneconf
View
9 oneconf
@@ -4,6 +4,13 @@
require "fileutils"
+# Taken from: http://jimeh.me/blog/2010/02/22/built-in-sudo-for-ruby-command-line-tools/
+def sudome
+ if ENV["USER"] != "root"
+ exec("sudo #{ENV['_']} #{ARGV.join(' ')}")
+ end
+end
+
class String
def uncomment(string)
self.gsub!(string) do |m|
@@ -16,6 +23,8 @@ if ONE_LOCATION = ENV['ONE_LOCATION']
oned_conf = ONE_LOCATION + '/etc/oned.conf'
sched_conf = ONE_LOCATION + '/etc/sched.conf'
else
+ sudome()
+
oned_conf = '/etc/one/oned.conf'
sched_conf = '/etc/one/sched.conf'
end

0 comments on commit 9ecabbf

Please sign in to comment.
Something went wrong with that request. Please try again.