Minor correction to run in container

This commit is contained in:
2016-07-18 09:37:01 +02:00
parent 83e0e0b86b
commit 0a9e94da01
5 changed files with 19 additions and 18 deletions

4
opt/inverter/create_rrd.php Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/local/bin/php
<?php
require_once 'rrd.php';
@@ -75,4 +75,4 @@ foreach (glob($sDataDirectory . '/*.csv') as $sFile) {
RRD::update($sFile, $iTime, $aValues);
}
}
}
}

14
opt/inverter/daemon.php Normal file → Executable file
View File

@@ -1,16 +1,14 @@
<?php
require_once 'System/Daemon.php'; // pear install -f System_Daemon
define('NAME', 'inverter');
define('TASK', '/opt/inverter/inverter.pl > /dev/null');
define('CWD', '/opt/inverter/');
define('FILE_DAEMON_START', 'daemon_start.sh');
define('FILE_DAEMON_STOP', 'daemon_stop.sh');
define('MODE', 0755);
define('PROCESS_POLL', 30);
/* Install daemon */
if (isset($argv[1]) && $argv[1] == 'install') {
daemon_install();
}
function daemon_init() {
global $sName;
@@ -26,8 +24,10 @@ function daemon_init() {
}
function daemon_install() {
global $argv;
System_Daemon::writeAutoRun(); // update-rc.d %s defaults
/* Write scripts for scheduling with at */
if (isset($argv[2]) && $argv[2] == 'schedule') {
if (!file_exists(FILE_DAEMON_START)) {
@@ -65,4 +65,4 @@ function daemon_sigterm_handler($iSigNo) {
global $sName;
system(sprintf('pkill %s', $sName));
System_Daemon::stop();
}
}

13
opt/inverter/inverter.php Normal file → Executable file
View File

@@ -1,16 +1,17 @@
#!/usr/bin/php
#!/usr/local/bin/php
<?php
require_once 'functions.php';
require_once 'daemon.php';
define('NAME', 'inverter');
define('TASK', '/opt/inverter/inverter.pl > /dev/null');
define('CWD', '/opt/inverter/');
/* Initialize */
chdir(CWD);
daemon_init();
/* Install daemon */
if (isset($argv[1]) && $argv[1] == 'install') {
daemon_install();
}
/* Remove previous at entries */
foreach (explode("\n", trim(command('atq 2> /dev/null'))) as $sJob) {
$sId = substr($sJob, 0, strpos($sJob, "\t"));
@@ -54,4 +55,4 @@ function schedule_sleep() {
$sTime = date('H:i', strtotime($sSleep));
System_Daemon::info(sprintf('Schedule sleep at %s', $sTime));
command(sprintf('at -f %s %s 2> /dev/null', FILE_DAEMON_STOP, $sTime));
}
}

0
opt/inverter/inverter.pl Normal file → Executable file
View File

6
opt/inverter/pvoutput.php Normal file → Executable file
View File

@@ -1,4 +1,4 @@
#!/usr/bin/php
#!/usr/local/bin/php
<?php
require_once 'functions.php';
require_once 'rrd.php';
@@ -92,7 +92,7 @@ if (isset($fTemperature)) {
$fTemperature = abs($aToday[3] - $fTemperature) > (MARGIN_TEMPERATURE * $aToday[3]) ? $aToday[3] : $fTemperature;
}
$aData['v5'] = $fTemperature; // ignore potential flaws in first temperature of the day
file_put_contents('temp.csv', sprintf("%d,%f\n", $iTime,$fTemperature), FILE_APPEND);
file_put_contents('temp.csv', sprintf("%d,%f\n", $iTime, $fTemperature), FILE_APPEND);
}
/* Store debug data */
@@ -109,4 +109,4 @@ if (isset($aSystems[$sSerial])) {
CURLOPT_POSTFIELDS => http_build_query($aData),
CURLOPT_RETURNTRANSFER => true));
$sResult = curl_exec($rCurl);
}
}