aboutsummaryrefslogtreecommitdiff
path: root/README.txt
blob: d344de6cf610c4bcbb140432313bd9c09fa1e1b4 (plain) (blame)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
== Introduction ==

h-source is web software that can be used to build a community of people that want to share their hardware information. It is based on the EasyGiant PHP framework (www.easygiant.org) and can be considered an EasyGiant application.


== Requirements ==

TODO: It is not clear what are the exact php modules required for the site to run.
      Help with formalizing the module dependencies would be appreciated.
      On a debian-like distro, typically it is sufficient to have the following
      extra modules installed on top of a standard php 7 installation:

* Web server with PHP and URL rewrite (such as Apache with mod-rewrite)
* Any version of MariaDB, or MySQL 5 or newer
* php (currently v7)
* php-fpm (also needs to be enabled)
* php-cli
* php-gd
* php-mbstring
* php-mysql
* php-xml

On a Debian-like system, the following command should be sufficient:

  # apt install apache2 mysql-server php libapache2-mod-php php-mysql php-xml
  # a2enmod rewite

You may need to turn off the STRICT_TRANS_TABLES sql mode to avoid query errors.

In a sql shell, do

  > SELECT @@GLOBAL.sql_mode;

Note all the modes in the output, and set the mode to exclude the STRICT_TRANS_TABLES.

For example, if the output was "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES", do

  > SET GLOBAL sql_mode = "NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION";

* FIXME: apparently this is not needed in some cases.  Find the root cause.


== Installation and configuration ==

Extract the tarball or clone the VCS to your filesystem:

git clone https://git.savannah.gnu.org/git/h-source.git

You have to create the MySQL database used by h-source. The tables of the database that have to be created are written inside the file tables.sql and distros.sql. A way to carry out this operation is the following:

Open a terminal and type:

  # cp Config/Config.php{.sample,}
  # cp admin/Config/Config.php{.sample,}

And if necessary:

  # cp .htaccess{.sample,}

Now edit those configuration files, at least, defining the DB password 'PWD' under "/*db parameters*/" section in Config/Config.php.

The following constants are mandatory:

* DB          // name of the database (the database we will create now)
* USER        // database user
* PWD         // database password
* HOST        // hostname of the mysql server (usually localhost)
* DOMAIN_NAME // domain name of the website (use 'localhost'
                 or create a virtual host in your web server)

Note that the <USERNAME>, <PASSWORD>, and <DB> in the commands below, must correspond to the "/*db parameters*/" in Config/Config.php and admin/Config/Config.php.

Back at the terminal, type:

  # mysql -u <USERNAME> -p

where <USERNAME> is the database user. Write the password and type the following command:

  > create database <DB>;

where <DB> is the database name you want to use. Close Mysql by typing the following command:

  > exit

Now you have to move inside the folder that contains the tables.sql file and type the following commands:

  # mysql -u <USERNAME> -p<PASSWORD> <DB> < tables.sql
  # mysql -u <USERNAME> -p<PASSWORD> <DB> < distros.sql
  # mysql -u <USERNAME> -p<PASSWORD> <DB> < admin/tables.sql

Now you have created the database named <DB> and populated it with the default accepted/recognized distros. This will also create the default web user having the following credentials:

  username: admin
  password: admin

Make sure you change the password of this user!
  
* FIXME: apparently, this is not created sometimes.

  > CREATE USER '<USERNAME>'@'localhost' IDENTIFIED BY '<PASSWORD>';
  > GRANT ALL ON <DB>.* TO '<USERNAME>'@'localhost' IDENTIFIED BY '<PASSWORD>' WITH GRANT OPTION;
  > FLUSH PRIVILEGES;

Create an apache virtual host conf pointing to the h-source directory (say it's /var/www/h-source), enable it and reload the apache web server.  Here's a simple example of the Apache virtual host conf:

  <VirtualHost *:80>
    ServerName <DOMAIN_NAME>
  
    DocumentRoot /var/www/h-source
  
  	<Directory /var/www/h-source>
  		Options Indexes FollowSymLinks MultiViews
  		AllowOverride All
  		Order allow,deny
  		allow from all
  	</Directory>
  	
  	ErrorLog ${APACHE_LOG_DIR}/error.log
  </VirtualHost>
  

Direct your browser to the following URL:

  http://<DOMAIN_NAME>/

where DOMAIN_NAME is the domain name you have previously set (eg: localhost). You should see the home page of the h-source software.

You will be able to login to the website using the 'admin' user and change the website preferences and the admin password.


== Account issues ==

If you want that the system can send e-mails you have to specify the name of the SMTP server that has to be used. Copy the file Application/Include/params.php.sample to Application/Include/params.php and set the following static attributes of the Website class:

  $mailServer = "";   // set the mail server (if $useSMTP = true)
  $generalMail = "";  // set the username of your mail account (always needed)
  $mailPassword = ""; // set the password of your mail account (if $useSMTP = true)
  $fromEmail = "";    // this is the "from address e-mail" used inside the mails
                         sent by h-source (example: confirmation requesta e-mail,
                         change password e-mail, ...)
  $useSMTP = true;    // if you want to use a SMTP account. It can be true or false.
                         Set $useSMTP to false if you want that the software rely on
                         the mail() PHP function.

You can also set these constants:

  $generalName = "";  // the string that you want to use inside the <title> tag of your website
  $projectName = "";  // the name of your project

To configure for the admin app, do the same for admin/Application/Include/params.php.sample.

== Configure the HTML template (right column, top notices, top menu, etc.) ==

Modify the file config.xml inside the ROOT folder of your h-source installation.

If you want to change the position of the config.xml file change the following static attribute of the Website class inside the Application/Include/params.php file:

  static public $xmlConfigFileFolder = ROOT; // the constant ROOT contains the
                                                path to the root folder of your
                                                h-source installaton


== Change the homepage ==

Modify the PHP files inside the folder Application/Views/Home


== Change the hardware ==

Modify the PHP file Application/Include/hardware.php


== Change the allowed distributions ==

Modify the PHP file Application/Include/distributions.php


== Change the allowed languages ==

Modify the PHP file Application/Include/languages.php


== How to fill the vendors table ==

After the installation, you have to fill the MySQL table containing the USB/PCI vendors IDs.  Note this corresponds to vendors for the USB/PCI interface, which are different from say the notebook vendors which are stored in Application/Include/hardware.php.

To carry out this task, use the scripts in the scripts sub-directory.

Change into the scripts/vendorid/ directory. Copy the file connect.php.sample to connect.php and set the following variables with the same values as your h-node instance:

  $host     = '<DOMAIN_NAME>';
  $user     = '<USERNAME>';
  $password = '<PASSWORD>';
  $dbName   = '<DB>';

You will find two files containing the list of vendors: pci.ids and usb.ids. If you want more up-to-date versions of those files then delete them and write the following commands (or download those files from the URLs indicated below):

  wget pciids.sourceforge.net/v2.2/pci.ids -O pci.ids
  wget http://www.linux-usb.org/usb.ids -O usb.ids

Be sure you have installed php-cli, then write the following command:

  php insert_vendors.php

It will fill the 'vendors' MySql table.

== Learn the EasyGiant PHP framework ==

Since h-source is an application of the EasyGiant PHP framework you can use the EasyGiant features in order to modify the h-source source code. Visit www.easygiant.org (archived at http://web.archive.org/web/20161027164429/http://www.easygiant.org/).

You may find a guide to EasyGiant at http://www.easygiant.org/media/guide/20150326.pdf (archived at http://web.archive.org/web/20161027162658/http://www.easygiant.org/media/guide/20150326.pdf).


<!-- NOTE: this file is legal mediawiki syntax -->

<!-- LICENSE
  h-source, a web software to build a community of people that want to share their hardware information.

  Copyright (C) 2010  Antonio Gallo (h-source-copyright.txt)
  Copyright (C) 2022 bill-auger <h-source-users@nongnu.org>

  This file is part of h-source

  h-source 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
  (at your option) any later version.

  h-source 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 h-source.  If not, see <http://www.gnu.org/licenses/>.
-->