Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

oneconf: ask for sudo password in system-wide installations

  • Loading branch information...
commit 0e72a65df042aec5755063bf66b86ba82d570205 1 parent d80f7f2
Carlos Martín authored

Showing 1 changed file with 9 additions and 0 deletions. Show diff stats Hide diff stats

  1. +9 0 oneconf
9 oneconf
@@ -4,6 +4,13 @@
4 4
5 5 require "fileutils"
6 6
  7 +# Taken from: http://jimeh.me/blog/2010/02/22/built-in-sudo-for-ruby-command-line-tools/
  8 +def sudome
  9 + if ENV["USER"] != "root"
  10 + exec("sudo #{ENV['_']} #{ARGV.join(' ')}")
  11 + end
  12 +end
  13 +
7 14 class String
8 15 def uncomment(string)
9 16 self.gsub!(string) do |m|
@@ -16,6 +23,8 @@ if ONE_LOCATION = ENV['ONE_LOCATION']
16 23 oned_conf = ONE_LOCATION + '/etc/oned.conf'
17 24 sched_conf = ONE_LOCATION + '/etc/sched.conf'
18 25 else
  26 + sudome()
  27 +
19 28 oned_conf = '/etc/one/oned.conf'
20 29 sched_conf = '/etc/one/sched.conf'
21 30 end

0 comments on commit 0e72a65

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