FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
#!/usr/local/bin/php -f <?php /* rc.initial.install part of FreeNAS (http://freenas.org) Copyright (C) 2005-2009 Olivier Cochard-Labbe <olivier@freenas.org>. All rights reserved. Based on m0n0wall (http://m0n0.ch/wall) Copyright (C) 2003-2007 Manuel Kasper <mk@neon1.net>. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ require_once("config.inc"); require_once("functions.inc"); require_once("install.inc"); require_once("util.inc"); require_once("tui.inc"); // Get product information $productname = get_product_name(); // Display information $text = <<<EOD {$productname} 'embedded' installer for Flash device or HDD. - Create 1 partition for OS image - Uses a RAM disk to limit read/write access to the device WARNING: There will be some limitations: 1. This will erase ALL partitions and data on the destination disk 2. You can't use your destination disk for sharing data Installing on USB key is the preferred way: It saves you an IDE or SCSI channel for more hard drives. EOD; $result = tui_display_message_ex("{$productname} installation", $text, 74, 17); if (0 != $result) exit(0); // Detect hardware $cdlist = get_cdrom_list(); $disklist = get_physical_disks_list(); if (0 == count($cdlist)) { tui_wait_keypress("Failed to detect any CDROM."); exit(0); } // Display installation medias $amenuitem = array(); foreach ($cdlist as $cdromk => $cdromv) { $menuitem = array(); $menuitem['tag'] = $cdromk; $menuitem['item'] = $cdromv['desc']; $amenuitem[] = $menuitem; } $result = tui_display_menu("Choose installation media", "Select CD/DVD drive for installation.", 60, 10, 6, $amenuitem, $cdrom); if (0 != $result) exit(0); // Display destination medias $amenuitem = array(); foreach ($disklist as $diskk => $diskv) { $menuitem = array(); $menuitem['tag'] = $diskk; $menuitem['item'] = "{$diskv['size']} <{$diskv['desc']}>"; $amenuitem[] = $menuitem; } $result = tui_display_menu("Choose destination media", "Select media where {$productname} OS should be installed.", 60, 14, 10, $amenuitem, $harddrive); if (0 != $result) exit(0); // Check if destination drive is mounted if (disks_ismounted_ex($harddrive, "mdisk")) { tui_wait_keypress("The destination drive is already in usage!"); exit(0); } if (install_mount_cd($cdrom)) { tui_wait_keypress("There was a problem while mounting the CDROM."); exit(0); } if (install_dd_image($harddrive)) { install_unmount_cd(); tui_wait_keypress("There was a problem while copying files."); exit(0); } install_unmount_cd(); // Display final message $text = <<<EOD {$productname} has been installed on {$harddrive}. You can now remove the CDROM and reboot the PC. EOD; tui_wait_keypress($text); ?>