#!/bin/bash ################################################################################ # # # Author: Sean E. Russell # # Version: 1.0 # # Date: Jun 26, 2002 # # Adaptation: Mike Frysinger [SpanKY] # # Original code was in Ruby ... recoded into bash (at syntax level) # # # # This application displays information about the RC system used by Gentoo. # # In particular, it displays a tree-like format of a run level, showing # # all of the services that are installed at that level, and what each # # service's status is (running, stopped, etc.) # # # # -a can be used to display all runlevels # # -d can be used to display service dependancies # # -u will display all unassigned services # # -n will turn off colors # # -h will display help # # is used to choose the run level for which information is # # displayed # # # # By default, rc-status only displays information about the current # # runlevel; services installed and services running. # # # ################################################################################ #require 'getoptlong' # For parsing options COLS=( `stty size` ) ; let "COLS = ${COLS[1]} - 14" #COLS=`stty size`.split[1].to_i - 14 # Get the number of columns of the term #filter = proc {|f| f =~ /^\..*/} # A dirlist filter for .* files ################################################################################ # # # Parse command line options # # # ################################################################################ #opts = GetoptLong.new( [ '--all', '-a', GetoptLong::NO_ARGUMENT], # [ '--unused', '-u', GetoptLong::NO_ARGUMENT], # [ '--help', '-h', GetoptLong::NO_ARGUMENT], # [ '--nocolors', '-n', GetoptLong::NO_ARGUMENT], # [ '--list', '-l', GetoptLong::NO_ARGUMENT]) do_opt() { case $1 in "--all" | "-a" ) ALL=true;; "--depend" ) DEPEND=true;; "--unused" | "-u" ) ALL=true UNUSED=true;; "--nocolors" | "-n" ) NOCOLORS=true;; "--list" | "-l" ) for runlvl in `ls /etc/runlevels` ; do echo $runlvl done exit 0;; "--help" | "-h" | -* ) echo "USAGE: $0 [--nocolors] [--all | --list | --unused | ]" echo " --all -a Show services at all run levels" echo " --list -l Show list of run levels" echo " --unused -u Show services not assigned to any run level" echo " --nocolors -n Turn off colors" echo " Show services assigned to " echo "If no arguments are supplied, shows services for current run level." exit 0;; * ) runlevel=$1;; esac } for opt in $* ; do do_opt ${opt} [ -n "$2" ] && shift done ################################################################################ # # # Find the current runlever being queried. This is either something supplied # # on the command line, or pulled from softlevel # # # ################################################################################ [ -z "${runlevel}" ] && runlevel=`