Changeset 324

Show
Ignore:
Timestamp:
11/30/06 15:48:13 (6 years ago)
Author:
max
Message:

Add --pending, expand process_setup_options()

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/shepherd

    r323 r324  
    166166&open_logfile unless ($opt->{nolog}); 
    167167 
    168 if ($opt->{status}) 
    169 { 
    170     &status; 
    171     exit; 
    172 } 
    173  
    174 if ($opt->{'show-config'}) 
    175 { 
    176     &show_config; 
    177     exit; 
    178 } 
    179  
    180 if ($opt->{'show-channels'}) 
    181 { 
    182     &show_channels; 
    183     exit; 
    184 } 
    185  
    186168&process_setup_commands; 
    187169 
     
    614596} 
    615597 
     598sub pending 
     599{ 
     600    return unless ($components_pending_install); 
     601 
     602    my @pending; 
     603    foreach (keys %$components_pending_install) 
     604    { 
     605        push @pending, $_; 
     606    } 
     607    unless (@pending) 
     608    { 
     609        &log("\nNo components are pending install.\n"); 
     610        return; 
     611    } 
     612    &log("\nThe following components are pending install: " . 
     613        join(', ', @pending) . ".\n\n" . 
     614        "You may have missing Perl dependencies. To see errors,\n". 
     615        "run: $progname --update or $progname --check\n"); 
     616 
     617    # Exit with non-zero status so this sub can be used to 
     618    # notify an external program (to email the owner, perhaps) 
     619    # about pending installs. 
     620    exit 1; 
     621} 
    616622 
    617623# ----------------------------------------- 
     
    10891095                        output=s 
    10901096                        randomize 
     1097                        pending 
    10911098                     )); 
    10921099  $debug = $opt->{debug}; 
     
    10961103 
    10971104 
     1105# Here we can specify which command-line options should call 
     1106# subroutines of the same name. The field following each sub 
     1107# name is a string that can contain a key for what action should 
     1108# be performed following the sub: 
     1109#   W : write config file 
     1110#   S : print --status output 
     1111# Shepherd will exit if at least one of these routines was 
     1112# called. 
    10981113sub process_setup_commands 
    10991114{ 
    1100     my @opts = qw( enable disable setorder check \ 
    1101                    setpreftitle clearpreftitle setmirror reset ); 
    1102  
    1103     my $run = 0; 
    1104     foreach (@opts) 
     1115    my %routines = (    enable => 'WS', 
     1116                        disable => 'WS', 
     1117                        setorder => 'WS', 
     1118                        check => 'WS', 
     1119                        setpreftitle => 'W', 
     1120                        clearpreftitle => 'W', 
     1121                        setmirror => 'W', 
     1122                        'reset' => 'W', 
     1123                        status => '', 
     1124                        'show-config' => '', 
     1125                        'show-channels' => '', 
     1126                        'pending' => '' 
     1127                    ); 
     1128 
     1129    my @run; 
     1130    foreach (keys %routines) 
    11051131    { 
    11061132        if ($opt->{$_}) 
    11071133        { 
    1108             $run = 1; 
    1109             &$_($opt->{$_}); 
    1110         } 
    1111     } 
    1112     return unless ($run); 
    1113     write_config_file(); 
    1114     status(); 
     1134            push @run, $_; 
     1135            my $sub = $_; 
     1136            $sub =~ s/-/_/g; 
     1137            &$sub($opt->{$_}); 
     1138        } 
     1139    } 
     1140    return unless (@run); 
     1141    foreach (@run) 
     1142    { 
     1143        &write_config_file if ($routines{$_} =~ /W/); 
     1144        &status if ($routines{$_} =~ /S/); 
     1145    } 
    11151146    exit; 
    11161147} 
     
    14971528 
    14981529    --check               Check status of all components, configure if necessary 
     1530    --pending             List pending installs, if any 
    14991531 
    15001532    --debug               Print lots of debugging messages