#!/usr/local/bin/perl # index.cgi # Display a list of services, built from svcs command $unsafe_index_cgi = 1; require './smf-lib.pl'; &ReadParse(); &ui_print_header(undef, $text{'index_title'}, "", "help", 1, 1, 0, &help_search_link("smf", "man", "doc", "howto")); # deal with application of state changes first. this way # fmri list will show changes... if (defined($in{'change_state'})) { $cmd = "$in{'change_state'}"; # get update fmri list @update_fmris = split(/\0/, $in{'applyto'}); &svc_state_cmd("$cmd", \@update_fmris); } # service type if (defined($in{'type'})) { $svc_type = $in{'type'}; } else { $svc_type = "All"; } if (defined($in{'include_disabled'})) { $include_disabled = $in{'include_disabled'}; } else { $include_disabled = $default_include_disabled; } if ($include_disabled == 1) { $checked_include_disabled = "checked"; } else { $checked_include_disabled = ""; } # opts for svcs listing $opts = "$default_svc_options"; if (defined($in{'opts'})) { @extraopts = split(/\0/, $in{'opts'}); foreach $extraopt (@extraopts) { $opts = "$opts,$extraopt"; } } $sortopt = "$default_sortopt"; if (defined($in{'sortopt'})) { $sortopt = $in{'sortopt'}; } print "

"; &text_and_whats_this("index_detail"); print "

\n"; # Checkboxes for view update print "
\n"; print "

\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print ""; print "
$text{'index_svc_type'}"; @typelist = sort keys %svc_types; &print_selection("type", "$svc_type", \@typelist); print "
$text{'index_extraopts'}"; @additional_option_names = sort keys %svc_options; foreach $o (@additional_option_names) { if ($default_svc_options =~ /$o/) { next; } $checked = "unchecked"; if ($opts=~ /$o/) { $checked = "checked"; $opts_str="$opts_str\&opts=$o"; } print "$svc_options{$o}"; print " "; } print "
$text{'index_include_disabled'}"; print ""; print "
 \n"; print "

\n"; print "
\n"; print "\n"; print "\n"; print "
\n"; # multiple select buttons(enable, disable, maintenance, degraded, clear, delete) print "
\n"; print ""; print " "; print "\n"; print "
$text{'index_apply'}: "; &print_state_buttons(); # add delete/create new buttons in addition to statechange buttons print " \n"; print "
\n"; @svcs_info = &svcs_listing("$svc_types{$svc_type}", "$sortopt"); @optlist = split(/,/, $opts); print "\n"; print "\n"; foreach $o (@optlist) { # clicking should reverse sort option if we`re already sorting by # this option... if ($sortopt =~/-S$o/) { $new_sortopt = "-s$o"; } elsif ($sortopt =~/-s$o/) { $new_sortopt = "-S$o"; } else { $new_sortopt = "-s$o"; } print "\n"; } print "\n"; for $svc_info (@svcs_info) { # if we are displaying enabled only, skip disabled if (($include_disabled != 1) && ($svc_info->{'STATE'} eq "disabled")) { next; } print ""; $fmri = $svc_info->{'FMRI'}; if ("$fmri" =~ /^lrc:\//) { print "\n"; } else { print "\n"; } foreach $opt (@optlist) { $field = $svc_info->{$opt}; if ($opt eq "FMRI") { $field =~ /$svc_types{$svc_type}(.*)/; $svc = $1; # make sure legacy svcs are unclickable! if ($field =~ /svc:\//) { print "\n"; } else { print "\n"; } } elsif ($opt eq "STATE") { print "\n"; } else { print "" } } print "\n"; } print "
$text{'index_select'}"; print "$text{'index_sort_by'}: "; print ""; print "$svc_options{$o}
-{'FMRI'}\">"; print "$svc"; print "$svc"; print "{$opt}}>$svc_info->{$opt}\n"; print "$field
\n"; &print_cmds_run(); &ui_print_footer("/", $text{'index'});