}
}
if ($new_install) {
    out("Creating Brand List Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_brand_list` (\n                  `id` varchar(11) NOT NULL,\n                  `name` varchar(255) NOT NULL,\n                  `directory` varchar(255) NOT NULL,\n                  `cfg_ver` varchar(255) NOT NULL,\n                  `installed` int(1) NOT NULL DEFAULT '0',\n                    `local` int(1) NOT NULL DEFAULT '0',\n                  `hidden` int(1) NOT NULL DEFAULT '0',\n                  PRIMARY KEY (`id`)\n                ) ENGINE=MyISAM DEFAULT CHARSET=latin1";
    $db->query($sql);
    out("Creating Line List Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_line_list` (\n  `luid` int(11) NOT NULL AUTO_INCREMENT,\n  `mac_id` int(11) NOT NULL,\n  `line` smallint(2) NOT NULL,\n  `ext` varchar(15) NOT NULL,\n  `description` varchar(20) NOT NULL,\n  `custom_cfg_data` longblob NOT NULL,\n  `user_cfg_data` longblob NOT NULL,\n  PRIMARY KEY (`luid`)\n) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;";
    $db->query($sql);
    out("Creating Global Variables Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_global_vars` (\n                  `idnum` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Index',\n                  `var_name` varchar(25) NOT NULL COMMENT 'Variable Name',\n                  `value` text NOT NULL COMMENT 'Data',\n                  PRIMARY KEY (`idnum`),\n                  UNIQUE KEY `var_name` (`var_name`)\n                ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=17";
    $db->query($sql);
    out("Locating NMAP + ARP + ASTERISK Executables");
    $nmap = find_exec("nmap");
    $arp = find_exec("arp");
    $asterisk = find_exec("asterisk");
    out("Inserting data into the global vars Table");
    $sql = "INSERT INTO `endpointman_global_vars` (`idnum`, `var_name`, `value`) VALUES\n            (1, 'srvip', ''),\n            (2, 'tz', ''),\n            (3, 'gmtoff', ''),\n            (4, 'gmthr', ''),\n            (5, 'config_location', '/tftpboot/'),\n            (6, 'update_server', 'http://mirror.freepbx.org/provisioner/'),\n            (7, 'version', '" . $version . "'),\n            (8, 'enable_ari', '0'),\n            (9, 'debug', '0'),\n            (10, 'arp_location', '" . $arp . "'),\n            (11, 'nmap_location', '" . $nmap . "'),\n            (12, 'asterisk_location', '" . $asterisk . "'),\n            (13, 'language', ''),\n            (14, 'check_updates', '0'),\n            (15, 'disable_htaccess', ''),\n            (16, 'endpoint_vers', '0'),\n            (17, 'disable_help', '0'),\n            (18, 'show_all_registrations', '0'),\n            (19, 'ntp', ''),\n            (20, 'server_type', 'file')";
    $db->query($sql);
    out("Creating mac list Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_mac_list` (\n  `id` int(10) NOT NULL AUTO_INCREMENT,\n  `mac` varchar(12) DEFAULT NULL,\n  `model` varchar(11) NOT NULL,\n  `template_id` int(11) NOT NULL,\n  `global_custom_cfg_data` longblob NOT NULL,\n  `global_user_cfg_data` longblob NOT NULL,\n  `config_files_override` text NOT NULL,\n  `global_settings_override` longblob,\n    `specific_settings` longblob,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `mac` (`mac`)\n) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
    $db->query($sql);
    out("Creating model List Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_model_list` (\n  `id` varchar(11) NOT NULL COMMENT 'Key ',\n  `brand` int(11) NOT NULL COMMENT 'Brand',\n  `model` varchar(25) NOT NULL COMMENT 'Model',\n  `max_lines` smallint(2) NOT NULL,\n  `template_list` text NOT NULL,\n  `template_data` longblob NOT NULL,\n  `product_id` varchar(11) NOT NULL,\n  `enabled` int(1) NOT NULL DEFAULT '0',\n  `hidden` int(1) NOT NULL DEFAULT '0',\n  PRIMARY KEY (`id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1";
    $db->query($sql);
    out("Creating oui List Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_oui_list` (\n          `id` int(30) NOT NULL AUTO_INCREMENT,\n          `oui` varchar(30) DEFAULT NULL,\n          `brand` int(11) NOT NULL,\n          `custom` int(1) NOT NULL DEFAULT '0',\n          PRIMARY KEY (`id`),\n          UNIQUE KEY `oui` (`oui`)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1";
    $db->query($sql);
    out("Creating product List Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_product_list` (\n  `id` varchar(11) NOT NULL,\n  `brand` int(11) NOT NULL,\n  `long_name` varchar(255) NOT NULL,\n  `short_name` varchar(255) NOT NULL,\n  `cfg_dir` varchar(255) NOT NULL,\n  `cfg_ver` varchar(255) NOT NULL,\n  `hidden` int(1) NOT NULL DEFAULT '0',\n  `firmware_vers` varchar(255) NOT NULL,\n  `firmware_files` text NOT NULL,\n  `config_files` text,\n  `special_cfgs` blob NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=MyISAM DEFAULT CHARSET=latin1";
    $db->query($sql);
Esempio n. 2
0
/**
 * Check for an executable and return the path to it
 * If it does not exist, run composer update.
 * If composer isn't installed, print error and exit.
 *
 * @param string $exec the name of the executable to check
 * @return string path to the executable
 */
function check_exec($exec)
{
    try {
        return find_exec($exec);
    } catch (Exception $e) {
        try {
            $composer_bin = find_exec(array('composer', 'composer.phar'));
            shell_exec("{$composer_bin} update");
            return find_exec($exec);
        } catch (Exception $ce) {
            echo "\nCould not find {$exec}. Please install composer.\nYou can find more info at http://docs.librenms.org/Developing/Validating-Code/\n";
            exit(1);
        }
    }
}