#include #include #include #include #include "mythcontext.h" #include "installdialog.h" #include "installsettings.h" #include "installationtype.h" #include "mv_common.h" #include "questionnotice.h" #include "mythprogressdialog.h" #include #include // for milliseconds #include // for sleep_for #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_menuPopup(NULL), m_status_text(NULL),m_recording_text(NULL), m_scheduled_text(NULL), m_mv_text(NULL), m_time_text(NULL), m_date_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 = ""; 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); m_menuPopup = NULL; 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.simplified(); // system("rm -f /tmp/.install_state"); // system("rm -f /tmp/.install_percent"); // system("rm -f /tmp/.install_error"); if (rc == 1) { if(!system("/sbin/halt")) LOG(VB_GENERAL, LOG_ERR, "Error running halt"); } else { if(!system("/sbin/reboot")) LOG(VB_GENERAL, LOG_ERR, "Error running reboot"); } } void WelcomeDialog::runLIVECD(void) { ask_validate_network(); if ( runsettings(true) == 1 ) { QString PAINTER = gCoreContext->GetSetting("ThemePainter"); QString SERVERIP = gCoreContext->GetSetting("HostMysqlServer"); QString startFECmd = ("MYTHCONFDIR=/tmp mythfrontend -O ThemePainter=" + PAINTER + " -O AudioOutputDevice=ALSA:default -O MasterServerIP=" + SERVERIP ); // myth_system(startFECmd.ascii()); myth_system(startFECmd); } 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(); // QByteArray tmp = cmd; // system(tmp); myth_system(qPrintable(cmd)); } } else handled = false; } if (!handled && MythScreenType::keyPressEvent(event)) handled = true; return handled; } void WelcomeDialog::closeDialog() { Close(); } // 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) ) { QTextStream t( &file ); // use a text stream distro_line = t.readLine(); file.close(); } QString s=""; s.append(distro_line); s.append( "\nMythTV Branch: " ); //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 " ); int sysRet = system(qPrintable(cmdtxt)); if (sysRet < 0) LOG(VB_GENERAL, LOG_ERR, "Error running install_proxy.sh in updateScreen"); recording_text="Press MENU for Options"; 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) ) { QTextStream t( &mystatus ); // use a text stream scheduled_text = t.readLine(); mystatus.close(); } if ( mypercent.open(QIODevice::ReadOnly | QIODevice::Text) ) { QTextStream t( &mypercent ); // use a text stream recording_text = t.readLine(); mypercent.close(); } if ( myerror.open(QIODevice::ReadOnly | QIODevice::Text) ) { QTextStream 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 ) ) { QTextStream 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); m_updateScreenTimer->start(UPDATE_SCREEN_INTERVAL); if ( scheduled_text == "Done" ) { CloseBusyPopup(); m_updateScreenTimer->stop(); Reboot_popup(); } // shows the busy box when configuring the system if ( scheduled_text == "Configuring system") { m_recording_text->SetText(" "); QString msgtext = "Configuring LinHES on host " ; msgtext.append(current_hostname); msgtext.append("..."); OpenBusyPopup(msgtext); } }; void WelcomeDialog::busy_find_oldsettings(void) { QString msgtext = "Importing Old Settings..." ; OpenBusyPopup(msgtext); int return_code = 0; while ( return_code == 0 ) { qApp->processEvents (); std::this_thread::sleep_for(std::chrono::microseconds(900)); return_code = myth_system("ps -ef|grep install_proxy.sh|grep -v grep > /dev/null"); } CloseBusyPopup(); } 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) { 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::findinstallsource(void) { string line; QString currentitem; ifstream mountfile("/proc/mounts"); while (! mountfile.eof() ) { getline (mountfile,line); if ( line.empty() ) line = "oops didn't find anything"; 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("/"); ndx = currentitem.lastIndexOf("/"); currentitem = currentitem.mid(ndx+1,3); return currentitem; }; } return NULL; }; void WelcomeDialog::showPopup_2(void) { MythScreenStack *popupStack = GetMythMainWindow()->GetMainStack(); m_menuPopup = new MythDialogBox("Where do you want to install LinHES?", 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.simplified(); if ( NETBOOT == "YES" ) m_menuPopup->AddButton(("Diskless Frontend"), SLOT(install_net() ) ); QString INSTALLSOURCE = findinstallsource(); 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(), "", go_text, tr("Start Installation"), tr("Cancel"), kDialogCodeButton0); if ( retval == kDialogCodeButton0 ) { install_it(); } else { showPopup(); } } void WelcomeDialog::Reboot_popup(void) { QString prompt1; QFile updbstatus("/tmp/.upgrade_db_failed"); if ( updbstatus.open(QIODevice::ReadOnly | QIODevice::Text) ) { prompt1 = QObject::tr("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."); } else prompt1 = QObject::tr("Installation of LinHES is complete!"); //as extern to be set in questionnotice.cpp extern int questionReturnCode; MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack(); QuestionNoticeDialog *questionNotice = new QuestionNoticeDialog(mainStack, "Question"); if (questionNotice->Create("question", "Installation Complete", prompt1, "Reboot", "Shutdown")) mainStack->AddScreen(questionNotice, true); else return; do { qApp->processEvents(); std::this_thread::sleep_for(std::chrono::milliseconds(5)); } while (mainStack->TotalScreens() > 1); int returncode; if (questionReturnCode == 16) { LOG(VB_GENERAL, LOG_INFO, "Reboot"); returncode = 0; } else { LOG(VB_GENERAL, LOG_INFO, "Shutdown"); returncode = 1; } shutdownNow(returncode); } void WelcomeDialog::MAINPopup(void) { showPopup(); } void WelcomeDialog::Display_2ndpopup(void) { 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( QIODevice::WriteOnly | QIODevice::Text ) ) 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 ("The selected drive ("); installwarningtext.append (install_drive); installwarningtext.append (") will be erased and LinHES will be installed."); 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 and LinHES will be installed."); installwarningtext.append ("\n"); installwarningtext.append ("The other partitions on ("); installwarningtext.append (install_drive); installwarningtext.append (") will not be erased."); QString cmdtxt; cmdtxt=MV_ROOT ; cmdtxt.append("bin/install_proxy.sh find_update " + install_drive +" &"); int sysRet = system(qPrintable(cmdtxt)); if (sysRet < 0) LOG(VB_GENERAL, LOG_ERR, "Could not run install_proxy.sh find update"); busy_find_oldsettings(); bool flag = false; QString line; QString currentitem; QFile file("/etc/systemconfig"); if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) { QTextStream t( &file ); // use a text stream while ( !t.atEnd() ) { 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) ) { QTextStream t( &file ); // use a text stream while ( !t.atEnd() ) { 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 (); std::this_thread::sleep_for(std::chrono::microseconds(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); //busy_network(); QString msgtext = "Starting Network..." ; MythScreenStack *popupStack = GetMythMainWindow()->GetStack( "popup stack"); m_progressDialog = new MythUIProgressDialog(msgtext, popupStack, "networkbusy"); if (m_progressDialog->Create()) { popupStack->AddScreen(m_progressDialog, false); } else { delete m_progressDialog; m_progressDialog = NULL; } if (m_progressDialog) m_progressDialog->SetTotal(6); QString cmdtxt; cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it setup_network"); retval = system(qPrintable(cmdtxt)); //int return_code = 0; //while ( return_code == 0 ) //{ // qApp->processEvents (); // std::this_thread::sleep_for(std::chrono::microseconds(900)); // return_code = myth_system("ps -ef|grep install_proxy.sh| grep setup_network |grep -v grep > /dev/null"); //} if (network_check) { network_check->setProgress(2); if ( retval == 0) { m_progressDialog->SetMessage("Checking Network for this Computer..."); m_progressDialog->SetProgress(2); cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it check_self"); retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); pop_text="Could not find myself on the network."; } } } if ( retval == 0) { network_check->setProgress(3); m_progressDialog->SetMessage("Checking Network for the Gateway Server..."); m_progressDialog->SetProgress(3); cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it check_gw"); retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); pop_text="Could not locate the gateway server."; } } if (retval == 0) { network_check->setProgress(4); m_progressDialog->SetMessage("Checking Network for the Nameserver..."); m_progressDialog->SetProgress(4); cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it check_ns"); retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); pop_text="Could not locate nameserver."; } } if (retval == 0) { network_check->setProgress(5); m_progressDialog->SetMessage("Checking the Nameserver..."); m_progressDialog->SetProgress(5); cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it check_names"); retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); pop_text="Could not lookup names."; } } if (retval == 0) { network_check->setProgress(6); m_progressDialog->SetMessage("Checking Network for this Hostname..."); m_progressDialog->SetProgress(6); cmdtxt=MV_ROOT; cmdtxt.append("bin/install_proxy.sh network_check_it host_names"); retval = system(qPrintable(cmdtxt)); if ( retval != 0 ) { network_check->Close(); pop_text="This hostname is already on the network."; } } if (m_progressDialog) { m_progressDialog->Close(); m_progressDialog = NULL; } network_check->setProgress(7); if (network_check) { network_check->Close(); network_check->deleteLater(); } if ( retval != 0 ) { DialogCode val = MythPopupBox::Show2ButtonPopup( GetMythMainWindow(), "", pop_text, tr("Continue"), tr("Try Again"), kDialogCodeButton0); if ( kDialogCodeButton0 == val ) retval = 0; } } } return 0; } void WelcomeDialog::install_it(void) { int sysRet; QString installtype = gCoreContext->GetSetting("HOSTinstallationtype"); if ( installtype != "Upgrade" ) current_hostname = gCoreContext->GetSetting("HostMyhostname"); QString clean_upgrade = getenv("CLEAN_UPGRADE"); if ( clean_upgrade == "YES" ) current_hostname = gCoreContext->GetSetting("HostMyhostname"); if ( installtype == "Full/Auto" ) { QString currentitem; QString line; QFile file("/proc/meminfo"); if ( file.open(QIODevice::ReadOnly | QIODevice::Text) ) { QTextStream t( &file ); // use a text stream line = t.readLine(); if ( line.startsWith("MemTotal:")) { currentitem = line.simplified(); currentitem = currentitem.section( " ", 1, 1 ); } } file.close(); 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 &"); sysRet = system(qPrintable(cmdtxt)); if (sysRet < 0) LOG(VB_GENERAL, LOG_ERR, "Error running install_proxy.sh full_install_it"); } 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 &"); sysRet = system(qPrintable(cmdtxt)); if (sysRet < 0) LOG(VB_GENERAL, LOG_ERR, "Error running install_proxy.sh upgrade_it"); } 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); sysRet = system(qPrintable(cmdtxt)); if (sysRet < 0) LOG(VB_GENERAL, LOG_ERR, "Error running restore_default_settings.sh"); cmdtxt=MV_ROOT ; //cmdtxt.append("bin/install_proxy.sh NETBOOT " + install_drive + " &"); cmdtxt.append("bin/install_proxy.sh NETBOOT &"); sysRet = system(qPrintable(cmdtxt)); if (sysRet < 0) LOG(VB_GENERAL, LOG_ERR, "Error running install_proxy.sh NETBOOT"); } WORKING_ON_INSTALL = true; std::this_thread::sleep_for(std::chrono::microseconds(500)); updateScreen(); std::this_thread::sleep_for(std::chrono::microseconds(500)); updateScreen(); }