more path updated...and some clean-ups

This commit is contained in:
Justin Otherguy 2010-12-29 23:22:09 +01:00
parent cbfa56669d
commit f96e38f36b
7 changed files with 6 additions and 225 deletions

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

@ -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