Nowa wersja obrazów OpenWRT r39288

Nowa wersja obrazów właśnie została skompilowana, nowe obrazy znajdują się pod adresem:

http://grucha.no-ip.pl:82

Working Copy Root Path: /home/openwrt/trunk
URL: svn://svn.openwrt.org/openwrt/trunk
Repository Root: svn://svn.openwrt.org/openwrt
Repository UUID: 3c298f89-4303-0410-b956-a3cf2f4a3e73
Revision: 39288
Node Kind: directory
Schedule: normal
Last Changed Author: blogic
Last Changed Rev: 39288
Last Changed Date: 2014-01-14 20:35:55 +0100 (Tue, 14 Jan 2014)

Ponadto chciałbym dodać że:

  • zostało dodane do obrazu GUI do Transmission (możliwośc skonfigurowania w Luci)
  • usunięto z obrazu tryb failsafe dla Luci – ponieważ było to niebezpieczne dla routerów widocznych z zewnatrz

 

Moje kompilacje OpenWRT Trunk

Założyłem na blogu nową kategorie o Nazwie OpenWRT Trunk, będę zamieszczał tam info odnośnie moich kompilacji OpenWRT

Wersja Trunk, obrazy bede sie starał aktualizować na bieżąco, wsparcie dla routerów z 8MB pamięcią flash ze względu na ilość wkompilowanych pakietów.

Obrazy posiadają:

  • Luci + Luci tryb failsafe
  • Samba + Gui
  • QoS
  • Multiwan + Gui
  • QoS
  • UPnP
  • obsługę nośników ntfs
  • Wake On Lan
  • HDD Idle
  • Transmission + Transmission Luci
  • i wiele innych…

Obrazy można pobierać z :

http://grucha.no-ip.pl:82

Paczki:

http://grucha.no-ip.pl:82/packages

Aktualna wersja systemu to OpenWRT Barrier Breaker.

Instalacja serwera LAMP = Apache+MySQL+PHP+phpMyAdmin

Skrót LAMP odnosi się do zestawu oprogramowania o otwartym kodzie źródłowym, powszechnie odnoszącego się do platformy serwera dynamicznych stron WWW. Po Polsku LAMP oznacza dosłownie Linux Apache MySQL PHP. Jest to pełen pakiet aplikacji i oprogramowania potrzebnego do uruchomienia serwera WWW z bazą danych na naszej maszynie.

Instalacja jest dośc prosta i nie wymaga specjalnych umiejętności:

W przypadku systemów Ubuntu/Lubuntu Mint itp. :

sudo su 

A później: (w przypadku Debiana, logujemy się po prostu na konto root i efekt będzie ten sam)

aptitude install apache2 apache2-utils apache2-mpm-prefork php5 php5-common mysql-server mysql-common libapache2-mod-php5 php5-mysql phpmyadmin

Podczas instalacji zostajemy zapytani o kilka opcji m.in hasło do administratora bazy danych mysql.

Domyślnie serwer www nasłuchuje na katalog /var/www i tam należy wgrywać własną stronę WWW.

Serwer działa teraz pod adresem http://<IPSerwera>/ bądź http://localhost

 

Test PHP:

touch /var/www/test.php

echo "<?php phpinfo(); ?>" >> /var/www/test.php

I wczytujemy w przeglądarce http://<IPSerwera>/test.php lub http://localhost/test.php

Jeśli poprawnie nie działa to powinno pomóc przeładowanie serwera Apache

a2enmod php5
/etc/init.d/apache2 force-reload

Test MySQL

mysql -u root -p

Powinien pojawić się monit o hasło – podajemy je.

Tak wygląda odpowiedź serwera MySQL:

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 859
Server version: 5.5.33-1 (Debian)

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Strony możemy kopiować do katalogu

  • /var/www – jednak do tego wymagane są uprawnienia root’a
  • /public_html – katalog zakładamy w naszym katalogu, i nie musimy mieć uprawnień administracyjnych
  • By można było korzystać z katalogu public_html znajdującym się w naszym katalogu domowym

Musimy wykonać następujące kroki z poziomu użytkownika:

mkdir ~/public_html

Jednorazowe uaktywnienie modułu userdir

a2enmod userdir

Na taką stronę wchodzimy przez taki adres: http://localhost/~twoja-nazwa-uzytkownika np: http://localhost/~krzysztof lub http://localhost/~user3

 
Warto zaznaczyć że katalogi i pliki udostępniane przez serwer Apache2 powinny mieć odpowiednie uprawnienia (względy bezpieczeństwa)

  • katalogi 755
  • pliki 644
  • jeśli korzystamy z public_html to nasz katalog domowy powinien mieć uprawnienia 711

Do zmiany uprawnień używamy chmod.

 

Apache i moduł SSL czyli protokuł https

Generowanie certyfikatu:

mkdir /etc/apache2/ssl; cd /etc/apache2/ssl
openssl genrsa -out /etc/apache2/ssl/apache.key 1024
openssl req -new -x509 -days 365 -key /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

Po tym poleceniu program zapyta nas o kilka informacji, które należy podać w celu dostarczenia niezbędnych informacji organowi wydającemu certyfikaty.

Aktywujemy port 443

echo "Listen 443" >> /etc/apache2/ports.conf

Instalacja certyfikatu: (instalacja modułu jeśli brak i jego uruchomienie)

apt-get install apache2 libapache-mod-ssl
a2enmod ssl
/etc/init.d/apache2 restart
cd /etc/apache2/sites-available
cp 000-default.conf default-ssl.conf

I edytujemy default-ssl.conf

nano default-ssl.conf

i wklejamy: ( a właściwie zamieniamy)

NameVirtualHost *:443
<virtualhost *:443>
 ServerAdmin webmaster@localhost

SSLEngine On
 SSLCertificateFile /etc/apache2/ssl/apache.crt
 SSLCertificateKeyFile /etc/apache2/ssl/apache.key
 DocumentRoot /var/www/

...

Na koniec:

a2ensite ssl
/etc/init.d/apache2 restart

 

Wystarczy teraz wczytać https://<ip-serwera> lub https://localhost

 

Reasumując:

  • Serwer WWW znajduje się w katalogu /var/www ale można włączyć moduł userdir
  • Adres do serwera to po prostu http://<ip-serwera>
  • Adres do phpmyadmina http://<ip-serwera>/phpmyadmin
  • Domyślny port http 80
  • Domyślny port mysql 3306
  • Domyślny port https 443

Digitemp i zapis do mysql – instalacja dtgraph v0.4n

Opis budowy domowego termometra już był, dzis czas na opis konfiguracji jakiegoś “logera” tych informacji dla potomnych.

Opisze bardzo mało znane narzędzie  dtgraph v0.4n.

Do prawidłowego działania DTGraph wymaga oczywiście serwera WWW z obsługą PHP oraz serwer mysql oraz moduł PHP generujący JPG.

Ja jako demona www używam Apache w wersji 2.4.6, PHP w wersjii 5.5.6-1 oraz mysql 5.5.-33.1

apt-get update

apt-get install apache2 php5 mysql-server phpmyadmin libphp-jpgraph nano php-mdb2-driver-mysql php-pear

pear install MDB2-2.4.1

Teraz pobieramy ze źródeł dtgraph’a lub stąd -> http://pliki.gru.one.pl/01-2014/dtgraph-0.4n.tar.gz

Polecam pobrać sobie to na komputer na którym mamy jakies środowisko graficzne, będzie łatwiej.

Po wypakowaniu mamy strukturę katalogów, a nas interesuja dokładnie dwa katalogi czyli SQL i WWW.

Zawartośc katalogu WWW należy przesłać np poprzez SCP do katalogu /var/www na naszym serwerze.

Ja mam to w katalogu /var/www/dt

Zawartośc katalogu SQL – tam właśnie są tabele bazy danych które musimy wgrać do naszej bazy mysql.

Wchodzimy przeglądarką na nasz serwer http://<ip_serwera>/phpmyadmin logujemy się na konto root z uzyciem naszego hasła roota.

Teraz należy wyklikać sobie nową tabelę, moja ma nazwę temperatura, a do tej bazy importujemy wpisy zkatalogu DTGrapha

  • mysql_create_digitemp_metadata
  • mysql_create_digitemp
  • mysql_create_digitemp_alarms

Po zaimportowaniu tych 3-tabel praca w phpmyadmin jest skończona, teraz zostało skonfigurowanie reszty.

W  plikach DTGrapha znajduję sie conf.php

To już można wykonać w konsoli, czyli:

nano /var/www/dt/conf.php

Ukaże się nam plik konfiguracyjny:

<?php

/*
 * DTTemp Configuration File
 *
 * Structure loosely based on horde's components
 * (www.horde.org)
 */

/************** PHP config **************************/
// Ubuntu has E_NOTICE on - which causes problems sometimes.
// Also, Some MDB2 versions have deprecation
// Comment this out if you don't want this app to change your log
// level (applies to this app only)
ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_DEPRECATED);

/************** Database Properties *****************/
/****************************************************/
$conf['driver'] = 'sql';

$conf['sql']['phptype'] = 'mysql'; //typ bazy - pozostawiamy mysql

// What protocol will we use to connect to the database. The default
// is tcp, but if you wish to use UNIX sockets, change it to 'unix'.
$conf['sql']['protocol'] = 'tcp';

// If you are using UNIX sockets, you may need to specify the socket's
// location.
// $conf['sql']['socket'] = '/var/lib/mysql/mysql.sock';

// What port is the database server running on? Not required for all
// databases.
$conf['sql']['port'] = 3306; wskazujemy port, domyslnie opcja zakomentowana, wystarczy wpissac port standardowy to 3306 i odkomentowac linie

// What hostname is the database server running on, or what is the
// name of the system DSN to use?
$conf['sql']['hostspec'] = 'localhost';  //host bazy, zazwyczaj localhost

// What username do we authenticate to the database server as?
$conf['sql']['username'] = 'root';  // uzytkownik bazy
// What password do we authenticate to the database server with?
$conf['sql']['password'] = 'TWOJEHASLO';  // twoje haslo do konta

// What database name/tablespace are we using?
$conf['sql']['database'] = 'temperatura'; // nazwa stworzonej bazy danych przez Ciebie
//Main table name that digitemp_mysql.pl logs to
$conf['sql']['table'] = 'digitemp'; // te wartości pozostawiamy standardowe, jeśli nie zmianialiśmy naz tabeli
//Metadata table describing available sensors
$conf['sql']['table_meta'] = 'digitemp_metadata';
//Alarms table describing raised/old alarms
$conf['sql']['table_alarms'] = 'digitemp_alarms';
// What charset does the database use internally?
$conf['sql']['charset'] = 'iso-8859-1';
/********************* LOGGER **********************/
/****************************************************/
// This is for the script that will insert current
// readings into the database (PHP version).
// This is optional - it is needed only if you logger.php (on cron)
//$conf['digitemp_binary'] = '/usr/local/bin/digitemp';
$conf['digitemp_binary'] = '/usr/bin/digitemp_DS9097';
$conf['digitemp_config'] = '/root/.digitemprc';
/************** JPGraph Properties ******************/
/****************************************************/

//The dir path under which jpgraph.php and others can be found
//This may be relative or absolute (filesystem, not url)
$conf['jp_path'] = "/usr/share/jpgraph/";
/************** Graph Properties ********************/
/****************************************************/
$conf['graph'] = array(); //leave this line alone!

//The colors define the graph colors in reverse order
//The colors now come from the metadata table, but
//these are defaults for yet undescribed sensors
$conf['graph']['colors'] = array("black","gray","blue","red","green","yellow","magenta","purple");

//Background color of the graph image
$conf['graph']['bgcolor'] = '#F0F0FF';

//Graph size below (in pixels):
$conf['graph']['width'] = 800;
$conf['graph']['height'] = 600;
//$conf['graph']['width'] = 640;
//$conf['graph']['height'] = 480;

$conf['data'] = array(); //leave alone

/*** UNITS ****/
//Temp display units. Logging is assumed to be done in fahrenheit
//(As is suggested by the schema)
//Possible values are : "celsius", "fahrenheit"
//Note that changing this changes default,
//as well as changing the checkbox in the inteface to offer the
//other unit of measurement instead
//$conf['data']['units'] = 'fahrenheit';
$conf['data']['units'] = 'celsius';

/*** Precision ***/
//Number of digits to show after decimal point
//in stats, etc
$conf['data']['displayPrecision'] = 2;
/**** Initial ****/
//negative number of seconds to set start time to
//when the page is first visited
$conf['data']['defaultOffset'] = -3600 * 12; //3 hours ago

//same for alarm viewer
$conf['data']['alarmsDefaultOffset'] = -3600 * 24 * 60; //two months
// Safeties on incoming data:
$conf['data']['loggerValidTempMin'] = -80;
$conf['data']['loggerValidTempMax'] = 180;

// Default states of main interface checkboxes
$conf['data']['defaults'] = array(
 'show_stats' => true,
 'showLegend' => false,
 'showMargin' => false,
 'showMarks' => true,
 'showBands' => false,
 'showNegatives' => true,
 'datesAbsolute' => false,
 'showRepeats' => false,
 'showAll' => false,
 'showAlarms' => false,
 // toggleUnits is handled above: $conf['data']['units']
);
/**** THIN OUT ********/

/**
Thinning out data (dropping every Nth record from display)
This is basically an attempt to keep the graph drawing engine
From being overloaded with data (it will take forever)

There are two supported ways of skipping data
SQL and CODE (or AUTO - below)
Code will read all data for the requested timeframe, and then
decide what to skip. This results in more datatransfer from DB
but a much smoother distribution of points (read on)

SQL complicates the WHERE part of the select statement by restricting
time to being less than a calculated amount per hour,day,month, etc
this is crude but fast, and results in a dense bunch of points at the
beginning of each calculated interval.
This mode relies on the collectionInterval (below) and
will not be accurate if data for different sensors is
collected at different intervals, or if the data has
been selectively purged for any reason

A combination mode of AUTO allows the program to auto-detect when to use which
It uses the threshold below. Setting it to AUTO will result in a
count query ran every time, allowing to decide which method to use.
Count queries don't take a significant amount of time.

How will you know which mode it's using?
Well first of all, the graph will show
"Measurements shown 3233/9899" at the bottom, where 9899 is the total amount.
If that amount exceeds your threshold below, then it's using SQL.
The other indicator is that graph edges are particularly jagged in SQL mode.
**/
$conf['data']['thinOutMethod'] = "AUTO";

// ------ This is for AUTO thinOut method -----
//In AUTO mode (above), how many readings must
//there be to switch to SQL+CODE method of thinOut
//over just CODE mode for thinout
//For my XP1800+ CPU the value of 50000 seems good
//it slows down noticeably as you get closer to 100K
$conf['data']['thinOutAutoSQLThreshold'] = 50000;
// ------ This is for CODE/AUTO thinOut method -----
//First I need to know how often temperature is collected
//This is in minutes. This should agree with the interval
//in your cron schedule, if the itervals are uneven -
//put in average number of minutes
//This setting affects the SQL thin Out method
$conf['data']['collectionInterval'] = 5; //minutes

// -------- This is for all thinOut methods --------
//The algorithm will attempt to thin out the data to a point
//where the resulting datapoint count will be below this value
//Setting this to a reasonable value
//will keep rendering time reasonable
//This value is the total points for all sensors being displayed
//Note that having collectionInterval set correctly
//is imperative to correct guessing
$conf['data']['maxThinnedOutDataPoints'] = 1000;
/************** HTML Properties *********************/
/****************************************************/
$conf['html'] = array(); //no movo this lino

//Background color for main page
//as well as graph margin
//Tip: using simple colors (FF,DD, etc) usually
//yields exact color matches between graph margin
//and HTML background
$conf['html']['bgcolor'] = "#DDDDFF";

/***** FORM submission METHOD *****/
//set to GET to be able to bookmark the url
//with all the options,
//set to POST to have have a more aesthetically pleasing URL
//NOTE - cookies offer a more flexible way of
//remembering settings - see below
$conf['html']['formMethod'] = "POST";
/************ PREFS *************/
$conf['prefs'] = array();

//enable cookies for saving
//user preferences
$conf['prefs']['cookieenable'] = true;

//name for prefs cookie
$conf['prefs']['cookiename'] = 'dtgraphprefs';

//lifetime for prefs cookie, seconds
$conf['prefs']['duration'] = 31536000; //one year

/************** ALARMS ******************************/
/****************************************************/

// Enable alarm checking - if this is off, no new
// alarms will be raised or lowered
// Alarm checking is done via cron when you run
// alarms.php (or logger.php, see below)
$conf['alarms']['enable'] = true;

// Enable alarm checking whenever logger.php
// is run (depends on 'enable' also)
// If this is enabled, you only need one cron job -
// to invoke 'php logger.php'
// If you'd like to update alarm info less frequently,
// or if you're not using logger.php,
// you can set this to false and add 'php alarms.php' to cron
$conf['alarms']['onLogger'] = true;
//Enable alarms display support... this makes dtgraph
//check for active alarms every time the main page is hit
// but this doesn't actually raise alarms!
//This is the default value for the checkbox on the interface
$conf['alarms']['display'] = true;

//Notify whenever an alarm is raised
//This option applies to the admin
//script which gets run on a cron (optional)
$conf['alarms']['notify'] = true;
$conf['alarms']['notifyEmail'] = 'system-alert';

//format (for date() function) to show dates in html
$conf['alarms']['dateformat'] = 'm/d g:i A';

&nbsp;

/****************************************************/
$conf['version'] = '0.4n';

?>

Po krótce wyjaśniłem opcje które zmieniamy i ustawiamy.

U mnie do poprawnego odczytu czujników temperatury wymagały edycję w katalogu admin/logger.php

Zmiana polegała na zmianie linii:

$command = $conf['digitemp_binary'].' -q -a -o"%R %.2F" -c '.$conf['digitemp_config'];

na

$command = 'digitemp_DS9097 -q -a -o"%R %.2F" -c /root/.digitemprc';

Pozostało tylko dodać wykonywanie odczytu teperatury do crona, aby cyklicznie się odświerzała temperatura:

crontab -e

i doklejamy:

*/5 * * * * php -f /var/www/dt/admin/logger.php >> /dev/null 2>&1

Oczywiście musisz zmienić scieżkę do katalogu DTGrapha jeżeli masz inna.

Polecam również zabezpieczyć hasłem katalog /admin aby niepowołane osoby tam nie zaglądały.

Efekty pracy:

ss-dtgraph

 

 

 

 

 

 

 

 

Przykład działania ( już od około pól roku działa nieprzerwanie):

http://s.temperatura.gniezno.pl/dt