/dev/null"); // Next try regular fs (ufs) if(!$result) $result = exec("/sbin/mount /dev/{$disk} /tmp/mnt/cf 2>/dev/null"); if($result == "0") { // Item was mounted - look for config.xml file $config_location = discover_config($disk); if($config_location) { if(test_config($config_location)) { // We have a valid configuration. Install it. echo " -> found "; backup_config(); restore_backup($config_location); exec("/sbin/unount /tmp/mnt/cf"); break; } } } } } function discover_config($mountpoint) { global $g; $locations_to_check = array("/", "/conf", "/conf.default", "/config"); foreach($locations_to_check as $ltc) { $tocheck = "{$mountpoint}{$ltc}/config.xml"; if(file_exists($tocheck)) return $tocheck; } return ""; } function test_config($file_location) { global $g; // config.xml was found. ensure it is sound. $root_obj = $g['xml_rootobj']; $xml_file_head = trim(`/bin/cat {$file_location} | /usr/bin/head -n1`); if($xml_file_head == $root_obj) { // Now parse config to make sure $config_status = config_validate($file_location); if($config_status) return true; } return false; } echo "External config loader 1.0 is now starting..."; find_config_xml(); echo "\n"; ?>