diff --git a/etc/ecl.php b/etc/ecl.php new file mode 100755 index 0000000000..f55b615235 --- /dev/null +++ b/etc/ecl.php @@ -0,0 +1,110 @@ +/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"; + +?> \ No newline at end of file diff --git a/etc/rc b/etc/rc index ab1b46092c..88813f5597 100755 --- a/etc/rc +++ b/etc/rc @@ -342,6 +342,21 @@ cap_mkdb /etc/login.conf # /usr/local/etc/php.ini and /usr/local/lib/php.ini /etc/rc.php_ini_setup +# Launch external configuration loader for supported platforms +if [ "$PLATFORM" = "embedded" ]; then + /etc/ecl.php +fi + +# Launch external configuration loader for supported platforms +if [ "$PLATFORM" = "nanobsd" ]; then + /etc/ecl.php +fi + +# Launch external configuration loader for supported platforms +if [ "$PLATFORM" = "pfSense" ]; then + /etc/ecl.php +fi + nohup /usr/bin/nice -n20 /usr/local/sbin/check_reload_status # let the PHP-based configuration subsystem set up the system now