X-Git-Url: http://git.steven-mcdonald.id.au/?p=aids.git;a=blobdiff_plain;f=bin%2Faids;h=34444b36de643ad17ad8d5fb40aded053da551ba;hp=7b3fa5022aff8741be234aa8824f8c0881121479;hb=22a04aa1f77d43c9529bf7f95602e54d431888fa;hpb=16da2ea2a6c6d9b70ea3b3424d80b0f8a68b6cec diff --git a/bin/aids b/bin/aids index 7b3fa50..34444b3 100755 --- a/bin/aids +++ b/bin/aids @@ -1,5 +1,13 @@ #!/usr/bin/ruby1.8 +# This program is free software. It comes without any warranty, to the +# extent permitted by applicable law. You can redistribute it and/or +# modify it under the terms of the Do What The Fuck You Want To Public +# License, Version 2, as published by Sam Hocevar. See the file COPYING +# in the root of this program's source distribution for details, or: +# +# http://sam.zoy.org/wtfpl/COPYING + require 'lib/aids' def main(argv) @@ -13,17 +21,36 @@ def main(argv) svc.disable! when 'list' if svc - puts svc.status + display_status(svc) else - AIDS.get_all_services.sort_by{|s|s.name}.each do |s| - puts "#{s.name}: #{s.status}" - end + AIDS.get_all_services.sort_by{|s|s.name}.each{|s|display_status(s)} end else usage end end +def display_status(svc) + print "#{svc.name[0..14]}#{' ' * (16 - svc.name[0..14].length)}" + status = svc.status + prettystatus = nil + AIDS::RUNLEVEL_ALL.each do |r| + print "\t" if prettystatus + case status[r] + when :start + prettystatus = 'on' + when :stop + prettystatus = 'off' + when :none + prettystatus = 'none' + else + next + end + print "#{r}:#{prettystatus}" + end + puts +end + def usage $stderr.puts <<-EOF AIDS - Assistant for Initialisation of Debian Services