2010-11-10 15:08:57 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
require File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib', 'noprocast')
|
|
|
|
|
|
|
|
begin
|
|
|
|
case ARGV.first
|
2010-11-10 15:36:12 +00:00
|
|
|
when 'on', 'reload'
|
2010-11-10 15:08:57 +00:00
|
|
|
Noprocast.activate!
|
|
|
|
when 'off'
|
|
|
|
Noprocast.deactivate!
|
|
|
|
when 'status'
|
|
|
|
puts Noprocast.status_message
|
|
|
|
when 'edit'
|
2010-11-10 15:47:33 +00:00
|
|
|
if File.exists?(Noprocast.deny_file_path) && (Process.uid != File.stat(Noprocast.deny_file_path).uid)
|
2010-11-10 15:08:57 +00:00
|
|
|
puts "Can't edit this file as it belongs to another user (hint: don't use sudo)"
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
Noprocast.edit!
|
2010-11-10 15:36:12 +00:00
|
|
|
if Noprocast.active?
|
|
|
|
puts "Saved. Now: noprocast reload"
|
|
|
|
else
|
|
|
|
puts "Saved. Now: noprocast on"
|
|
|
|
end
|
2010-11-10 15:08:57 +00:00
|
|
|
when 'help', '-h', '--help', nil
|
|
|
|
puts "Usage: [sudo] noprocast [on|off|status|edit]"
|
|
|
|
end
|
|
|
|
rescue Errno::EACCES
|
|
|
|
puts "Permission denied: try sudo noprocast"
|
|
|
|
end
|