Menu

[r10367]: / branches / 0.7exp / etc / rc.initial.embupgfromcdrom  Maximize  Restore  History

Download this file

123 lines (101 with data), 3.9 kB

#!/usr/local/bin/php -f
<?php
/*
	rc.initial.upgfromcdrom
	part of FreeNAS (http://www.freenas.org)
	Copyright (C) 2005-2008 Olivier Cochard-Labbe <olivier@freenas.org>.
	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

This will upgrade your current installation to the latest version.

EOD;
$result = tui_display_message_ex("{$productname} upgrade", $text, 70, 7);
if (0 != $result)
	exit(0);

// Search where the config file is installed
if (0 != install_detect_installation("embedded", $devinfo)) {
	tui_wait_keypress("No 'embedded' installation detected!");
	exit(0);
}

$result = tui_display_yesno("{$productname} has been detected on device '{$devinfo['device']}{$devinfo['partition']}'.\n\nIs this is correct?", 50, 7);
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);

if (install_mount_cd($cdrom)) {
	tui_wait_keypress("There was a problem while mounting the CDROM.");
	exit(0);
}

if (install_backup_config("{$devinfo['device']}{$devinfo['partition']}")) {
	install_unmount_cd();
	tui_wait_keypress("There was a problem during configuration file backup.");
	exit(0);
}

// Must install on ad0s1 if installed on partition 1, but install on ad0 if installed on ad0a.
if ("s1" === $devinfo['partition']) {
	if (install_dd_image("{$devinfo['device']}{$devinfo['partition']}")) {
		install_unmount_cd();
		tui_wait_keypress("There was a problem while copying files.");
		exit(0);
	}
}	else {
	if (install_dd_image($devinfo['device'])) {
		install_unmount_cd();
		tui_wait_keypress("There was a problem while copying files.");
		exit(0);
	}
}

if (install_restore_config("{$devinfo['device']}{$devinfo['partition']}")) {
	install_unmount_cd();
	tui_wait_keypress("There was a problem while restoring configuration file.");
	exit(0);
}

install_unmount_cd();

// Display final message
$text = <<<EOD

{$productname} installed on device '{$devinfo['device']}{$devinfo['partition']}' has been upgraded.
You can remove the CDROM and reboot the PC now.
EOD;

tui_wait_keypress($text);
?>
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.