Private
Server IP : 195.201.23.43  /  Your IP : 3.128.190.205
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/webmin/virtual-server/list-commands.pl
#!/usr/bin/perl

=head1 list-commands.pl

Lists API scripts available

This command lists all API commands available, categorized by type and
with a brief summary of each. It is used to produce the output from the
Virtualmin C<--help> command. By default the output is in a human-readable format,
but you can switch to a more parsable format with the C<--multiline> flag.

=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-features.pl";
	require './virtual-server-lib.pl';
	$< == 0 || die "list-commands.pl must be run as root";
	}

# Parse command-line args
my $short = 1;
while(@ARGV > 0) {
	local $a = shift(@ARGV);
	if ($a eq "--short") {
		$short = 1;
		}
	elsif ($a eq "--long") {
		$short = 0;
		}
	elsif ($a eq "--multiline") {
		$multiline = 1;
		}
	elsif ($a eq "--name-only") {
		$nameonly = 1;
		}
	elsif ($a eq "--help") {
		&usage();
		}
	else {
		&usage("Unknown parameter $a");
		}
	}

# Work out the max command length, for formatting
my $maxlen = 0;
foreach my $c (&list_api_categories()) {
	my ($cname, @cglobs) = @$c;
	foreach my $cmd (map { glob($_) } @cglobs) {
		my $scmd = $cmd;
		$scmd =~ s/\.pl$// if ($short);
		$maxlen = length($scmd) if (length($scmd) > $maxlen);
		}
	}

# Go through the categories
my @skips = &list_api_skip_scripts();
my %cdescs = &list_api_category_descs();
my %done;
my $fmt = "\%-${maxlen}.${maxlen}s \%s\n";
foreach my $c (&list_api_categories()) {
	my ($cname, @cglobs) = @$c;
	@cglobs = map { my $g = $_; ($g, "pro/$g", map { "$root_directory/$_/$g" } @plugins) } @cglobs;
	my @cmds = map { glob($_) } @cglobs;
	@cmds = grep { &indexof($_, @skips) < 0 && !$done{$_} } @cmds;

	# Print a line for each command
	my $donehead = 0;
	foreach my $cmd (@cmds) {
		my $src = &read_file_contents($cmd);
		next if ($src !~ /=head1\s+(.*)\n\n(.*)\n/);
		my $desc = $2;
		my $scmd = $cmd;
		$scmd =~ s/^.*\///;
		$scmd =~ s/\.pl$// if ($short);
		if ($multiline) {
			# Show a block for the command
			print $scmd,"\n";
			print "    Description: $desc\n";
			print "    Category: $cname\n";
			}
		elsif ($nameonly) {
			# Just command name
			print $scmd,"\n";
			}
		else {
			# Just one line, maybe wrapped
			my $wrap;
			while (length($desc) + $maxlen > 79) {
				# Line is too long - wrap it by taking off
				# a word
				$desc =~ s/\s(\S+)$//;
				$wrap = $1." ".$wrap;
				}
			$desc =~ s/\.\s*$//;
			$wrap =~ s/\.\s*$//;
			if (!$donehead) {
				# Category header
				print $cname,"\n";
				print ("-" x length($cname));
				print "\n";
				$donehead = 1;
				}
			printf $fmt, $scmd, $desc;
			printf $fmt, "", $wrap if ($wrap);
			}
		$done{$cmd}++;
		}
	if ($donehead && !$multiline && !$nameonly) {
		print "\n";
		}
	}

sub usage
{
print "$_[0]\n\n" if ($_[0]);
print "Lists available command-line API scripts.\n";
print "\n";
print "virtualmin list-commands [--short]\n";
print "                         [--multiline | --name-only]\n";
exit(1);
}

Private