home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2007 January, February, March & April
/
Chip-Cover-CD-2007-02.iso
/
boot
/
i386
/
root
/
usr
/
share
/
YaST2
/
modules
/
AutoInstall.ycp
< prev
next >
Wrap
Text File
|
2006-11-29
|
6KB
|
180 lines
/**
* File: modules/AutoInstall.ycp
* Package: Auto-installation
* Summary: Auto-installation related functions module
* Author: Anas Nashif <nashif@suse.de>
*
* $Id: AutoInstall.ycp 30346 2006-04-21 12:40:09Z ug $
*/
{
module "AutoInstall";
textdomain "autoinst";
import "Profile";
import "Mode";
import "Stage";
import "AutoinstConfig";
import "AutoInstallRules";
import "Report";
import "TFTP";
global boolean autoconf = false;
global define boolean callbackTrue() {
return true;
}
global define boolean callbackFalse() {
return false;
}
/**
* Read saved data in continue mode
* @return boolean true on success
*/
global define boolean Continue()
{
//
// First check if there are some other control files availabe
// i.e. for post-installation only
//
boolean ret = false;
if ( SCR::Read(.target.size, AutoinstConfig::autoconf_file) != -1 )
{
y2milestone("XML Post installation data found: %1", AutoinstConfig::autoconf_file );
ret = Profile::ReadXML ( AutoinstConfig::autoconf_file );
SCR::Execute(.target.bash, sformat("/bin/mv %1 %2",
AutoinstConfig::autoconf_file, AutoinstConfig::cache));
return (ret);
}
else
{
ret = Profile::ReadProfileStructure ( AutoinstConfig::parsedControlFile );
if ( Profile::current == $[] || !ret ) {
y2milestone( "No saved autoinstall data found" );
return (false);
} else {
y2milestone( "Found and read saved autoinst data");
SCR::Execute(.target.remove, AutoinstConfig::parsedControlFile);
return (true);
}
}
return false;
}
/**
* Constructer
* @return void
*/
global define void AutoInstall()
{
if (Stage::cont ())
{
boolean ret = Continue();
if (ret && size ( Profile::current ) > 0) {
y2milestone("Enabling Auto-Installation mode");
Mode::SetMode("autoinstallation");
} else if (Mode::autoinst ()) {
y2milestone("No autoyast data found, switching back to manual installation");
Mode::SetMode("installation");
}
}
else if (Stage::initial ())
{
if ( SCR::Read(.target.size, AutoinstConfig::xml_tmpfile) != -1
&& size ( Profile::current ) == 0)
{
y2milestone("autoyast: %1 found", AutoinstConfig::xml_tmpfile);
// Profile is available and it has not been parsed yet.
Profile::ReadXML( AutoinstConfig::xml_tmpfile );
}
}
return;
}
/**
* Save configuration
* @return boolean true on success
*/
global define boolean Save()
{
if (Mode::autoinst ())
return (Profile::SaveProfileStructure( AutoinstConfig::parsedControlFile ));
else
return true;
}
/**
* Finish Auto-Installation by saving misc files
* @param string destdir
* @return void
*/
global define void Finish ( string destdir )
{
list dircontents = (list)SCR::Read(.target.dir, AutoinstConfig::tmpDir
+ "/pre-scripts/");
if (size(dircontents) > 0 )
{
SCR::Execute(.target.bash, "/bin/cp " + AutoinstConfig::tmpDir
+ "/pre-scripts/* " + destdir + AutoinstConfig::scripts_dir);
SCR::Execute(.target.bash, "/bin/cp " + AutoinstConfig::tmpDir
+ "/pre-scripts/logs/* " + destdir + AutoinstConfig::logs_dir);
}
SCR::Execute(.target.bash, sformat("/bin/cp %1 %2%3",
AutoinstConfig::xml_tmpfile , destdir , AutoinstConfig::xml_file) );
SCR::Execute(.target.bash, sformat("/bin/chmod 700 %1%2",
destdir , AutoinstConfig::xml_file) );
return;
}
/**
* Put PXE file on the boot server using tftp
* @return true on success
*/
global boolean PXELocalBoot ()
{
string tmpdir = (string)SCR::Read(.target.tmpdir);
string hexfile = sformat("%1/%2", tmpdir, AutoInstallRules::hostid );
map pxe = Profile::current["pxe"]:$[];
string server = pxe["tftp-server"]:"";
if (server!="" && pxe["pxe_localboot"]:false)
{
y2milestone("putting pxe local boot file on server :%1", server);
string config = pxe["pxelinux-config"]:"";
string dir = pxe["pxelinux-dir"]:"pxelinux.cfg";
if (config == "")
{
config = "DEFAULT linux\nLABEL linux\n localboot 0";
}
SCR::Write(.target.string, hexfile, config);
return TFTP::Put(server, dir + "/" + AutoInstallRules::hostid,
hexfile );
}
return true;
}
/**
* Turn off the second stage of autoyast
*
*/
global boolean TurnOff () {
if( ! Profile::current["general","mode","second_stage"]:true ) {
y2milestone("switching from autoinstallation to manual installation in second stage");
SCR::Execute(.target.bash, "/bin/grep -v -i '^autoyast:' /etc/install.inf > /tmp/install.inf.new");
SCR::Execute(.target.bash, "/bin/mv /tmp/install.inf.new /etc/install.inf");
}
}
//EOF
}