From fbc9178d1d2e221290e19c3b7a639a17c81e01f4 Mon Sep 17 00:00:00 2001 From: laf Date: Wed, 15 Jan 2014 02:51:25 +0000 Subject: [PATCH] New web based installer to simplify installation install.php will now redirect and exit if config.php exists Updated install docs --- build-base.php | 11 +- build.sql | 1 - doc/INSTALL.md | 3 + doc/INSTALL_RHEL.md | 4 + html/index.php | 7 + html/install.php | 542 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 563 insertions(+), 5 deletions(-) create mode 100644 html/install.php diff --git a/build-base.php b/build-base.php index 99f23a0f3c..fc008c5b97 100644 --- a/build-base.php +++ b/build-base.php @@ -2,16 +2,19 @@ include( "config.php" ); -$sql_file = 'build.sql'; +$sql_file = $sqlfile ?: 'build.sql'; $sql_fh = fopen( $sql_file, 'r' ); $connection = mysql_connect( $config['db_host'], $config['db_user'], $config['db_pass'] ); mysql_select_db( $config['db_name'] ); while( !feof( $sql_fh ) ) { $line = fgetss( $sql_fh ); - $creation = mysql_query( $line ); - if( !$creation ) { - echo( mysql_error() . "\n" ); + if(!empty($line)) + { + $creation = mysql_query( $line ); + if( !$creation ) { + echo( mysql_error() . "\n" ); + } } } diff --git a/build.sql b/build.sql index f51435b1e9..a4b3897b9c 100644 --- a/build.sql +++ b/build.sql @@ -1,4 +1,3 @@ -USE librenms; CREATE TABLE IF NOT EXISTS `alerts` ( `id` int(11) NOT NULL AUTO_INCREMENT, `importance` int(11) NOT NULL DEFAULT '0', `device_id` int(11) NOT NULL, `message` text NOT NULL, `time_logged` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `alerted` smallint(6) NOT NULL DEFAULT '0', KEY `id` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `applications` ( `app_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `app_type` varchar(64) NOT NULL, PRIMARY KEY (`app_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `authlog` ( `id` int(11) NOT NULL AUTO_INCREMENT, `datetime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `user` text NOT NULL, `address` text NOT NULL, `result` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/doc/INSTALL.md b/doc/INSTALL.md index d998e551d7..b472307a44 100644 --- a/doc/INSTALL.md +++ b/doc/INSTALL.md @@ -44,6 +44,9 @@ You can clone the repository via HTTPS or SSH. In either case, you need to ensu cd /opt git clone https://github.com/librenms/librenms.git librenms cd /opt/librenms + +At this stage you can either launch the web installer by going to http://IP/install.php, follow the onscreen instructions then skip to the 'Web Interface' section further down. Alternatively if you want to continue the setup manually then just keep following these instructions. + cp config.php.default config.php vim config.php diff --git a/doc/INSTALL_RHEL.md b/doc/INSTALL_RHEL.md index 2564d823a7..ff4b3db08a 100644 --- a/doc/INSTALL_RHEL.md +++ b/doc/INSTALL_RHEL.md @@ -56,6 +56,10 @@ You can clone the repository via HTTPS or SSH. In either case, you need to ensu cd /opt git clone https://github.com/librenms/librenms.git librenms cd /opt/librenms + +At this stage you can either launch the web installer by going to http://IP/install.php, follow the onscreen instructions then skip to the 'Web Interface' section further down. Alternatively if you want +to continue the setup manually then just keep following these instructions. + cp config.php.default config.php vim config.php diff --git a/html/index.php b/html/index.php index 78643f8f01..b2c3bb178e 100755 --- a/html/index.php +++ b/html/index.php @@ -18,6 +18,13 @@ include_once("../includes/definitions.inc.php"); include("../includes/functions.php"); include("includes/functions.inc.php"); +// Check for install.inc.php +if (!file_exists('../config.php') && $_SERVER['PATH_INFO'] != '/install.php') { + // no config.php does so let's redirect to the install + header('Location: /install.php'); + exit; +} + $runtime_start = utime(); ob_start(); diff --git a/html/install.php b/html/install.php new file mode 100644 index 0000000000..0cb351f3b1 --- /dev/null +++ b/html/install.php @@ -0,0 +1,542 @@ + + + + + + <?php echo($config['page_title_prefix']); ?> + + + + + + + + + + + + + + + + +
+
+
+
+
+

Welcome to the install

+
+
+
+
+
+
+
+
+

Stage of complete

+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+ % Complete +
+
+
+
+
+
+ + + +
+
+
+
+
Checking PHP module support
+
+
+
+
+
+
+
+
+ + + + + + + + + "); + if($ext_loaded == 'no') + { + echo(""); + } + else + { + echo(""); + } + echo(""); +} + +// Check for pear install +require_once 'System.php'; +if(class_exists('System')===true) +{ + $ext_loaded = 'yes'; + $row_class = 'success'; +} +else +{ + $ext_loaded = 'yes'; + $row_class = 'danger'; +} + +echo(" + + "); +if($ext_loaded == 'no') +{ + echo(""); +} +else +{ + echo(""); +} + echo(""); +?> +
ModuleInstalledComments
$extension$ext_loadedapt-get install php5-$extension / yum install php-$extension
pear$ext_loadedapt-get install php5-$extension / yum install php-$extension
+
+
+
+
+
+
+
+
+
+ + +
+
+
+
+
+ + + +
+
+
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+ + +
+
+
+
+
Importing MySQL DB
+ +
+
+
+
+
+
+
+
+ If you don't see any errors or messages above then the database setup has been successful.
+
+ + + + + + +
+
+
+
+
+ +
+
+
+
+ +EOD; + + if(!file_exists("../config.php")) + { + $conf = fopen("../config.php", 'w'); + if ($conf === false) + { + if(fwrite($handle, 'We couldn't create the config.php file, please create this manually before continuing by copying the below into a config.php in the root directory of your install (typically /opt/librenms/)
"); + echo("
<?php\n".stripslashes($config_file)."
"); + } + else + { + $config_file = stripslashes($config_file); + fwrite($handle,$config_file); + echo("
The config file has been created
"); + } + } + } +?> +
+ + + + + + +
+ +
+
+
+
+ +
+
+
+
+
+ + + + + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+
+
+
+ +
+
+
+
+User has been added successfully
"); + $proceed = 0; + } + else + { + echo("
User hasn't been added, please try again
"); + } + } + else + { + echo("
User $add_user already exists!
"); + } + } + else + { + echo("
Auth module isn't loaded
"); + } + +?> +
+ + + + + + +
+
+
+
+ + +
+
+
+
+
Thank you for setting up LibreNMS, you can now click here to login to your new install.
+
+
+
+ + +
+ +