Added server status functions

master
Marisa Giancarla 2022-07-21 11:32:10 +08:00
parent df600dd9c4
commit 788e0db55d
1 changed files with 82 additions and 20 deletions

102
mmc
View File

@ -37,6 +37,9 @@ my $DuCommand = "du -h /home/mtowner/|tail -1";
my $FilesToRemove = "$MINETESTDIR/debug.txt $MINETESTDIR/MinetestScreen.log";
my $CrontabCommand = "crontab -e";
my $BuildCommand = "make";
my $WhoCommand = "/usr/bin/w";
my $LastCommand = "/usr/bin/last";
my $TopCommand = "/usr/bin/top";
###################################################
# No changes below here
@ -351,14 +354,14 @@ sub BackupTools
# Run a backup
PrintDebugCommand("$BackupCommand");
system("$BackupCommand");
print "Press Enter To Continue";
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
elsif ($menuselection eq "2")
{
# Do a restore
DoRestore();
print "Press Enter To Continue";
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
}
@ -466,7 +469,7 @@ sub ServerTools
system("clear");
PrintDebugCommand("$BackupCommand");
system("$BackupCommand");
print "Press Enter To Continue";
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
elsif ($menuselection eq "2")
@ -496,6 +499,75 @@ sub ServerTools
}
}
sub ServerStatusMenu
{
my $WantRespawn="ON";
CheckServerStatus();
if (-f "$MINETESTDIR/nostart")
{
$WantRespawn="OFF";
}
$menuselection = $d->menu( title => "Server Status Menu", text => "Server is $ServerStatus and respawn is $WantRespawn - Select one:",
list => [ '1', 'Free Space',
'2', 'Current Version',
'3', 'Shell Users',
'4', 'Last Shell Logins',
'5', 'Running Processes',
'q', 'Main Menu' ] );
}
sub ServerStatusTools
{
while (-1)
{
ServerStatusMenu();
if (($menuselection eq "CANCEL") || ($menuselection eq "ESC") || ($menuselection eq "") || ($menuselection eq "q") || ($menuselection eq "Q"))
{
return;
}
elsif ($menuselection eq "1")
{
# Space Usage
system("clear");
SpaceUsage();
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
elsif ($menuselection eq "2")
{
# Get Version
system("clear");
system("$MINETESTDIR/bin/$ServerProcess --version");
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
elsif ($menuselection eq "3")
{
# Who's Online
system("clear");
system("$WhoCommand");
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
elsif ($menuselection eq "4")
{
# Last Logins
system("clear");
system("$LastCommand");
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
elsif ($menuselection eq "5")
{
# Top Processes
system("clear");
print "--- To exit this command press \"q\" ---";
my $entered = <STDIN>;
system("$TopCommand");
}
}
}
sub DoUpdate
{
@ -505,7 +577,7 @@ sub DoUpdate
chdir ($DesiredDir);
PrintDebugCommand("Running $UpdateCommand in $DesiredDir\n");
system("$UpdateCommand");
print "Press Enter To Continue";
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
@ -675,7 +747,6 @@ sub SpaceUsage
return;
}
print "Leaving temporary files alone\n";
sleep 5;
}
sub MainMenu
@ -703,10 +774,9 @@ sub MainMenu
'13', 'Edit News.txt',
'14', 'Update Utils',
'15', 'Install Mod',
'16', 'Space Usage',
'16', 'Server Status',
'17', 'Scheduled Tasks',
'18', 'Current Version',
'19', 'Server Tasks',
'18', 'Server Tasks',
'q', 'Quit MMC' ] );
}
@ -779,7 +849,7 @@ while (-1)
# View online players
system("clear");
system("ls $PlayersDir");
print "Press Enter To Continue";
print "--- Press Enter To Continue ---";
my $entered = <STDIN>;
}
elsif ($menuselection eq "11")
@ -812,23 +882,15 @@ while (-1)
}
elsif ($menuselection eq "16")
{
# Space Usage
SpaceUsage();
# Server Status Tools
ServerStatusTools();
}
elsif ($menuselection eq "17")
{
# Space Usage
system("$CrontabCommand");
}
elsif ($menuselection eq "18")
{
# Get Version
system("clear");
system("$MINETESTDIR/bin/$ServerProcess --version");
print "Press Enter To Continue";
my $entered = <STDIN>;
}
elsif ($menuselection eq "19")
elsif ($menuselection eq "18")
{
# Server Tools
ServerTools();