Server IP : 195.201.23.43 / Your IP : 13.58.187.29 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/bin/ |
Upload File : |
#!/usr/bin/env perl # server - control Webmin web-server use strict; use warnings; use 5.010; use File::Basename; use Getopt::Long; use Pod::Usage; use Term::ANSIColor qw(:constants); use lib (dirname(dirname($0))); use WebminCore; sub main { my %opt; GetOptions('help|h' => \$opt{'help'}, 'command|x=s' => \$opt{'command'}, 'config|c=s' => \$opt{'config'}); # If username passed as regular param my $cmd = scalar(@ARGV) == 1 && $ARGV[0]; $cmd = $opt{'command'} if ($opt{'command'}); if ($cmd !~ /^(status|start|stop|restart|reload|force-restart|kill)$/) { $cmd = undef; } # Show usage pod2usage(0) if ($opt{'help'} || !$cmd); # Assign defaults $opt{'config'} ||= "/etc/webmin"; $opt{'cmd'} = $cmd; # Catch kill signal my $sigkill = sub { system("stty echo"); print "\n^C"; print "\n"; exit 1; }; $SIG{INT} = \&$sigkill; # Run change password command run(\%opt); return 0; } exit main(\@ARGV) if !caller(0); sub run { my ($o) = @_; my $conf_check = sub { my ($configs) = @_; foreach my $config (@{$configs}) { if (!-r $config) { say BRIGHT_RED, "Error: ", RESET, "Failed to read Webmin essential config file: ", BRIGHT_YELLOW, $config, RESET, " doesn't exist"; exit 1; } } }; root($o->{'config'}, \&$conf_check); my $service = ($o->{'config'} =~ /usermin/ ? 'usermin' : 'webmin'); my $systemctlcmd = `which systemctl`; $systemctlcmd =~ s/\s+$//; if ($o->{'cmd'} =~ /^(start|stop|restart|reload)$/) { my $rs = system("$o->{'config'}/$o->{'cmd'} $service"); exit $rs; } if ($o->{'cmd'} =~ /^(kill)$/) { my $rs; if (-x $systemctlcmd) { $rs = system("$systemctlcmd stop $service"); $rs = system("$systemctlcmd kill -s SIGTERM $service"); } $rs = system("$o->{'config'}/.stop-init --kill >/dev/null 2>&1 $service"); exit $rs; } if ($o->{'cmd'} =~ /^(force-restart)$/) { my $rs = system("$o->{'config'}/restart-by-force-kill $service"); exit $rs; } if ($o->{'cmd'} =~ /^(status)$/) { my $rs; if (-x $systemctlcmd) { $rs = system("$systemctlcmd status $service"); } else { $rs = system("service $service status"); } exit $rs; } exit 0; } sub root { my ($config, $conf_check) = @_; my $mconf = "$config/miniserv.conf"; $conf_check->([$mconf]); open(my $CONF, "<", $mconf); my $root; while (<$CONF>) { if (/^root=(.*)/) { $root = $1; } } close($CONF); # Does the Webmin root exist? if ($root) { die BRIGHT_RED, "Error: ", BRIGHT_YELLOW, $root, RESET, " is not a directory\n" unless (-d $root); } else { # Try to guess where Webmin lives, since config file didn't know. die BRIGHT_RED, "Error: ", RESET, "Unable to determine Webmin installation directory\n"; } return $root; } 1; =pod =head1 NAME server =head1 DESCRIPTION This program allows you to control Webmin web-server =head1 SYNOPSIS webmin server [command] webmin [command] =head1 OPTIONS =over =item --help, -h Print this usage summary and exit. Examples of usage: - webmin server status - webmin server restart - webmin server --config /usr/local/etc/webmin --command start - webmin status - webmin restart =item --config, -c Specify the full path to the Webmin configuration directory. Defaults to C</etc/webmin> =item --command, -x Available commands: - status - start - stop - restart - force-restart - reload - kill =back =head1 LICENSE AND COPYRIGHT Copyright 2018 Jamie Cameron <jcameron@webmin.com> Joe Cooper <joe@virtualmin.com> Ilia Rostovtsev <ilia@virtualmin.com>Private