-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm2_ssh_commands.php
82 lines (70 loc) · 2.44 KB
/
m2_ssh_commands.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
<?php
error_reporting(1);
ini_set('max_execution_time', 0);
require __DIR__ . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
?>
<html>
<head>
<title>Commands Executor</title>
</head>
<body>
<form action="<?php echo $storeManager->getStore()->getBaseUrl(); ?>" id="commands" type="post">
<center>
<h1> Select command from below list</h1>
<select name="command">
<option>Option Select Operation</option>
<option value="cache_clean">Cache Clean</option>
<option value="cache_flush">Cache Flush</option>
<option value="reindex">Reindex</option>
<option value="setup_upgrade">Setup Upgrade</option>
<option value="deploy">Deploy</option>
<option value="permission">Folder Permission Without Sudo</option>
<option value="sudo_permission">Folder Permission with Sudo</option>
</select>
<button type="submit" form="commands" value="Submit">Submit</button>
</center>
</form>
<?php
if(isset($_GET['command'])){
$task = $_GET['command'];
switch ($task) {
case 'cache_clean':
$command = 'php '.__DIR__.'/bin/magento cache:clean';
echo '<pre>' . shell_exec($command) . '</pre>';
break;
case 'cache_flush':
$command = 'php '.__DIR__.'/bin/magento cache:flush';
echo '<pre>' . shell_exec($command) . '</pre>';
break;
case 'reindex':
$command = 'php '.__DIR__.'/bin/magento indexer:reindex';
echo '<pre>' . shell_exec($command) . '</pre>';
break;
case 'setup_upgrade':
$command = 'php '.__DIR__.'/bin/magento setup:upgrade';
echo '<pre>' . shell_exec($command) . '</pre>';
break;
case 'deploy':
$command = 'php '.__DIR__.'/bin/magento setup:static-content:deploy -f';
echo '<pre>' . shell_exec($command) . '</pre>';
break;
case 'permission':
$command = 'chmod -R 777 '.__DIR__.'/var/ '.__DIR__.'/pub/ '.__DIR__.'/generated/ ';
echo '<pre>' . shell_exec($command) . '</pre>';
break;
case 'sudo_permission':
//$command = 'sudo chmod -R 777 '.__DIR__.'/var/ '.__DIR__.'/pub/ '.__DIR__.'/generated/ ';
//echo '<pre>' . shell_exec($command) . '</pre>';
echo "Please Run this command from Shell.";
break;
default:
echo "Please select Command";
break;
}
}
?>
</body>
</html>