File: //opt/VRTSpbx/bin/cluster/online
#!/opt/VRTSvcs/bin/perl5
################################################################
# This script starts the PBX resource on a VCS cluster
# The outline:
# - Include the VxPSP library path to LD_LIBRARY_PATH env variable
# - Run the pbx_exchange as a background process.
# - Location and name of the PBX configuration file in ARGV[1].
# In absence of this argument the default location and name of the PBX configuration file is /opt/VRTS/ICS/VxPSP/bin/svc.conf
################################################################
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
#use strict;
my $command_string;
# Get arguments by calling subroutine get_arg_list()
my @args = get_arg_list();
my ($vcs_home, $pbx_home, $pbx_conf, $port_number, $is_windows, $separator) = @args;
my $vcs_home = $ENV{"VCS_HOME"} || "$vcs_home" ;
my $dir="$pbx_home$separator"."bin";
my $command_string="";
if($^O=~/win/i)
{
$ENV{'PATH'}="$pbx_home;$ENV{'PATH'}";
$command_string = "net start VRTSpbx";
}
else
{
$command_string = "/opt/VRTSpbx/bin/vxpbx_exchanged startincluster 2>/dev/null";
}
my $HALOG= "$vcs_home$separator"."bin$separator"."halog" ;
print "PBX::online called:";
print "PBX:online::Invoking pbx_exchange with command line: $command_string";
my $retcode = system ($command_string);
#Move to vcs home folder
$retcode >>8;
if ($retcode == 0)
{
print "PBX started successfully!\n";
exit(10);
}
else
{
print "Couldn't start PBX server";
exit(0);
}
###############################################################
# Get VCS Home, PBX Home, PBX Conf and port number arguments
# value from VCS.
###############################################################
sub get_arg_list {
my $arg;
my @argList =();
my $vcs_home = "/opt/VRTSvcs";
my $pbx_home = "/opt/VRTSpbx";
my $pbx_conf = "svc.conf";
my $port_number = 1556;
my $is_windows = 0;
my $separator = "/";
my $os = `ver`;
my $i;
if ($os =~ /Windows/) {
$is_windows = 1;
$separator = "\\";
}
# first argument is resource name
shift(@ARGV);
for ($i=0;$i<=@ARGV;$i++) {
if ( $ARGV[$i] =~ /pbx/i) {
# extract pbx homepath
$pbx_home = $ARGV[$i];
}
elsif ($ARGV[$i] =~ /cluster/i) {
# extract vcs homepath
$vcs_home = $ARGV[$i];
}
elsif ( $ARGV[$i] =~ /\w+/) {
$port_number = $ARGV[$i];
}
}
push (@argList, $vcs_home);
push (@argList, $pbx_home);
push (@argList, $pbx_conf);
push (@argList, $port_number);
push (@argList, $is_windows);
push (@argList, $separator);
return @argList;
}