Distributing Scripts¶
Debian/Ubuntu¶
To distribute scripts across multiple Debian/Ubuntu machines, or
containers, or virtual machines, it may be handy to create a deb
package containing the sources of one or more scripts. The package
only have to install script sources under
/usr/share/ntopng/scripts/scripts/
, which is the default
directory ntopng uses to load them.
A skeleton for a deb
package ready to distribute scripts is available
on GitHub.
The skeleton can be used to create a minimal .deb
file. It is
suitable to produce a .deb
for personal use but it may not be
stringent enough if the package needs to be included in official Debian /
Ubuntu repositories. Comprehensive instructions and rules can be found
in the Debian New Maintainer’s Guide and in the Ubuntu Packaging
Guide.
Example¶
The following example shows how to create a deb
package to distribute the
example scripts Blacklisted Flows and Flow Flooders.
First of all, download the skeleton contents. in
a local directory, say ntopng-scripts
.
The tree of the skeleton is quite simple:
ntopng-scripts/
|-- DEBIAN
| |-- README.source
| `-- control
`-- usr
`-- share
`-- ntopng
`-- scripts
`-- scripts
The root directory ntopng-scripts
contains two
sub-directories, namely DEBIAN
and
usr/share/ntopng/scripts/scripts/
.
Sub-directory DEBIAN
contains a README file which just points
to this documentation, and a control
file which is basically a
descriptor
of the package. This file lists package dependencies, maintainer,
version, name and other information. Change it to make sure it fits
your needs.
The other Sub-directory usr/share/ntopng/scripts/scripts/
is
just the path which will be used by the package installer to place
the files in the destination system during package installation. Place
in this sub-directory the scripts to be installed.
To distribute Blacklisted Flows and Flow Flooders, copy
their whole script directories under ntopng-scripts
package
sub-directory usr/share/ntopng/scripts/scripts/
. After the
copy, the final structure of the package directory ntopng-scripts
becomes
ntopng-scripts/
|-- DEBIAN
| |-- README.source
| `-- control
`-- usr
`-- share
`-- ntopng
`-- scripts
`-- scripts
|-- blacklisted
| |-- alert_definitions
| | `-- alert_flow_blacklisted.lua
| |-- manifest.lua
| |-- status_definitions
| | `-- status_blacklisted.lua
| `-- checks
| `-- flow
| `-- blacklisted.lua
`-- flow_flood
|-- alert_definitions
| `-- alert_flows_flood.lua
|-- manifest.lua
`-- checks
|-- host
| |-- flow_flood_attacker.lua
| `-- flow_flood_victim.lua
`-- network
`-- flow_flood_victim.lua
Now everything is ready and setup for the actual creation of the
deb
. Just jump in the directory which contains
ntopng-scripts/
and type the following
$ dpkg-deb --build ntopng-scripts
This will product a .deb
file ntopng-scripts.deb
ready
to be distributed on a repository or manually installed with
$ dpkg -i ntopng-scripts.deb