summaryrefslogtreecommitdiffstats
path: root/abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp')
-rwxr-xr-xabs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp1179
1 files changed, 1179 insertions, 0 deletions
diff --git a/abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp b/abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp
new file mode 100755
index 0000000..ac72a0b
--- /dev/null
+++ b/abs/core/mythinstall/MythVantage-app/mythinstall/installdialog.cpp
@@ -0,0 +1,1179 @@
+#include <qapplication.h>
+//Added by qt3to4:
+#include <Q3TextStream>
+#include <unistd.h>
+#include <fstream>
+
+#include "mythcontext.h"
+//#include "tv.h"
+#include "uitypes.h"
+#include "installdialog.h"
+#include "installsettings.h"
+#include "installationtype.h"
+#include "mv_common.h"
+#include "mythprogressdialog.h"
+
+#include <stdlib.h>
+
+#include "mythversion.h"
+#include "mythsystemlegacy.h"
+
+#define UPDATE_STATUS_INTERVAL 5000
+#define UPDATE_SCREEN_INTERVAL 5000
+
+
+
+WelcomeDialog::WelcomeDialog(MythScreenStack *parent, const char *name)
+ :MythScreenType(parent, name),
+ m_status_text(NULL), m_recording_text(NULL), m_scheduled_text(NULL),
+ m_time_text(NULL), m_date_text(NULL),
+ m_menuPopup(NULL), m_mv_text(NULL)
+
+{
+// system("rm -f /tmp/.install_state");
+// system("rm -f /tmp/.install_percent");
+// system("rm -f /tmp/.install_error");
+ install_drive = "" ;
+ recording_text = "";
+ scheduled_text = "";
+ install_text = "";
+ version_text = "";
+ I_AM_BUSY = false;
+ WORKING_ON_INSTALL = false;
+ current_hostname = "";
+
+ gCoreContext->addListener(this);
+ m_timeFormat = gCoreContext->GetSetting("TimeFormat", "h:mm AP");
+
+ m_updateStatusTimer = new QTimer(this);
+ connect(m_updateStatusTimer, SIGNAL(timeout()), this,
+ SLOT(updateStatus()));
+ m_updateStatusTimer->start(UPDATE_STATUS_INTERVAL);
+
+ m_updateScreenTimer = new QTimer(this);
+ connect(m_updateScreenTimer, SIGNAL(timeout()), this,
+ SLOT(updateScreen()));
+
+ m_timeTimer = new QTimer(this);
+ connect(m_timeTimer, SIGNAL(timeout()), this,
+ SLOT(updateTime()));
+ m_timeTimer->start(1000);
+
+ reboot_box = NULL;
+ m_menuPopup = NULL;
+ //QTimer::singleShot(6000, this, showPopup());
+
+ // JM
+ QTimer::singleShot(1000, this, SLOT(showPopup()));
+
+}
+
+bool WelcomeDialog::Create(void)
+{
+ bool foundtheme = false;
+
+ // Load the theme for this screen
+ foundtheme = LoadWindowFromXML("install-ui.xml", "welcome_screen", this);
+
+ if (!foundtheme)
+ return false;
+
+ bool err = false;
+ UIUtilE::Assign(this, m_status_text, "status_text", &err);
+ UIUtilE::Assign(this, m_recording_text, "recording_text", &err);
+ UIUtilE::Assign(this, m_scheduled_text, "scheduled_text", &err);
+ UIUtilE::Assign(this, m_time_text, "time_text", &err);
+ UIUtilE::Assign(this, m_date_text, "date_text", &err);
+ UIUtilE::Assign(this, m_mv_text, "mythvantage_text", &err);
+ if (err)
+ {
+ //JM VERBOSE(VB_IMPORTANT, "Cannot load screen 'welcome_screen'");
+ return false;
+ }
+
+ BuildFocusList();
+ updateTime();
+
+ return true;
+}
+
+void WelcomeDialog::shutdownNow(int rc)
+{
+ QString NETBOOT = getenv("NETBOOT");
+ NETBOOT=NETBOOT.stripWhiteSpace();
+// system("rm -f /tmp/.install_state");
+// system("rm -f /tmp/.install_percent");
+// system("rm -f /tmp/.install_error");
+ if (rc == 1)
+ system("/sbin/halt");
+ else
+ system("/sbin/reboot");
+}
+
+void WelcomeDialog::runLIVECD(void)
+{
+ ask_validate_network();
+ if ( runsettings(true) == 1 )
+ {
+ QString PAINTER = gCoreContext->GetSetting("ThemePainter");
+ QString startFECmd = ("MYTHCONFDIR=/tmp mythfrontend -O ThemePainter=" + PAINTER );
+ myth_system(startFECmd.ascii());
+ }
+ else
+ {
+ showPopup();
+ }
+
+
+}
+
+bool WelcomeDialog::keyPressEvent(QKeyEvent *event)
+{
+ bool handled = false;
+ QStringList actions;
+ handled=GetMythMainWindow()->TranslateKeyPress("Welcome", event, actions);
+
+ for (int i = 0; i < actions.size() && !handled; i++)
+ {
+ QString action = actions[i];
+ handled = true;
+
+ if (action == "ESCAPE")
+ {
+ return true; // eat escape key
+ }
+ else if (action == "MENU")
+ {
+ showPopup();
+ }
+ else if (action == "NEXTVIEW")
+ {
+ Close();
+ }
+ else if (action == "STARTXTERM")
+ {
+ QString cmd = gCoreContext->GetSetting("MythShutdownXTermCmd", "");
+ if (!cmd.isEmpty())
+ {
+ QByteArray tmp = cmd.toAscii();
+ system(tmp);
+ }
+ }
+ else
+ handled = false;
+ }
+
+ if (!handled && MythScreenType::keyPressEvent(event))
+ handled = true;
+ return handled;
+}
+
+void WelcomeDialog::closeDialog()
+{
+ Close();
+ exit(0);
+}
+
+
+// void WelcomeDialog::slotPopup()
+// {
+// showPopup();
+// }
+
+WelcomeDialog::~WelcomeDialog()
+{
+ gCoreContext->removeListener(this);
+ if (m_updateStatusTimer)
+ delete m_updateStatusTimer;
+
+ if (m_updateScreenTimer)
+ delete m_updateScreenTimer;
+
+ if (m_timeTimer)
+ delete m_timeTimer;
+}
+
+void WelcomeDialog::updateTime(void)
+{
+ QString releasefile="/etc/";
+ releasefile.append(RELEASEFILE);
+
+ QString distro_line;
+ QFile file(releasefile);
+ if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ Q3TextStream t( &file ); // use a text stream
+ distro_line = t.readLine();
+ file.close();
+ }
+ QString s="";
+ s.append(distro_line);
+ s.append( "\nMythtv source:" );
+ //s.append(MYTH_SOURCE_VERSION);
+ //s.append(" ");
+ s.append(MYTH_SOURCE_PATH);
+ m_date_text->SetText(s);
+}
+
+void WelcomeDialog::updateStatus(void)
+{
+ updateStatusMessage();
+ updateScreen();
+}
+
+void WelcomeDialog::updateScreen(void)
+{
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh " );
+ system(cmdtxt);
+ recording_text=" ";
+ mythvantage_text=" ";
+ error_text=" ";
+ scheduled_text=" ";
+ QFile mystatus("/tmp/.install_state");
+ QFile mypercent("/tmp/.install_percent");
+ QFile myerror("/tmp/.install_error");
+ QFile mylog("/tmp/mythvantage_install.log");
+ if ( mystatus.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ Q3TextStream t( &mystatus ); // use a text stream
+ scheduled_text = t.readLine();
+ mystatus.close();
+ }
+
+ if ( mypercent.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ Q3TextStream t( &mypercent ); // use a text stream
+ recording_text = t.readLine();
+ mypercent.close();
+ }
+
+ if ( myerror.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ Q3TextStream t( &myerror ); // use a text stream
+ error_text = t.readLine();
+ myerror.close();
+ scheduled_text = error_text;
+ recording_text = "FAILED";
+ WORKING_ON_INSTALL = false;
+ }
+
+ if ( WORKING_ON_INSTALL )
+ {
+ if ( mylog.open( QIODevice::ReadOnly| QIODevice::Text ) )
+ {
+ Q3TextStream t( &mylog );
+ while ( !t.atEnd() )
+ {
+ mythvantage_text=t.readLine();
+ }
+ mylog.close();
+ }
+ }
+ else
+ mythvantage_text="";
+ m_recording_text->SetText(recording_text);
+ m_scheduled_text->SetText(scheduled_text);
+ m_mv_text->SetText(mythvantage_text);
+
+ if ( install_drive != "" )
+ install_text = "";
+
+ m_status_text->SetText(install_text );
+ m_updateScreenTimer->start(UPDATE_SCREEN_INTERVAL, true);
+ if ( scheduled_text == "Done" )
+ {
+ Reboot_popup () ;
+ }
+ // shows the busy box when configuring the system
+ if ( scheduled_text == "Configuring system")
+ {
+ if ( ! I_AM_BUSY )
+ busy_box();
+ }
+};
+
+void WelcomeDialog::busy_box(void)
+{
+ QString msgtext = "Please wait, " ;
+ msgtext.append(current_hostname);
+ msgtext.append(" is preparing for life");
+ MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+ MythUIBusyDialog *busyPopup = new MythUIBusyDialog(msgtext, popupStack,"installbusy");
+ if (busyPopup->Create())
+ {
+ popupStack->AddScreen(busyPopup, false);
+ }
+ else
+ {
+ delete busyPopup;
+ busyPopup = NULL;
+ }
+
+
+ while ( scheduled_text == "Configuring system" )
+ {
+ qApp->processEvents ();
+ usleep(900);
+ I_AM_BUSY = true;
+ }
+
+ if (busyPopup)
+ {
+ busyPopup->Close();
+ busyPopup = NULL;
+ }
+ I_AM_BUSY = false;
+}
+
+void WelcomeDialog::busy_find_oldsettings(void)
+{
+
+ QString msgtext = "Importing old settings" ;
+ MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+ MythUIBusyDialog *busyPopup = new MythUIBusyDialog(msgtext, popupStack,
+ "importsettingsbusy");
+ if (busyPopup->Create())
+ {
+ popupStack->AddScreen(busyPopup, false);
+ }
+ else
+ {
+ delete busyPopup;
+ busyPopup = NULL;
+ }
+
+ int return_code = 0;
+ while ( return_code == 0 )
+ {
+ qApp->processEvents ();
+ usleep(900);
+ I_AM_BUSY = true;
+ return_code = myth_system("ps -ef|grep install_proxy.sh|grep -v grep > /dev/null");
+ }
+
+ if (busyPopup)
+ {
+ busyPopup->Close();
+ busyPopup = NULL;
+ }
+ I_AM_BUSY = false;
+
+}
+
+
+bool WelcomeDialog::updateRecordingList()
+{
+ //JM VERBOSE(VB_IMPORTANT, "updateRecordingList");
+ return true;
+}
+
+bool WelcomeDialog::updateScheduledList()
+{
+ //JM VERBOSE(VB_IMPORTANT, "updateScheduled list");
+ updateStatus();
+ updateScreen();
+ return true;
+}
+
+void WelcomeDialog::updateStatusMessage(void)
+{
+ return ;
+}
+
+void WelcomeDialog::showPopup(void)
+{
+
+// if (m_menuPopup)
+ // return;
+//
+// QString label = tr("MythVantage Menu");
+// MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();
+// m_menuPopup = new MythDialogBox(label, mainStack, "menuPopup");
+//
+// if (m_menuPopup->Create())
+// mainStack->AddScreen(m_menuPopup);
+//
+// m_menuPopup->SetReturnEvent(this, "action");
+
+ MythScreenStack *popupStack = GetMythMainWindow()->GetMainStack();
+
+ m_menuPopup = new MythDialogBox("Menu", popupStack, "actionmenu");
+
+ if (m_menuPopup->Create())
+ popupStack->AddScreen(m_menuPopup);
+
+ m_menuPopup->SetReturnEvent(this, "action");
+
+
+
+
+
+ // This is a bad way to lock the buttons but it works for now.
+ if ( scheduled_text.length() <= 2 )
+ {
+ m_menuPopup->AddButton(tr("Install or Upgrade "),
+ SLOT(Display_2ndpopup()));
+ m_menuPopup->AddButton(tr("Run MythFrontend"),
+ SLOT(runLIVECD()));
+ m_menuPopup->AddButton(tr("Exit"),
+ SLOT(closeDialog()));
+ m_menuPopup->AddButton(tr("Close menu")) ;
+ }
+ else
+ {
+ m_menuPopup->AddButton(tr("Exit"),
+ SLOT(closeDialog()));
+ m_menuPopup->AddButton(tr("Close menu"));
+ }
+
+}
+// switch (override_menu)
+// {
+// case 2:
+// case 4:
+// // shutdown
+// m_menuPopup->SetReturnEvent(this,"popmenu_shutdown");
+// m_menuPopup->AddButton(tr("Shutdown"));
+// break;
+// case 5:
+// // reboot
+// m_menuPopup->SetReturnEvent(this,"popmenu_reboot");
+// m_menuPopup->AddButton(tr("Reboot"));
+// break;
+// case 3:
+// case 6:
+// // both
+// m_menuPopup->SetReturnEvent(this,"popmenu_exit");
+// m_menuPopup->AddButton(tr("Shutdown"));
+// m_menuPopup->AddButton(tr("Reboot"));
+// break;
+// case 0:
+// default:
+// m_menuPopup->SetReturnEvent(this,"popmenu_noexit");
+// break;
+// }
+//
+// m_menuPopup->AddButton(tr("About"));
+// m_menuPopup->AddButton(tr("Cancel"));
+//
+// }
+
+
+
+
+// MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+//
+// m_menuPopup = new MythDialogBox("Menu", popupStack, "actionmenu");
+//
+// if (m_menuPopup->Create())
+// popupStack->AddScreen(m_menuPopup);
+//
+// m_menuPopup->SetReturnEvent(this, "action");
+// // This is a bad way to lock the buttons but it works for now.
+// if ( scheduled_text.length() <= 2 )
+// {
+// m_menuPopup->AddButton(tr("Install or Upgrade "),
+// SLOT(Display_2ndpopup()));
+// m_menuPopup->AddButton(tr("Run MythFrontend"),
+// SLOT(runLIVECD()));
+// m_menuPopup->AddButton(tr("Exit"),
+// SLOT(closeDialog()));
+// m_menuPopup->AddButton(tr("Close menu")) ;
+// }
+// else
+// {
+// m_menuPopup->AddButton(tr("Exit"),
+// SLOT(closeDialog()));
+// m_menuPopup->AddButton(tr("Close menu"));
+// }
+// }
+
+
+QString WelcomeDialog::diskmodel(QString drive , QString tsize)
+{
+ string line;
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh disk_model_it " + drive + " " + tsize );
+ myth_system(cmdtxt);
+
+ ifstream model("/tmp/model");
+ if (model.is_open())
+ getline (model,line);
+ model.close();
+
+ QString qline( QString::fromStdString( line ) );
+ return qline;
+}
+
+QString WelcomeDialog::findinstallsouce(void)
+{
+ string line;
+ QString currentitem;
+ ifstream mountfile("/proc/mounts");
+ while (! mountfile.eof() )
+ {
+ getline (mountfile,line);
+ if ( line.empty() )
+ line = "oops didn't find andthing";
+
+ currentitem= ( QString::fromStdString( line ) );
+
+ if ( ! currentitem.contains("/dev"))
+ currentitem="not the right line";
+ // LOG(VB_GENERAL, LOG_ERR, currentitem);
+
+ if ( currentitem.contains("bootmnt") )
+ {
+ int ndx = line.find(" ");
+ currentitem =QString::fromStdString(line.substr(0,ndx));
+ ndx = currentitem.findRev("/");
+ currentitem = currentitem.mid(ndx+1,3);
+ return currentitem;
+ };
+ }
+};
+
+void WelcomeDialog::showPopup_2(void)
+{
+ MythScreenStack *popupStack = GetMythMainWindow()->GetMainStack();
+
+ m_menuPopup = new MythDialogBox("Select the drive to install to", popupStack, "actionmenu");
+
+ if (m_menuPopup->Create())
+ popupStack->AddScreen(m_menuPopup);
+
+ m_menuPopup->SetReturnEvent(this, "action");
+ QString currentitem;
+
+ string sizeitem;
+ QString disksize;
+ string line;
+ bool installsource = false;
+
+ QString NETBOOT = getenv("NETBOOT");
+ NETBOOT=NETBOOT.stripWhiteSpace();
+ if ( NETBOOT == "YES" )
+ m_menuPopup->AddButton(("Diskless Frontend " ), SLOT(install_net() ) );
+
+ QString INSTALLSOURCE = findinstallsouce();
+ ifstream partitions("/proc/partitions");
+ if (partitions.is_open())
+ {
+ while (! partitions.eof() )
+ {
+ getline (partitions,line);
+ if ( line.empty() )
+ {
+ line = "oops didn't find anything";
+ }
+ int ndx = line.rfind(" ");
+ ndx = ndx +1;
+ int linelength = line.length();
+ currentitem = QString::fromStdString(line.substr(ndx,linelength));
+ sizeitem = line.substr(0,ndx-1);
+ linelength = sizeitem.length();
+ ndx = sizeitem.rfind(" ");
+ disksize = QString::fromStdString(sizeitem.substr(ndx+1,linelength));
+
+ if ( currentitem == INSTALLSOURCE )
+ installsource = true;
+
+ if (! installsource )
+ {
+ if ( currentitem == "sde" )
+ m_menuPopup->AddButton(("sde " + diskmodel(currentitem,disksize)), SLOT(install_sde() ) );
+ if ( currentitem == "sdf" )
+ m_menuPopup->AddButton(("sdf " + diskmodel(currentitem,disksize)), SLOT(install_sdf() ) );
+ if ( currentitem == "sdg" )
+ m_menuPopup->AddButton(("sdg " + diskmodel(currentitem,disksize)), SLOT(install_sdg() ) );
+ if ( currentitem == "sdh" )
+ m_menuPopup->AddButton(("sdh " + diskmodel(currentitem,disksize)), SLOT(install_sdh() ) );
+ if (currentitem == "sda" )
+ m_menuPopup->AddButton(("sda " + diskmodel(currentitem,disksize)), SLOT(install_sda() ) );
+ if (currentitem == "sdb" )
+ m_menuPopup->AddButton(("sdb " + diskmodel(currentitem,disksize)), SLOT(install_sdb() ) );
+ if (currentitem == "sdc" )
+ m_menuPopup->AddButton(("sdc "+ diskmodel(currentitem,disksize)), SLOT(install_sdc() ) );
+ if (currentitem == "sdd" )
+ m_menuPopup->AddButton(("sdd "+ diskmodel(currentitem,disksize)), SLOT(install_sdd() ) );
+ }
+ installsource = false;
+ }
+ }
+ partitions.close();
+ m_menuPopup->AddButton(tr("Cancel"), SLOT(MAINPopup()));
+}
+
+void WelcomeDialog::GO_popup(QString go_text)
+{
+ DialogCode retval = MythPopupBox::Show2ButtonPopup(GetMythMainWindow(),
+ QString("Start the process"),
+ QObject::tr(go_text),
+ QObject::tr("Start the process"), QObject::tr("Cancel"), kDialogCodeButton0);
+
+ if ( retval == kDialogCodeButton0 )
+ {
+ install_it();
+ }
+ else
+ {
+ showPopup();
+ }
+}
+
+
+void WelcomeDialog::Reboot_popup(void)
+{ if (reboot_box)
+ return;
+ QString prompt1;
+ QFile updbstatus("/tmp/.upgrade_db_failed");
+ if ( updbstatus.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ prompt1 = QObject::tr(" ");
+ prompt1.append("\n");
+ prompt1.append("An error occured while attempting to restore the database!");
+ prompt1.append("\n");
+ prompt1.append("The old database could not be restored, so a new database was created");
+ prompt1.append("\n");
+ }
+ else
+ prompt1 = QObject::tr("Ready to go!");
+
+ reboot_box = new DialogBox(GetMythMainWindow(), prompt1);
+ reboot_box->AddButton(QObject::tr("Reboot"));
+ reboot_box->AddButton(QObject::tr("Power off"));
+
+ int returncode = 0;
+ DialogCode dcode = reboot_box->exec();
+ reboot_box->deleteLater();
+ if (kDialogCodeButton0 == dcode )
+ returncode = 0;
+ if (kDialogCodeButton1 == dcode )
+ returncode = 1;
+ if (kDialogCodeButton2 == dcode )
+ returncode = 2;
+
+ reboot_box = NULL;
+ shutdownNow(returncode);
+}
+
+
+
+void WelcomeDialog::MAINPopup(void)
+{
+// if (!popup)
+// return;
+// popup->hide();
+// popup->deleteLater();
+ popup = NULL;
+ showPopup();
+
+}
+
+void WelcomeDialog::Display_2ndpopup(void)
+{
+ //JM VERBOSE(VB_GENERAL, "Display_2ndpopup");
+ showPopup_2();
+}
+
+void WelcomeDialog::install_sde(void)
+{
+ install_drive = "sde" ;
+ install_generic();
+}
+
+void WelcomeDialog::install_sdf(void)
+{
+ install_drive = "sdf" ;
+ install_generic();
+}
+
+void WelcomeDialog::install_sdg(void)
+{
+ install_drive = "sdg" ;
+ install_generic();
+}
+
+void WelcomeDialog::install_sdh(void)
+{
+ install_drive = "sdh" ;
+ install_generic();
+}
+
+void WelcomeDialog::install_sda(void)
+{ install_drive = "sda" ;
+ install_generic();
+}
+void WelcomeDialog::install_sdb(void)
+{ install_drive = "sdb" ;
+ install_generic();
+}
+
+void WelcomeDialog::install_sdc(void)
+{ install_drive = "sdc" ;
+ install_generic();
+}
+
+void WelcomeDialog::install_sdd(void)
+{
+ install_drive = "sdd" ;
+ install_generic();
+}
+
+void WelcomeDialog::install_net(void)
+{
+ install_drive = "NET" ;
+ //gCoreContext->ActivateSettingsCache(false);
+ gCoreContext->SaveSetting("HOSTinstallationtype","NET");
+ install_generic();
+}
+
+void WelcomeDialog::write_install_conf(QString rootdisk)
+{
+ //1077
+ QString op;
+ //QString rootdisk;
+ QString rootfs;
+ QString uprootfs;
+ QString rootsize;
+ QString homesize;
+ QString sqlsize;
+ QString usealldata;
+ QString datasize;
+ QString datafs;
+ QString datadisk;
+ QString swapsize;
+ QString useswap;
+
+ op = gCoreContext->GetSetting("HOSTinstallationtype");
+ if ( op == "Full/Auto" )
+ op = "full_install";
+ if ( op == "Upgrade" )
+ op = "upgrade";
+ //rootdisk = install_drive;
+ rootfs = gCoreContext->GetSetting("HOSTrootfstype");
+ uprootfs = gCoreContext->GetSetting("HOSTuprootfstype");
+ rootsize = gCoreContext->GetSetting("HOSTOSsize");
+ homesize = gCoreContext->GetSetting("HOSTHOMEsize");
+ sqlsize = gCoreContext->GetSetting("HOSTDatabasesize");
+
+ //datasize
+ usealldata = gCoreContext->GetSetting("HostUseALLdata");
+ datasize = gCoreContext->GetSetting("HOSTDATAsize");
+ if ( usealldata == "1" )
+ datasize="ALL";
+ else
+ datasize=datasize + "000";
+
+ datafs = gCoreContext->GetSetting("HOSTdatafstype");
+ datadisk = install_drive;
+
+ //swapsize
+ useswap = gCoreContext->GetSetting("HostUseSWAP");
+ swapsize = gCoreContext->GetSetting("HOSTSWAPsize");
+ if ( useswap == "0" )
+ swapsize="NO";
+
+ rootsize=rootsize + "000";
+ homesize=homesize + "000";
+ sqlsize=sqlsize + "000";
+
+ QFile f( "/etc/install_layout" );
+ if( !f.open( IO_WriteOnly ) )
+ std::cout << "Failed to open file /etc/install_layout." << std::endl;
+ QTextStream myfile( &f );
+
+ myfile << "op=" + op + "\n";
+ myfile << "rootdisk=" + rootdisk + "\n";
+ myfile << "rootfs=" + rootfs + "\n";
+ myfile << "uprootfs=" + uprootfs + "\n";
+ myfile << "rootsize=" + rootsize + "\n";
+ myfile << "homesize=" + homesize + "\n";
+ myfile << "homefs=" + rootfs + "\n";
+ myfile << "sqlsize=" + sqlsize + "\n";
+ //myfile << "sqlfs=" + sqlfs + "\n";
+ myfile << "sqlfs=ext3\n";
+ myfile << "datasize=" + datasize + "\n";
+ myfile << "datafs=" + datafs + "\n";
+ myfile << "datadisk=" + datadisk + "\n";
+ myfile << "swapsize=" + swapsize + "\n";
+
+ f.close();
+}
+
+
+void WelcomeDialog::install_generic(void)
+{
+ //write_install_conf(install_drive);
+ QString installwarningtext;
+ int runNextSetting;
+ runNextSetting = 1;
+ int tflag;
+ tflag = 0;
+ int retcode;
+ retcode=0;
+ QString installtype;
+ if ( install_drive != "NET")
+ retcode = mythinstalltype(install_drive);
+ if ( retcode == 0 )
+ {
+ installtype = gCoreContext->GetSetting("HOSTinstallationtype");
+ if ( installtype == "Full/Auto" )
+ {
+ //JM VERBOSE(VB_GENERAL, "Full install");
+ runNextSetting = ask_validate_network();
+ installwarningtext="Warning!";
+ installwarningtext.append ("\n");
+ installwarningtext.append ("\n");
+ installwarningtext.append ("Installation drive (");
+ installwarningtext.append (install_drive);
+ installwarningtext.append (") is about to be erased.");
+ installwarningtext.append ("\n");
+ }
+ else if ( installtype == "NET")
+ {
+ runNextSetting=0;
+ gCoreContext->SaveSetting("HostSystemType", "Frontend_only");
+ gCoreContext->SaveSetting("HostaccesshostypeSystemtype","0");
+ installwarningtext.append ("About to install ");
+ installwarningtext.append ("\n");
+ installwarningtext.append (install_drive);
+ // ask for hostname
+ runsettings(false,true,false,false,false,false,false);
+ }
+ else if ( installtype == "Upgrade" )
+ {
+ installwarningtext="Warning!";
+ installwarningtext.append ("\n");
+ installwarningtext.append ("\n");
+ installwarningtext.append ("OS partition (");
+ installwarningtext.append (install_drive);
+ installwarningtext.append ("1");
+ installwarningtext.append (") will be erased.");
+ installwarningtext.append ("\n");
+
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh find_update " + install_drive +" &");
+ system(cmdtxt);
+ busy_find_oldsettings();
+ bool flag = false;
+ QString line;
+ QString currentitem;
+ QFile file("/etc/systemconfig");
+ if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ Q3TextStream t( &file ); // use a text stream
+ while ( !t.eof() )
+ {
+ line = t.readLine();
+ if ( line.startsWith("hostname"))
+ {
+ flag=true;
+ currentitem = line.section( "=", 1, 1 );
+ current_hostname = currentitem ;
+ }
+ }
+ file.close();
+ }
+ if ( flag )
+ {
+ //check if LinHES-release is 8.0 or newer
+ cout << "searching for LinHES-release" << endl;
+ //look for /tmp/etc/LinHES-release
+ QFile file("/tmp/etc/LinHES-release");
+ if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ Q3TextStream t( &file ); // use a text stream
+ while ( !t.eof() )
+ {
+ line = t.readLine();
+ if ( line.contains("8.") )
+ {
+ tflag = 1;
+ }
+ }
+ file.close();
+ }
+ }
+ if ( tflag == 0 )
+ {
+ //popup install doesn't look like R8
+ MythPopupBox::showOkPopup(
+ GetMythMainWindow(),
+ QObject::tr(""),
+ QObject::tr("The selected disk cannot be upgraded because it is older than LinHES R8.0."));
+ runNextSetting = 1;
+ }
+ }
+ }
+ //run through the system settings
+ if ( runNextSetting == 0 )
+ {
+ //DEfault settings screen for install
+ tflag = runsettings (false , false , true,
+ true , false, false,
+ false,true,false, false ,
+ false, true , false , false ,
+ false , false, false, true , true,
+ false);
+ }
+ //else
+ // {
+ // cancelPopup();
+ //this is the popup after the upgrade
+ // showPopup();
+ // };
+
+ if ( tflag == 1 )
+ {
+ //write out the conf file
+ write_install_conf(install_drive);
+ GO_popup(installwarningtext);
+ }
+ else
+ {
+ showPopup();
+ }
+
+}
+
+void busy_network(void)
+{
+ QString msgtext = "Starting network" ;
+ MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
+ MythUIBusyDialog *busyPopup = new MythUIBusyDialog(msgtext, popupStack,"installbusy");
+ if (busyPopup->Create())
+ {
+ popupStack->AddScreen(busyPopup, false);
+ }
+ else
+ {
+ delete busyPopup;
+ busyPopup = NULL;
+ }
+
+ int return_code = 0;
+ while ( return_code == 0 )
+ {
+ qApp->processEvents ();
+ usleep(900);
+ return_code = myth_system("ps -ef|grep install_proxy.sh| grep setup_network |grep -v grep > /dev/null");
+ }
+
+ if (busyPopup)
+ {
+ busyPopup->Close();
+ busyPopup = NULL;
+ }
+
+
+
+}
+
+
+int WelcomeDialog::ask_validate_network(void)
+{
+ QString pop_text="abc";
+ int retval = 1;
+ while ( retval != 0 )
+ {
+ int settingsrec = runsettings(false,true,false,false,false,false,false);
+ if ( settingsrec != 1 )
+ return 1;
+ else
+ {
+ MythProgressDialog *network_check = NULL;
+ network_check = new MythProgressDialog(QObject::tr("Please wait while the network is checked."), 7);
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh network_check_it setup_network &");
+ retval = system(cmdtxt);
+ busy_network();
+ if (network_check)
+ {
+ network_check->setProgress(2);
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh network_check_it check_self");
+ retval = system(cmdtxt);
+ if ( retval != 0 )
+ {
+ network_check->Close();
+ pop_text="Could not find myself on the network";
+ }
+ }
+
+ if ( retval == 0)
+ {
+ network_check->setProgress(3);
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh network_check_it check_gw");
+ retval = system(cmdtxt);
+ if ( retval != 0 )
+ {
+ network_check->Close();
+ pop_text="Could not locate gateway";
+ }
+ }
+
+ if (retval == 0)
+ {
+ network_check->setProgress(4);
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh network_check_it check_ns");
+ retval = system(cmdtxt);
+ if ( retval != 0 )
+ {
+ network_check->Close();
+ pop_text="Could not locate nameserver";
+ }
+ }
+
+ if (retval == 0)
+ {
+ network_check->setProgress(5);
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh network_check_it check_names");
+ retval = system(cmdtxt);
+ if ( retval != 0 )
+ {
+ network_check->Close();
+ pop_text="Could not lookup names";
+ }
+ }
+
+ if (retval == 0)
+ {
+ network_check->setProgress(6);
+ cmdtxt=MV_ROOT ;
+ cmdtxt.append("bin/install_proxy.sh network_check_it host_names");
+ retval = system(cmdtxt);
+ if ( retval != 0 )
+ {
+ network_check->Close();
+ pop_text="Hostname already on the network";
+ }
+ }
+
+ network_check->setProgress(7);
+ if (network_check)
+ {
+ network_check->Close();
+ network_check->deleteLater();
+ }
+
+ if (retval != 0 )
+ {
+ DialogCode val = MythPopupBox::Show2ButtonPopup(GetMythMainWindow(), QString(""), QObject::tr(pop_text), QObject::tr("Continue"), QObject::tr("Try again"), kDialogCodeButton0);
+ if (kDialogCodeButton0 == val )
+ retval = 0;
+ }
+ }
+ }
+ return 0;
+}
+
+
+void WelcomeDialog::install_it(void)
+{
+ QString installtype = gCoreContext->GetSetting("HOSTinstallationtype");
+// QString rootfs = gCoreContext->GetSetting("HOSTrootfstype");
+// QString datafs = gCoreContext->GetSetting("HOSTdatafstype");
+// QString rootsize = gCoreContext->GetSetting("HOSTOSsize");
+// rootsize=rootsize + "000";
+// QString usealldata = gCoreContext->GetSetting("HostUseALLdata");
+// QString datasize = gCoreContext->GetSetting("HOSTDATAsize");
+// QString uprootfs = gCoreContext->GetSetting("HOSTuprootfstype");
+// QString useswap = gCoreContext->GetSetting("HostUseSWAP");
+// QString swapsize = gCoreContext->GetSetting("HOSTSWAPsize");
+ if ( installtype != "Upgrade" )
+ current_hostname = gCoreContext->GetSetting("HostMyhostname");
+ QString clean_upgrade = getenv("CLEAN_UPGRADE");
+ if ( clean_upgrade == "YES" )
+ current_hostname = gCoreContext->GetSetting("HostMyhostname");
+
+//get the hostname here if upgrade then use previous declarion of hostname
+// if ( usealldata == "1" )
+// {
+// datasize="ALL";
+// }
+// else
+// {
+// datasize=datasize + "000";
+// }
+// if ( useswap == "0" )
+// {
+// swapsize="NO";
+// };
+
+
+ if ( installtype == "Full/Auto" )
+ {
+ QString currentitem;
+ QString line;
+ QFile file("/proc/meminfo");
+ if ( file.open(QIODevice::ReadOnly | QIODevice::Text) )
+ {
+ Q3TextStream t( &file ); // use a text stream
+ line = t.readLine();
+ if ( line.startsWith("MemTotal:"))
+ {
+ currentitem = line.simplifyWhiteSpace();
+ currentitem = currentitem.section( " ", 1, 1 );
+ }
+ }
+ file.close();
+ bool ok;
+ int mem = currentitem.toInt( &ok, 10 ); // dec == 0, ok == FALSE
+
+
+// if ( mem >= 500000 )
+// {
+// if ((gCoreContext->GetSetting("HostXres")) == "1280x720" )
+// gCoreContext->SaveSetting("Theme", "syth-lacquer-wide");
+// }
+
+
+ QString cmdtxt=MV_ROOT ;
+ //cmdtxt.append("bin/install_proxy.sh full_install_it " + install_drive + " " + rootfs + " " + rootsize + " " + datafs + " " + datasize + " " + swapsize + "&");
+ cmdtxt.append("bin/install_proxy.sh full_install_it &");
+ system(cmdtxt);
+ }
+ else if ( installtype == "Upgrade" )
+ {
+ QString cmdtxt=MV_ROOT ;
+ //cmdtxt.append("bin/install_proxy.sh upgrade_it " + install_drive + " " + uprootfs + "&");
+ cmdtxt.append("bin/install_proxy.sh upgrade_it &");
+ system(cmdtxt);
+ }
+ else if (installtype=="NET")
+ {
+ QString olddb = gCoreContext->GetSetting("HostMysqlserver");
+ QString cmdtxt;
+ cmdtxt=MV_ROOT ;
+ char localhostname[1024];
+ if (gethostname(localhostname, 1024))
+ {
+ //JM VERBOSE(VB_IMPORTANT,
+ //"MCP: Error, could not determine host name." + ENO);
+ localhostname[0] = '\0';
+ }
+ QString h;
+ h=localhostname;
+ cmdtxt.append("bin/restore_default_settings.sh -c save -t syssettings -d 127.0.0.1 -h " + h);
+ system(cmdtxt);
+ cmdtxt=MV_ROOT ;
+ //cmdtxt.append("bin/install_proxy.sh NETBOOT " + install_drive + " &");
+ cmdtxt.append("bin/install_proxy.sh NETBOOT &");
+ system(cmdtxt);
+ }
+
+ WORKING_ON_INSTALL = true;
+ usleep (500);
+ updateScreen();
+ usleep (500);
+ updateScreen();
+}