Menu

[r799]: / trunk / etc / rc.initial.install2  Maximize  Restore  History

Download this file

125 lines (99 with data), 4.0 kB

#!/usr/local/bin/php -f
<?php
/*
	rc.initial.install
	part of FreeNAS (http://www.freenas.org)
	Copyright (C) 2005-2007 Olivier Cochard-Labbé <olivier@freenas.org>.
	All rights reserved.
	
	Based on m0n0wall (http://m0n0.ch/wall)
	Copyright (C) 2003-2006 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.
*/
	/* parse the configuration and include all functions used below */
	require_once("config.inc");
	require_once("functions.inc");
	require_once("install.inc");

	/* Get product information */
	$productname = get_product_name();

	$fp = fopen('php://stdin', 'r');
	
	$cdlist = get_cdrom_list();
	$disklist = get_physical_disks_list();
	
	echo "Two Partition Install\n";
	echo "Creates two partitions on the boot disk\n:";
	echo "Installs {$productname} on (small) partition 1 and creates and formats partition 2 for DATA\n";
	echo "\nWARNING: This WILL erase ALL your partitions and data on the destination hard drive!\n";
	echo "\nWARNING: You can't install {$productname} if it's already installed on a drive (Use upgrade from Web GUI)\n";
	echo "\nHere is the list of detected CDROM:\n";
	
	foreach ($cdlist as $cdromk =>$cdromv) 	{
		echo "$cdromk (desc: {$cdromv['desc']})\n";
	}
	
	do {
		echo "\nEnter the name of the CD-ROM drive: ";
		$cdrom = chop(fgets($fp));
		if ($cdrom === "") {
			exit(0);
		}
	} while (!is_validaliasname($cdrom));

	echo "Here is the list of detected disks:\n";

	foreach ($disklist as $diskk => $diskv) 	{
		echo "$diskk (desc: {$diskv['desc']})\n";
	}
	
	do {
		echo "\nEnter the name of the Hard Drive: ";
		$harddrive = chop(fgets($fp));
		if ($harddrive === "") {
			exit(0);
		}
	} while (!is_validaliasname($harddrive));
	
	/* check if destination drive is mounted */
	if (disks_check_mount($harddrive)) 	{
		echo "\nYour destination drive is already used!\n";
		fgets($fp);
		exit(0);
	}

	if(install_mount_cd($cdrom)) {
		echo "\nThere is a problem mounting the CDROM.\n";
		fgets($fp);
		exit(0);
	}
	
	if(install_init_halfdisk($harddrive)) {
		echo "\nThere is a problem for initializing the destination disk.\n";
		install_unmount_cd();
		exit(0);
	}
	
	$installharddrive = "$harddrive" . "s1";
	if(install_dd_image($installharddrive)) {
		echo "\nThere is a problem during file copying.\n";
		install_unmount_cd();
		exit(0);
	}
	
	install_unmount_cd();
	
	echo <<<EOD
	
{$productname} has been installed on $installharddrive.
You can now remove the CD-ROM and reboot the PC.

To use the DATA partition:
1. Add the disk $harddrive on the Disks: Management page
2. Add the mount point on the Disks: Mount point page
(disk: $harddrive, partition 2, Filesystem: UFS)
DO NOT format the $harddrive drive! The data partition has been formatted for you as part of the installation!

Press ENTER to continue.

EOD;

	fgets($fp);
?>
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.