#!/usr/bin/perl 

## @file baseVersionShow
# @brief show base applications info
# @details This command shows the name of the installed base 
#          configuration and list base applications names and versions.
# @author
# @date
# @version 1.00 - Initial version
# @note

=pod

=head1 NAME

B<baseVersionShow> - show base applications info

=head1 SYNOPSIS

B<baseVersionShow> [B<--help>]

=head1 DESCRIPTION

This command shows the name of the installed base configuration and list base applications names and versions.

=head1 OPTIONS

=over 4

=item B<--help>

Print this help message and exit.

=back

=head1 EXAMPLES

$ B<baseVersionShow>

  Product Release: 6.00.00.00
  Base Applications
    base                         6.00.00
    Snmp-Daemon-TrapLib          6.00.00
    sm                           6.00.00
    Jboss-Quantum                6.00.00

=head1 CAVEATS

B<baseVersionShow> can be run only under Nortel authorized accounts.

=head1 SEE ALSO

B<swVersionShow> and B<appVersionShow>

=cut

use lib "/opt/nortel/base/lib";

use strict;
use warnings;
use common_variables;
use common_functions;
use baselog;
use appinstall::show_app_info;
use base_semctl;

## @fn main()
# @brief Entry point.
# @details
# @param None
# @return $OK - on success
# @return $ERROR - on error
# @author
# @date 
sub main
{
   if (warning_if_not_nortel_grp())
   {
      return $ERROR;
   }

   if (defined $ARGV[0] and $ARGV[0] =~ /help$/)
   {
      print_pod_usage();
      return $OK;
   }
   
   my $semmngr = base_semctl::new("baseVersionShow");
   if (!defined($semmngr))
   {
      my $error_descr = $!;
      baselog($LOG_ERROR, "Cannot create semaphore manager object ($error_descr).");
      return $ERROR;
   } ## end if (!defined($semmngr)...
   if (!$semmngr->sem_take($SEM_PATCH, IPC_NOWAIT))
   {
      my $thisfile = get_basename($0);
      baselog($LOG_ERROR, "Cannot take semaphore.");
      baselog($LOG_ERROR, "$thisfile operation aborted.\n", $TRUE);
      undef $semmngr;
      return $ERROR;
   } ## end if (!$semmngr->sem_take...

   unless (showAppInfo("base"))
   {
      baselog($LOG_ERROR, "Cannot get information about base installed\n", $TRUE);
      undef $semmngr;
      return $ERROR;
   }

   if (!$semmngr->sem_give($SEM_PATCH))
   {
      baselog($LOG_ERROR, "Cannot release semaphore.");
      undef $semmngr;
      return $ERROR;
   } ## end if (!$semmngr->sem_give...
   undef $semmngr;

   return $OK;
} ## end sub main

exit(main());
