-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonoInverter.php
28 lines (25 loc) · 996 Bytes
/
MonoInverter.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
<?php
$datafile = '/tmp/MonoInverter.json';
$dataroot = '/tmp/MonoInverter';
if (!file_exists($dataroot))
if (!mkdir($dataroot))
{
echo "Failed to create $dataroot\n";
exit;
}
// Get fresh data?
shell_exec("cd /mnt/dietpi_userdata/MonoInverter; mono ./MonoInverter.exe > $datafile");
if (file_exists($datafile))
{
if ($data = @json_decode(file_get_contents($datafile)))
{
foreach ((array)$data AS $i => $v)
{
echo "$i => $v\n";
file_put_contents($dataroot.'/'.$i, $v);
}
echo "\n";
} else
echo "Invalid json data found in $datafile\n";
} else
echo "No json data found in $datafile\n";