Skip to content
This repository was archived by the owner on Apr 4, 2026. It is now read-only.

Commit 92f396a

Browse files
committed
Add ability to show terminal style output
1 parent 3049088 commit 92f396a

4 files changed

Lines changed: 69 additions & 7 deletions

File tree

source/compose.manager/php/compose_manager_main.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,34 @@ function saveEdit() {
231231
}
232232

233233
function ComposeUp(path) {
234+
var height = 800;
235+
var width = 1200;
236+
234237
$.post(compURL,{action:'composeUp',path:path},function(data) {
235238
if (data) {
236-
openBox(data,"Stack "+basename(path)+" Up",800,1200);
239+
openBox(data,"Stack "+basename(path)+" Up",height,width);
237240
}
238241
})
239242
}
240243

241244
function ComposeDown(path) {
245+
var height = 800;
246+
var width = 1200;
247+
242248
$.post(compURL,{action:'composeDown',path:path},function(data) {
243249
if (data) {
244-
openBox(data,"Stack "+basename(path)+" Down",800,1200);
250+
openBox(data,"Stack "+basename(path)+" Down",height,width);
245251
}
246252
})
247253
}
248254

249255
function ComposePull(path) {
256+
var height = 800;
257+
var width = 1200;
258+
250259
$.post(compURL,{action:'composePull',path:path},function(data) {
251260
if (data) {
252-
openBox(data,"Stack "+basename(path)+" Pull",800,1200);
261+
openBox(data,"Stack "+basename(path)+" Pull",height,width);
253262
}
254263
})
255264
}

source/compose.manager/php/compose_util.php

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,51 @@
22

33
require_once("/usr/local/emhttp/plugins/compose.manager/php/defines.php");
44

5+
function logger($string) {
6+
$string = escapeshellarg($string);
7+
exec("logger ".$string);
8+
}
9+
510
function sanitizeStr($a) {
611
$a = str_replace(".","_",$a);
712
$a = str_replace(" ","_",$a);
813
return str_replace("-","_",$a);
914
}
1015

16+
function execComposeCommandInTTY($cmd)
17+
{
18+
global $socket_name;;
19+
$pid = exec("pgrep -a ttyd|awk '/\\/$socket_name\\.sock/{print \$1}'");
20+
logger($pid);
21+
if ($pid) exec("kill $pid");
22+
@unlink("/var/tmp/$socket_name.sock");
23+
$command = "ttyd -R -o -i '/var/tmp/$socket_name.sock' $cmd". " > /dev/null &";
24+
exec($command);
25+
logger($command);
26+
}
27+
1128
function echoComposeCommand($action)
29+
// {
30+
// global $plugin_root;
31+
// $path = isset($_POST['path']) ? urldecode(($_POST['path'])) : "";
32+
// $unRaidVars = parse_ini_file("/var/local/emhttp/var.ini");
33+
// if ($unRaidVars['mdState'] != "STARTED" ) {
34+
// echo $plugin_root."/scripts/arrayNotStarted.sh";
35+
// logger("Array not Started!");
36+
// }
37+
// else
38+
// {
39+
// $projectName = basename($path);
40+
// if ( is_file("$path/name") ) {
41+
// $projectName = trim(file_get_contents("$path/name"));
42+
// }
43+
// $projectName = sanitizeStr($projectName);
44+
// $path .= "/compose.yml";
45+
// // exec("chmod +x ".escapeshellarg($plugin_root."/scripts/compose.sh"));
46+
// $composeCommand = $plugin_root."/scripts/compose.sh"."&arg1=".$action."&arg2=".$path."&arg3=".$projectName;
47+
// echo $composeCommand;
48+
// }
49+
// }
1250
{
1351
global $plugin_root;
1452
$path = isset($_POST['path']) ? urldecode(($_POST['path'])) : "";
@@ -25,10 +63,13 @@ function echoComposeCommand($action)
2563
}
2664
$projectName = sanitizeStr($projectName);
2765
$path .= "/compose.yml";
28-
// exec("chmod +x ".escapeshellarg($plugin_root."/scripts/compose.sh"));
29-
$composeCommand = $plugin_root."/scripts/compose.sh"."&arg1=".$action."&arg2=".$path."&arg3=".$projectName;
30-
echo $composeCommand;
31-
}
66+
$compose_command = join(" ", array(escapeshellarg($plugin_root."scripts/compose.sh"),escapeshellarg($action),escapeshellarg($path),escapeshellarg($projectName)));
67+
logger($compose_command);
68+
69+
execComposeCommandInTTY($compose_command);
70+
echo "/plugins/compose.manager/php/show_ttyd.php";
71+
logger("/plugins/compose.manager/php/show_ttyd.php");
72+
}
3273
}
3374

3475
switch ($_POST['action']) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
22
$compose_root = "/boot/config/plugins/compose.manager/projects";
33
$plugin_root = "/usr/local/emhttp/plugins/compose.manager/";
4+
$socket_name = "compose_manager_action";
45
?>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
require_once("/usr/local/emhttp/plugins/compose.manager/php/defines.php");
3+
// $docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
4+
// require_once "$docroot/webGui/include/Secure.php";
5+
6+
// $done = unscript($_GET['done']??'');
7+
8+
$url = "/dockerterminal/$socket_name/";
9+
echo '<iframe src="'.$url.'" style="border: none; width: 100%; height: 100%;"></iframe>';
10+
// echo "<p class='centered'><button class='logLine' type='button' onclick=top.Shadowbox.close()'>"+decodeURI($done)+"</button></p>";
11+
?>

0 commit comments

Comments
 (0)