Italiano English
Modifica History Actions

Differenze per "InstallNodeshot"

Differenze tra le versioni 1 e 13 (in 12 versioni)
Versione 1 del 2012-03-30 17:45:41
Dimensione: 4077
Autore: 147
Commento: creata by nemesis
Versione 13 del 2012-08-05 16:42:31
Dimensione: 7230
Autore: Nemesis
Commento: light improvements
Le cancellazioni sono segnalate in questo modo. Le aggiunte sono segnalate in questo modo.
Linea 4: Linea 4:
Requirements The code is on github: [[https://github.com/ninuxorg/nodeshot|https://github.com/ninuxorg/nodeshot]]

== Requirements ==
Linea 7: Linea 9:
* Linux OS
* Python > 2.5
* Django > 1.4 (GenericIPAddressField for IPV6 was added in 1.4)
* Web server (eg: apache, nginx) - alternatively you can use the django development server (for development production only)
* d
atabase (mysql, postgresql, sqlite3 and others :: see setting.example.py)
 * Linux OS
 * Python > 2.5
 * Django > 1.4 (GenericIPAddressField for IPV6 was added in 1.4)
 * Web server (eg: apache, nginx), alternatively you can use the django development server (for development only)
 * D
atabase (mysql, postgresql, sqlite3 and others, see setting.example.py)
Linea 13: Linea 15:
Installing Django == Installing Django ==
Linea 17: Linea 19:
In a production environment you must setup a VIRTUAL HOST in your webserver and to enable MOD_PYTHON or MOD_WSGI in order to get Nodeshot to work. That's also out of the scope of this guide because the way you want to do that might vary depending on distribution, habits, ecc.  In a production environment you must setup a VIRTUAL HOST in your webserver and to enable MOD_PYTHON or MOD_WSGI in order to get Nodeshot to work. That's also out of the scope of this guide because the way you want to do that might vary depending on distribution, habits, ecc.
Linea 21: Linea 23:
{{{
Linea 28: Linea 31:
}}}
Linea 30: Linea 34:

== Where do I place the code? ==

Django applications are not PHP code, they don't need to be put in the public folder of the virtualhost. Infact it is better to store them in a folder which is not accessible from HTTP.

An example of common structure is the following:

{{{
  # media files (javascript, css, ecc)
  /var/www/mapserver/public_html
      ./media
          ./css
          ./js
          ./images
  # django code
  /var/www/mapserver/code/
       settings.py
       .. eccetera ..
}}}

== Install nodeshot ==
Linea 34: Linea 59:
2. rename the folder created by git with a different name than "nodeshot" (this prevents python in getting confused on some systems), eg: mapserver 2. '''On some systems it might be necessary to rename the folder''' created by git with a different name than "nodeshot" (eg: mapserver) because otherwise python might not be able to distinguish between the real python application and the container folder.
Linea 36: Linea 61:
mv nodeshot mapserver {{{
$
mv nodeshot mapserver
}}}
Linea 38: Linea 65:
cd mapserver More info about this issue here: [[https://github.com/ninuxorg/nodeshot/issues/85|https://github.com/ninuxorg/nodeshot/issues/85]]
Linea 40: Linea 67:
3. Create the database for nodeshot 3. '''Create the database for nodeshot'''
Linea 45: Linea 73:
mysql -uroot -pNodeshotpassword mysql -u root -p Nodeshotpassword
Linea 47: Linea 75:
sqlite3 doesn't need you to create anydatabase, indicate the absolute path were you want django to create the file  Sqlite3: doesn't need you to create anydatabase, indicate the absolute path were you want django to create the file
Linea 51: Linea 79:
a) Create settings.py by copying settings.example.py with the following command line
cp settings.example.py settings.py
b) Edit the settings example
edit setting.py

a) Create settings.py by copying settings.example.py with the following command:
{{{
$
cp settings.example.py settings.py
}}}

b) Edit the settings file following the instructions in the comments and according to your needs
Linea 66: Linea 98:
NODESHOT_FRONTEND_SETTINGS
    
META_ROBOTS: this indicates if you want Google to index your map-server or not. Possible choices are the ones indicated here http://googlewebmastercentral.blogspot.com/2007/03/using-robots-meta-tag.html
    SHOW_STATISTICS: boolean that indicates if you want to show the number of active nodes, potential nodes, hotspots, links and total link surface on the website
    SHOW_KML_LINK: this indicates if you want to show the KML feed icon and link
    HELP_URL: set up an URL on your website to explain how to use the map-server or whatever you need to tell to your users (this might change in the future, maybe is better to ship some instrctions with the core code)
'''NODESHOT_FRONTEND_SETTINGS''':

META_ROBOTS: this indicates if you want Google to index your map-server or not. Possible choices are the ones indicated here http://googlewebmastercentral.blogspot.com/2007/03/using-robots-meta-tag.html

SHOW_STATISTICS: boolean that indicates if you want to show the number of active nodes, potential nodes, hotspots, links and total link surface on the website

SHOW_KML_LINK: this indicates if you want to show the KML feed icon and link

HELP_URL: set up an URL on your website to explain how to use the map-server or whatever you need to tell to your users (this might change in the future, maybe is better to ship some instrctions with the core code)
Linea 73: Linea 109:
{{{
Linea 74: Linea 111:
this command creates the SQL tables and asks you to }}}
this command creates the necessary SQL tables.
Linea 76: Linea 114:
6. '''the previous command might fails if you miss some python libraries'''. If this happens you must install these libraries in order to proceed.
Linea 77: Linea 116:
Some common missing libraries are:
Linea 78: Linea 118:
* '''MySQLdb''' - fix with "apt-get install python-mysqldb" (depends on your distribution)
Linea 79: Linea 120:
http://176.31.121.62/admin
If not working, try this command with mapserver as working directory
== Media files ==

If you use apache you must link the folder that contains the static files (css, images, js) in your apache public folder.
Example:

{{{
$ ln -s /home/user/you/mapserver/nodeshot/media /var/www/mapserver/public_html/media
}}}

TODO: might miss some cases

== Admin media files ==

If you go to <YOUR_URL>/admin/ you will notice that the static files (css, images and javascript) for the admin interface are missing. Infact those files are stored in the django framework. You can either copy or link those files, but we strongly advise to use a symbolic link because when you will update django to a newer version the static admin files will also get updated automatically.

Example:
{{{
ln -s <DJANGO-INSTALLATION-DIR>/contrib/admin/static/admin <PUBLIC-DIR>/media/admin
}}}

Substitute <DJANGO-INSTALLATION-DIR> with the path to the directory where django is installed and <PUBLIC-DIR> with the path to the directory of your server which is reachable from public HTTP.

== Troubleshooting ==

If you get errors for missing libraries you will need to install them.
You can install python libraries either with your package manager or with easy_install / pip_install. This depends on your linux distribution.

If the admin interface in {PROJECT_URL}/admin is not working, try to run this command from the working directory of the code:
{{{
Linea 82: Linea 150:
}}}

== Setup the Cronjobs ==

There are two cronjobs to setup for nodeshot:

 1. nodeshot/scripts/read_topology_hna.py
 2. nodeshot/scripts/snmp.py

There is one problem though: these scripts have been written for the ninux network and might not work for your network or need additional work.
You could either make new scripts that suits your network or you could help us in improving the actual scripts in order to make them work both on our network and yours. The choice is up to you, the important thing is that there's somebody in your network who is able to program in python and can help out.

Nodeshot is an easy to use Wireless Community MapServer made by the Ninux Community. One instance can be find on their website. It's based on Django. This page aims at providing a tutorial on how to install an instance of this software.

The code is on github: https://github.com/ninuxorg/nodeshot

Requirements

Before starting the installation be sure to have a server ready with the following software:

  • Linux OS
  • Python > 2.5

  • Django > 1.4 (GenericIPAddressField for IPV6 was added in 1.4)

  • Web server (eg: apache, nginx), alternatively you can use the django development server (for development only)
  • Database (mysql, postgresql, sqlite3 and others, see setting.example.py)

Installing Django

Installing django is out of the scope of this document, for that please check the official django documentation: https://docs.djangoproject.com/en/1.4/intro/install/ . We advise to install the latest development version from svn or git so it's easy to upgrade.

In a production environment you must setup a VIRTUAL HOST in your webserver and to enable MOD_PYTHON or MOD_WSGI in order to get Nodeshot to work. That's also out of the scope of this guide because the way you want to do that might vary depending on distribution, habits, ecc.

if you use mod_wsgi this is the code you need to get it to work (create a file caled wsgi.py):

import os
import sys
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


Where do I place the code?

Django applications are not PHP code, they don't need to be put in the public folder of the virtualhost. Infact it is better to store them in a folder which is not accessible from HTTP.

An example of common structure is the following:

  # media files (javascript, css, ecc)
  /var/www/mapserver/public_html
      ./media
          ./css
          ./js
          ./images
  # django code
  /var/www/mapserver/code/
       settings.py
       .. eccetera ..

Install nodeshot

1. Choose the folder where you want to store the code of the project and clone the git repository with: git clone https://github.com/ninuxorg/nodeshot.git

2. On some systems it might be necessary to rename the folder created by git with a different name than "nodeshot" (eg: mapserver) because otherwise python might not be able to distinguish between the real python application and the container folder.

$ mv nodeshot mapserver

More info about this issue here: https://github.com/ninuxorg/nodeshot/issues/85

3. Create the database for nodeshot

if using mysql or postgresql create a new database in the web admin tool or via command line

MySQL: Set up a database for MySQL for the root user and a password e.g. "Nodeshotpassword"

mysql -u root -p Nodeshotpassword

Sqlite3: doesn't need you to create anydatabase, indicate the absolute path were you want django to create the file for example "/home/USER/mapserver/nodeshot.db"

4. Then edit the settings of nodeshot in the nodeshot folder.

a) Create settings.py by copying settings.example.py with the following command:

$ cp settings.example.py settings.py

b) Edit the settings file following the instructions in the comments and according to your needs

c) Fill in the following database information

set TIME_ZONE to your area set LANGUAGE_CODE to your language set SITE_URL to your URL (localhost if in development environment) set NODESHOT_GMAP_CENTER, change the coordinates of the center of the map to your area set NODESHOT_SITE (name and domain) edit NODESHOT_KML['description'] to a description that suits your community (optional) edit NODESHOT_ROUTING_PROTOCOLS and choose the ones that are used in your network set NODESHOT_DEFAULT_ROUTING_PROTOCOL to the prefered choice

NODESHOT_FRONTEND_SETTINGS:

META_ROBOTS: this indicates if you want Google to index your map-server or not. Possible choices are the ones indicated here http://googlewebmastercentral.blogspot.com/2007/03/using-robots-meta-tag.html

SHOW_STATISTICS: boolean that indicates if you want to show the number of active nodes, potential nodes, hotspots, links and total link surface on the website

SHOW_KML_LINK: this indicates if you want to show the KML feed icon and link

HELP_URL: set up an URL on your website to explain how to use the map-server or whatever you need to tell to your users (this might change in the future, maybe is better to ship some instrctions with the core code)

5. create the database structure

$ python manage.py syncdb

this command creates the necessary SQL tables.

6. the previous command might fails if you miss some python libraries. If this happens you must install these libraries in order to proceed.

Some common missing libraries are:

* MySQLdb - fix with "apt-get install python-mysqldb" (depends on your distribution)

Media files

If you use apache you must link the folder that contains the static files (css, images, js) in your apache public folder. Example:

$ ln -s /home/user/you/mapserver/nodeshot/media /var/www/mapserver/public_html/media

TODO: might miss some cases

Admin media files

If you go to <YOUR_URL>/admin/ you will notice that the static files (css, images and javascript) for the admin interface are missing. Infact those files are stored in the django framework. You can either copy or link those files, but we strongly advise to use a symbolic link because when you will update django to a newer version the static admin files will also get updated automatically.

Example:

ln -s <DJANGO-INSTALLATION-DIR>/contrib/admin/static/admin <PUBLIC-DIR>/media/admin

Substitute <DJANGO-INSTALLATION-DIR> with the path to the directory where django is installed and <PUBLIC-DIR> with the path to the directory of your server which is reachable from public HTTP.

Troubleshooting

If you get errors for missing libraries you will need to install them. You can install python libraries either with your package manager or with easy_install / pip_install. This depends on your linux distribution.

If the admin interface in {PROJECT_URL}/admin is not working, try to run this command from the working directory of the code:

sudo chown www-data. .

Setup the Cronjobs

There are two cronjobs to setup for nodeshot:

  1. nodeshot/scripts/read_topology_hna.py
  2. nodeshot/scripts/snmp.py

There is one problem though: these scripts have been written for the ninux network and might not work for your network or need additional work. You could either make new scripts that suits your network or you could help us in improving the actual scripts in order to make them work both on our network and yours. The choice is up to you, the important thing is that there's somebody in your network who is able to program in python and can help out.