diff --git a/validate.php b/validate.php index 2c03165876..6e0405fbc9 100755 --- a/validate.php +++ b/validate.php @@ -52,6 +52,12 @@ else { print_fail('Syntax error in config.php'); } +// Check we are running this as the root user +$username = getenv('USERNAME') ?: getenv('USER');//http://php.net/manual/en/function.get-current-user.php +if ($username !== 'root') { + print_fail("You need to run this script as root"); +} + // load config.php now require_once 'includes/defaults.inc.php'; require_once 'config.php'; @@ -59,6 +65,27 @@ require_once 'includes/definitions.inc.php'; require_once 'includes/functions.php'; require_once $config['install_dir'].'/includes/alerts.inc.php'; +// Check php modules we use to make sure they are loaded +$extensions = array('pcre','curl','session','snmp','mcrypt'); +foreach ($extensions as $extension) { + if (extension_loaded($extension) === false) { + $missing_extensions[] = $extension; + } +} +if (!empty($missing_extensions)) { + print_fail("We couldn't find the following php extensions, please ensure they are installed:"); + foreach ($missing_extensions as $extension) { + echo "$extension\n"; + } +} + +if (class_exists('Net_IPv4') === false) { + print_fail("It doesn't look like Net_IPv4 is installed"); +} +if (class_exists('Net_IPv6') === false) { + print_fail("It doesn't look like Net_IPv6 is installed"); +} + // Let's test the user configured if we have it if (isset($config['user'])) { $tmp_user = $config['user']; @@ -77,6 +104,9 @@ if (isset($config['user'])) { } } } +else { + print_warn('You don\'t have $config["user"] set, this most likely needs to be set to librenms'); +} // Run test on MySQL $test_db = @mysqli_connect($config['db_host'], $config['db_user'], $config['db_pass'], $config['db_name']);