-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
93 lines (93 loc) · 2.87 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<head>
<title>WhiteCore Grid Manager</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<script src="https://use.fontawesome.com/96c26a4572.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta charset="iso-8859-1" />
<style type="text/css">
body
{
background-color: #DADADA;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse navbar-static-top animate">
<div class="container">
<ul class="nav navbar-nav">
<li> <a class="navbar-brand" href="index.php"><b>WhiteCore Grid Manager</b></a></li>
<li><a href="index.php">Home</a></li></li>
<li><a href="?a=start">Start Grid</a></li></li>
<li><a href="?a=stop">Stop Grid</a></li></li>
<li><a href="?a=restart">Restart Grid</a></li></li>
<li><a href="?a=backup">Backup</a></li></li>
<li><a href="?a=backup_mysql">Backup Database</a></li></li>
</ul>
</div>
</nav>
<?php
include("config.php");
require("classes/class.ssh2.php");
$ssh = new SSH2(SSH_HOST,SSH_PORT);
$ssh->auth(SSH_USER, SSH_PASS);
$a = isset($_GET['a']) ? $_GET['a'] : '';
if($a == "start")
{
$ssh->exec("cd ". WC_PATH . "&& ./run_gridmode_html.sh");
echo $ssh->output();
}
else if($a == "stop")
{
$ssh->exec("cd ". WC_PATH . "&& ./stop_grid.sh");
echo $ssh->output();
}
else if($a == "restart")
{
echo "Restarting Grid";
$ssh->exec("cd ". WC_PATH . "&& ./stop_grid.sh");
echo $ssh->output();
$ssh->exec("cd ". WC_PATH . "&& ./run_gridmode_html.sh");
echo $ssh->output();
}
else if($a == "backup")
{
echo "Starting backup in background.";
$ssh->exec("cd " .WC_ROOT. " && sudo screen -AmdS backup tar czf backup.$(date +%Y%m%d-%H%M%S).tar.gz .");
}
else if($a == "backup_mysql")
{
echo "Starting MySQL backup in background.";
$ssh->exec("cd ". WC_PATH . "&& screen -AmdS backupdb ./backup_db.sh");
}
else
{
echo '<div class="row2" style ="background-color: #2ba6cb;" width=30%>';
$ssh->exec("screen -ls | grep Sim");
$check1 = $ssh->output();
if (strpos($check1, 'Sim') !== false)
{
echo "<font color='lime'>Sim Server Running</font><br />";
}
else
{
echo "<font color='red'>Sim server Stopped</font><br />";
}
echo "<hr>";
$ssh->exec("screen -ls | grep Grid");
$check2 = $ssh->output();
if (strpos($check2, 'Grid') !== false)
{
echo "<font color='lime'>Grid Server Running</font><br />";
}
else
{
echo "<font color='red'>Grid server Stopped</font><br />";
}
echo "</div>";
echo "<br><br>";
}
?>