Server IP : 195.201.23.43 / Your IP : 18.222.54.32 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/virtual-server/ |
Upload File : |
#!/usr/bin/perl =head1 list-shared-addresses.pl Lists shared IP addresses for virtual servers This command outputs a list of shared IP addresses that can be used by new or existing virtual servers. Output is in table format by default, but you can switch to a more detailed and easily parsed list with the C<--multiline> flag. Or to just get a list of addresses, use the C<--name-only> parameter. =cut package virtual_server; if (!$module_name) { $main::no_acl_check++; $ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin"; $ENV{'WEBMIN_VAR'} ||= "/var/webmin"; if ($0 =~ /^(.*)\/[^\/]+$/) { chdir($pwd = $1); } else { chop($pwd = `pwd`); } $0 = "$pwd/list-shared-addresses.pl"; require './virtual-server-lib.pl'; $< == 0 || die "list-shared-addresses.pl must be run as root"; } # Parse command-line args $owner = 1; while(@ARGV > 0) { local $a = shift(@ARGV); if ($a eq "--multiline") { $multi = 1; } elsif ($a eq "--name-only") { $nameonly = 1; } elsif ($a eq "--help") { &usage(); } else { &usage("Unknown parameter $a"); } } # Get the IPs push(@ips, { 'ip' => &get_default_ip(), 'type' => 'default' }); if (defined(&list_resellers)) { foreach $r (&list_resellers()) { if ($r->{'acl'}->{'defip'}) { push(@ips, { 'ip' => $r->{'acl'}->{'defip'}, 'type' => 'reseller', 'reseller' => $r->{'name'} }); } } } foreach $ip (&list_shared_ips()) { push(@ips, { 'ip' => $ip, 'type' => 'shared' }); } if ($multi) { # Several lines each foreach $ip (@ips) { print "$ip->{'ip'}\n"; print " Type: $ip->{'type'}\n"; if ($ip->{'reseller'}) { print " Reseller: $ip->{'reseller'}\n" } @doms = &get_domain_by("ip", $ip->{'ip'}); foreach $d (@doms) { print " Virtual server: $d->{'dom'}\n"; } } } elsif ($nameonly) { # Just addresses foreach $ip (@ips) { print $ip->{'ip'},"\n"; } } else { # One per line $fmt = "%-20.20s %-20.20s %-30.30s\n"; printf $fmt, "Address", "Type", "Reseller name"; printf $fmt, ("-" x 20), ("-" x 20), ("-" x 30); foreach $ip (@ips) { printf $fmt, $ip->{'ip'}, $ip->{'type'} eq 'default' ? 'System default' : $ip->{'type'} eq 'reseller' ? 'Reseller' : $ip->{'type'} eq 'shared' ? 'Shared address' : $ip->{'type'}, $ip->{'reseller'}; } } sub usage { print "$_[0]\n\n" if ($_[0]); print "Lists the available shared IP addresses for new virtual servers.\n"; print "\n"; print "virtualmin list-shared-addresses [--multiline | --name-only]\n"; exit(1); }Private