noprocrast/bin/noprocast

30 lines
765 B
Plaintext
Raw Permalink Normal View History

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
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!
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