diff --git a/.gitignore b/.gitignore
index 975011ebe..4ebd6e7d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ config.php
logs
patches
rrd
+html/plugins/*
+!html/plugins/Test/
diff --git a/doc/Plugin_System.md b/doc/Plugin_System.md
new file mode 100644
index 000000000..3d0c41ce9
--- /dev/null
+++ b/doc/Plugin_System.md
@@ -0,0 +1,61 @@
+# Developing for the Plugin System
+
+This documentation will hopefully give you a basis for how to write a plugin for LibreNMS.
+
+A test plugin is available on GitHib: https://github.com/laf/Test
+
+Plugins need to be installed into html/plugins
+
+The structure of a plugin is follows:
+
+```
+html/plugins
+ /PluginName
+ /PluginName.php
+ /PluginName.inc.php
+```
+
+The above structure is checked before a plugin can be installed.
+
+All files / folder names are case sensitive and must match.
+
+PluginName - This is a directory and needs to be named as per the plugin you are creating.
+
+PluginName.php - This file is used to process calls into the plugin from the main LibreNMS install.
+ Here only functions within the class for your plugin that LibreNMS calls will be executed.
+ For a list of currently enabled system hooks, please see further down.
+ The minimum code required in this file is (replace Test with the name of your plugin):
+```
+
+```
+
+PluginName.inc.php - This file is the main included file when browsing to the plugin itself.
+ You can use this to display / edit / remove whatever you like.
+ The minimum code required in this file is:
+```
+
+```
+
+### System Hooks ###
+
+System hooks are called as functions within your plugin class, so for example to create a menu entry within the PLugin dropdown you would do:
+
+```
+ public function menu() {
+ echo('
'.get_class().'');
+ }
+```
+
+This would then add the name and a link to your plugin.
+
+The following system hooks are currently available:
+
+menu()
+* This is called to build the plugin menu system and you can use this to link to your plugin (you don't have to).
diff --git a/html/includes/plugins.inc.php b/html/includes/plugins.inc.php
new file mode 100644
index 000000000..5ca6ca718
--- /dev/null
+++ b/html/includes/plugins.inc.php
@@ -0,0 +1,68 @@
+
diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php
index d17f4082b..00833d53d 100644
--- a/html/includes/print-menubar.php
+++ b/html/includes/print-menubar.php
@@ -460,7 +460,25 @@ if ($packages)
+
+ Plugins
+
+
+
+
-
-Normal width');
-} else {
- echo(' Widescreen');
-}
-
-?>
-
System
');
+ }
+}
+
+?>
diff --git a/includes/definitions.inc.php b/includes/definitions.inc.php
index 795501410..4c2a1dd7a 100644
--- a/includes/definitions.inc.php
+++ b/includes/definitions.inc.php
@@ -1225,5 +1225,6 @@ if (!isset($config['html_dir'])) { $config['html_dir'] = $config['install_dir']
if (!isset($config['rrd_dir'])) { $config['rrd_dir'] = $config['install_dir'] . '/rrd'; }
if (!isset($config['log_dir'])) { $config['log_dir'] = $config['install_dir'] . '/logs'; }
if (!isset($config['log_file'])) { $config['log_dir'] . "/" . $config['project_id'] . ".log"; }
+if (!isset($config['plugin_dir'])) { $config['plugin_dir'] = $config['html_dir'] . '/plugins'; }
?>
diff --git a/includes/functions.php b/includes/functions.php
index a3db601e8..c6eefb8de 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -880,4 +880,40 @@ function is_port_valid($port, $device)
return $valid;
}
+function scan_new_plugins()
+{
+
+ global $config, $debug;
+
+ $installed = 0; // Track how many plugins we install.
+
+ if(file_exists($config['plugin_dir']))
+ {
+ $plugin_files = scandir($config['plugin_dir']);
+ foreach($plugin_files as $name)
+ {
+ if(is_dir($config['plugin_dir'].'/'.$name))
+ {
+ if($name != '.' && $name != '..')
+ {
+ if(is_file($config['plugin_dir'].'/'.$name.'/'.$name.'.php') && is_file($config['plugin_dir'].'/'.$name.'/'.$name.'.inc.php'))
+ {
+ $plugin_id = dbFetchRow("SELECT `plugin_id` FROM `plugins` WHERE `plugin_name` = '$name'");
+ if(empty($plugin_id))
+ {
+ if(dbInsert(array('plugin_name' => $name, 'plugin_active' => '0'), 'plugins'))
+ {
+ $installed++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return( $installed );
+
+}
+
?>
diff --git a/sql-schema/030.sql b/sql-schema/030.sql
new file mode 100644
index 000000000..5acc85c2e
--- /dev/null
+++ b/sql-schema/030.sql
@@ -0,0 +1 @@
+CREATE TABLE IF NOT EXISTS `plugins` ( `plugin_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `plugin_name` VARCHAR( 60 ) NOT NULL , `plugin_active` INT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1;