forked from LightsOnHudson/FPP-Plugin-MessageQueue
-
Notifications
You must be signed in to change notification settings - Fork 1
/
commonFunctions.inc.php
executable file
·54 lines (31 loc) · 1.14 KB
/
commonFunctions.inc.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
<?php
//update plugin
function updatePluginFromGitHub($gitURL, $branch="master", $pluginName) {
global $settings;
logEntry ("updating plugin: ".$pluginName);
logEntry("settings: ".$settings['pluginDirectory']);
//create update script
//$gitUpdateCMD = "sudo cd ".$settings['pluginDirectory']."/".$pluginName."/; sudo /usr/bin/git git pull ".$gitURL." ".$branch;
$pluginUpdateCMD = "/opt/fpp/scripts/update_plugin ".$pluginName;
logEntry("update command: ".$pluginUpdateCMD);
exec($pluginUpdateCMD, $updateResult);
//logEntry("update result: ".print_r($updateResult));
//loop through result
return;// ($updateResult);
}
function logEntry($data, $logLevel = 1, $sourceFile = "", $sourceLine = "") {
global $logFile,$myPid, $LOG_LEVEL;
if($logLevel <= $LOG_LEVEL)
//return
if($sourceFile == "") {
$sourceFile = $_SERVER['PHP_SELF'];
}
$data = $sourceFile." : [".$myPid."] ".$data;
if($sourceLine !="") {
$data .= " (Line: ".$sourceLine.")";
}
$logWrite= fopen($logFile, "a") or die("Unable to open file!");
fwrite($logWrite, date('Y-m-d h:i:s A',time()).": ".$data."\n");
fclose($logWrite);
}
?>