Merge branch 'master' of github.com:volkszaehler/volkszaehler.org

This commit is contained in:
Steffen Vogel 2011-01-03 09:26:06 +01:00
commit ce3611c46f
11 changed files with 69 additions and 230 deletions

View file

@ -27,7 +27,7 @@
// default time interval to show
vz.options = {
language: 'de',
backendUrl: '../backend/index.php',
backendUrl: '../backend.php',
tuples: 300,
render: 'lines',
refresh: false,

2
lib/vendor/README vendored
View file

@ -2,4 +2,4 @@ This directory contains PHP libraries by external developers or projects.
Please consult the wiki for detailed instructions:
http://wiki.volkszaehler.org/getstarted
http://wiki.volkszaehler.org/howto/getstarted

View file

@ -5,7 +5,7 @@
#
# call it with a cronjob similiar to this one:
#
# */5 * * * * ~/bin/log1wire.sh
# */5 * * * * ~/bin/log_onewire.sh
#
# @copyright Copyright (c) 2010, The volkszaehler.org project
# @package controller

View file

@ -0,0 +1,58 @@
#!/bin/bash
#
# This is a simple bash script to read Dallas 1-Wire sensors
# connected to a controller board running ethersex and log their
# values to the volkszaehler project.
#
# call it with a cronjob similiar to this one:
#
# */5 * * * * ~/bin/log_onewire_ecmd.sh
#
# @copyright Copyright (c) 2010, The volkszaehler.org project
# @package controller
# @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
# @author Justin Otherguy <justin@justinotherguy.org>
# @author Steffen Vogel <info@steffenvogel.de>
#
##
# This file is part of volkzaehler.org
#
# volkzaehler.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# volkzaehler.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
##
# configuration
#
# backend url
URL="http://volkszaehler.org/neu/backend/index.php"
# sensor settings
# id of the sensor
SENSORID=<put your onewire sensor's hw id here>
# ip address of the controller board running ethersex
ESEXIP=<put the ip address of your controller board here>
# uuid of the sensor in the volkszaehler database
UUID=<put the uuid of your temperature sensor here>
##
# paths to binaries - you should not need to change these
CURL=/usr/bin/curl
NC=/bin/nc
# ========= do not change anything below this line ==============
echo "1w convert $SENSORID" |$NC $ESEXIP 2701 -q 1 2>/dev/null | grep -qe OK || exit 1
TEMPERATURE=`echo 1w get $SENSORID | nc $ESEXIP 2701 -q 1 2>/dev/null | sed -e 's/Temperatur: //'`
$CURL --data "" "$URL/data/$UUID.json?value=$TEMPERATURE"

View file

@ -2,9 +2,9 @@ volkszaehler.org uses doctrine [1] as database abstraction and object relation m
To setup your database follow these steps:
1. Make sure you have a proper configuration file (backend/volkszaehler.conf.php)
1. Make sure you have a proper configuration file (etc/volkszaehler.conf.php)
2. Adjust the configuration to your database setup
3. Call backend/bin/doctrine orm:schema-tool:create --dump-sql > share/sql/mysql.sql
3. Call misc/tools/doctrine orm:schema-tool:create --dump-sql > misc/sql/mysql.sql
4. import the resulting file using your favorite sql tool
Alternatively you can directly import a existing mysql.sql file or

View file

@ -1,8 +1 @@
Dieses Verzeichnis enhällt Datenbankdumps mit Daten, die für Demonstrationszwecke genutzt werden könne.
HOWTO Import pulses.dummy.copy.gz:
gunzip pulses.dummy.copy.gz
psql -d smartmeter -c "COPY pulses FROM '/var/lib/postgresql/pulses.dummy.copy';"
or use share/tools/import.php for mysql databases.

View file

@ -41,7 +41,7 @@
<?php
$vzDir = '/var/www/vz';
$vzDir = '/var/www/volkszaehler.org';
$output = array();
$rc = 0;
@ -55,8 +55,8 @@ exec($cmd, $output, $rc);
if ($rc == 0) {
# update documentation
$cmd = $vzDir . '/phpdoc/phpdoc -c ' . $vzDir . '/github/share/tools/phpdoc.ini';
//$cmd = 'php5 ' . $vzDir . '/phpdoctor/phpdoc.php ' . $vzDir . '/github/share/tools/phpdoctor.ini';
$cmd = $vzDir . '/phpdoc/phpdoc -c ' . $vzDir . '/github/misc/tools/phpdoc.ini';
//$cmd = 'php5 ' . $vzDir . '/phpdoctor/phpdoc.php ' . $vzDir . '/github/misc/tools/phpdoctor.ini';
$output[] = PHP_EOL . $cmd . PHP_EOL;
exec($cmd, $output, $rc);
}

View file

@ -1,74 +0,0 @@
<?php
/**
* simple script to import demo pulses
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package tools
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
* @todo adapt to doctrine dbal or use native pdo
* @todo move to installer
*/
/*
* This file is part of volkzaehler.org
*
* volkzaehler.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* volkzaehler.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
*/
$sql = '';
$pulses = array();
// initialize db connection
mysql_connect('localhost', 'vz', 'demo');
mysql_select_db('volkszaehler_doctrine');
// dump => db channel id mapping
$mapping[4] = 22;
$mapping[5] = 23;
$mapping[9] = 24;
$mapping[10] = 25;
$fd = fopen('/home/steffen/Desktop/testdaten_nicht_veroeffentlichen.sql', 'r');
if ($fd) {
while (!feof($fd)) {
$line = fgets($fd);
// $matches index 1 2 3 4 5 6 7 8
if (preg_match('/^\((\d), \'(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})\', (\d)/', $line, $matches)) {
$ts = mktime($matches[5], $matches[6], $matches[7], $matches[3], $matches[4], $matches[2]) * 1000;
$value = $matches[8];
$channel = $mapping[$matches[1]];
if ($ts > 0) {
$pulses[] = '(' . $channel . ', ' . $ts . ', ' . $value . ')';
}
if (count($pulses) % 1000 == 0) {
$sql = 'INSERT INTO data (channel_id, timestamp, value) VALUES ' . implode(', ', $pulses);
if (!mysql_query($sql)){
echo mysql_error();
}
echo 'Rows inserted: ' . mysql_affected_rows() . '<br />';
flush();
$pulses = array();
}
}
};
fclose($fd);
}
?>

View file

@ -1,59 +0,0 @@
<?php
/**
* simple script to import demo pulses
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package tools
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
* @todo adapt to doctrine dbal or use native pdo
* @todo move to installer
*/
/*
* This file is part of volkzaehler.org
*
* volkzaehler.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* volkzaehler.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
*/
$sql = '';
$fd = fopen('../docs/developer/pulses.dummy.copy', 'r');
if ($fd) {
while (!feof($fd)) {
$buffer = explode("\t", fgets($fd));
$ts = parsePgSqlTimestamp($buffer[0]);
if ($ts > 0)
$pulses[] = '(' . (int) ($buffer[2] + 1) . ', ' . $ts . ', 1)';
};
fclose($fd);
$sql = 'INSERT INTO data (channel_id, timestamp, value) VALUES ' . implode(', ', $pulses);
$dbh->execute($sql);
echo 'Imported rows: ' . $dbh->affectedRows();
}
else {
throw new Exception('cant open dump');
}
function parsePgSqlTimestamp($timestamp) {
$unix = strtotime($timestamp);
$ms = substr($timestamp, strrpos($timestamp, '.') + 1);
return $unix + $ms/pow(10, strlen($ms));
}
?>

View file

@ -1,78 +0,0 @@
<?php
/**
* Installer
*
* For creating/updating the configuration/database
* and downloading of required libraries
* and configuration of of the PHP interpreter/webserver
*
* @copyright Copyright (c) 2010, The volkszaehler.org project
* @package tools
* @license http://www.opensource.org/licenses/gpl-license.php GNU Public License
* @todo finish
*/
/*
* This file is part of volkzaehler.org
*
* volkzaehler.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* volkzaehler.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with volkszaehler.org. If not, see <http://www.gnu.org/licenses/>.
*/
?>
<?= '<?xml version="1.0"' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>volkszaehler.org - setup</title>
</head>
<body>
<h1>volkszaehler.org - setup</h1>
<?php
// TODO start session with GET-parameter (no cookies)
if (isset($_GET['step'])) {
if (file_exists($_GET['step'] . '.php')) {
include $_GET['step'] . '.php';
}
else {
// TODO check js history call
echo '<span style="color: red; font-weight: bold;">Invalid step during installation: ' . $_GET['step'] . '</span>
<p><a href="javascript:window.location.back()">back</a></p>';
}
}
else {
echo <<<EOT
<p>Welcome to the installation of your volkszaehler.org!<br />
This installer will:
<ul>
<li>check for all requirements</li>
<li>install missing libraries</li>
<li>setup your database + configuration</li>
<li>import your existing data</li>
<li>test your installation</li>
</ul>
Only fundamental administration knowledge is required :)
</p>
<p>
So, ready? Take a cup of coffee and lets take a look on your system:</p>
<p><a href="?step=check">Start with step 1: analyze your system</a></p>
EOT;
}
?>
</body>
</html>

View file

@ -64,7 +64,7 @@ get_db_name() {
echo
echo doctrine setup...
ask "doctrine path?" /usr/local/lib/volkszaehler.org/doctrine
ask "doctrine path?" /usr/local/lib/doctrine
dtdir=$REPLY
REPLY=y
@ -87,8 +87,7 @@ fi
echo
echo volkszaehler setup...
#/var/www/volkszaehler.org
ask "volkszaehler path?" /var/www/vz
ask "volkszaehler path?" /var/www/volkszaehler.org
vzdir=$REPLY
REPLY=y
@ -150,7 +149,7 @@ ask "insert demo data in to database?" n
if [ "$REPLY" == "y" ]; then
get_admin
get_db_name
cat $vzdir/misc/sql/demo/entities.sql $vzdir/misc/sql/demo/properties.sql $vzdir/share/sql/demo/data-demoset1.sql |
cat $vzdir/misc/sql/demo/entities.sql $vzdir/misc/sql/demo/properties.sql $vzdir/misc/sql/demo/data-demoset1.sql |
mysql -h$db_host -u$db_admin_user -p$db_admin_pass $db_name
fi