File: //opt/VRTSpbx/bin/cluster/offline
#!/opt/VRTSvcs/bin/perl5
#####################################################################
# This script stops an PBX resource on a VCS cluster
# The outline:
# - check if pbx_exchange server is running
# - If yes, get it's pid. To stop that process use "kill pid"
#####################################################################
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
# Get arguments by calling subroutine get_arg_list()
my $arg1;
my @args = get_arg_list();
my ($vcs_home, $pbx_home, $pbx_conf, $port_number, $is_windows, $separator) = @args;
$arg1=$vcs_home;
my $vcs_home = $ENV{"VCS_HOME"} || "/opt/VRTSvcs" ;
my $dir="$pbx_home$separator"."bin";
my $command_string="";
my $retcode;
print "PBX::offline called \n";
if($^O=~/win/i)
{
$ENV{'PATH'}="$pbx_home;$ENV{'PATH'}";
$command_string = "net stop VRTSpbx";
$retcode = system($command_string);
}
else
{
`/opt/VRTSpbx/bin/vxpbx_exchanged stopincluster`;
$retcode=$?;
}
if ($retcode == 0)
{
print "PBX instance is killed \n";
exit (10);
}
else
{
print "No any PBX instance is running";
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`;
# first argument is resource name
shift(@ARGV);
if ($os =~ /Windows/) {
$is_windows = 1;
$separator = "\\";
}
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;
}