[PC-BSD Commits] r5176 - pcbsd/trunk/SysInstaller

svn at pcbsd.org svn at pcbsd.org
Tue Dec 1 10:54:05 PST 2009


Author: kris
Date: 2009-12-01 10:54:05 -0800 (Tue, 01 Dec 2009)
New Revision: 5176

Modified:
   pcbsd/trunk/SysInstaller/backend.cpp
   pcbsd/trunk/SysInstaller/backend.h
   pcbsd/trunk/SysInstaller/dialogSelectNet.cpp
   pcbsd/trunk/SysInstaller/dialogSelectNet.h
   pcbsd/trunk/SysInstaller/dialogSelectNet.ui
   pcbsd/trunk/SysInstaller/sysinstaller.cpp
Log:

Large update, added support for setting up rsync restores, can setup ssh keys, provide listing of life-preserver backups,
etc. Save this info to the cfg as well



Modified: pcbsd/trunk/SysInstaller/backend.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/backend.cpp	2009-12-01 18:20:08 UTC (rev 5175)
+++ pcbsd/trunk/SysInstaller/backend.cpp	2009-12-01 18:54:05 UTC (rev 5176)
@@ -2,6 +2,39 @@
 
 using namespace Scripts;
 
+void Backend::setupSSHKeys(QString Host, QString User, QString Port)
+{
+  QString line;
+
+  QProcess p;
+  QString prog = "xterm";
+  QStringList args;
+  args << "-e" << PCSYSINSTALL << "setup-ssh-keys" << User << Host << Port;
+  p.start(prog, args);
+  if (p.waitForFinished()) {
+  }
+}
+
+QStringList Backend::listRsyncBackups(QString Host, QString User, QString Port)
+{
+    QString line;
+    QStringList backupList;
+
+    Process p(QStringList() << "list-rsync-backups" << User << Host << Port);
+    if (p.waitForFinished()) {
+        while (p.canReadLine()) {
+          line = p.readLine().simplified();
+          backupList = line.split(":");
+          qDebug() << "Found Rsync Backups: " << line;
+        }
+    }
+
+  if ( p.exitCode() != 0 )
+    backupList.clear();
+
+  return backupList;
+}
+
 void Backend::enableNic(QString Nic, QString IP, QString NetMask, QString DNS, QString Gate, bool fetchMirrors)
 {
     QString line;

Modified: pcbsd/trunk/SysInstaller/backend.h
===================================================================
--- pcbsd/trunk/SysInstaller/backend.h	2009-12-01 18:20:08 UTC (rev 5175)
+++ pcbsd/trunk/SysInstaller/backend.h	2009-12-01 18:54:05 UTC (rev 5176)
@@ -38,6 +38,8 @@
 class Backend {
 public:
     static void enableNic(QString Nic, QString IP, QString NetMask, QString DNS, QString Gate, bool fetchMirrors);
+    static void setupSSHKeys(QString Host, QString User, QString Port);
+    static QStringList listRsyncBackups(QString Host, QString User, QString Port);
     static QStringList languages();
     static QStringList keyLayouts();
     static QStringList keyModels();

Modified: pcbsd/trunk/SysInstaller/dialogSelectNet.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/dialogSelectNet.cpp	2009-12-01 18:20:08 UTC (rev 5175)
+++ pcbsd/trunk/SysInstaller/dialogSelectNet.cpp	2009-12-01 18:54:05 UTC (rev 5176)
@@ -52,40 +52,69 @@
 
 }
 
+// Set that we are running rsync not ftp
+void dialogSelectNetServer::setUsingRsync(QString rsyncHost, QString rsyncUser, QString rsyncPort)
+{
+  Host = rsyncHost;
+  User = rsyncUser;
+  Port = rsyncPort;
+  usingRsync = true;
+
+  radioInternet->setText(tr("Selected backup:"));
+  groupNetwork->setHidden(true);
+  radioManual->setHidden(true);
+}
+
 // Start the nic enabling 
 void dialogSelectNetServer::slotEnableNic()
 {
-   // Lets enable the NIC, and fetch our mirror listing
-   Scripts::Backend::enableNic(Nic, IP, Netmask, DNS, Gate, true);
-   labelStatus->setText("");
- 
-   radioInternet->setEnabled(true);
-   comboMirror->setEnabled(false);
-   radioManual->setEnabled(true);
-   groupNetwork->setEnabled(false);
-   pushSelect->setEnabled(true);
-   pushCancel->setEnabled(true);
-   radioChangedSlot();
-
-   QString tmp;
-   // Populate our combo box with the public mirror listing
-   QFile file( "/tmp/mirrors-list.txt" );
-   if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
+   if ( usingRsync) {
+     // Lets enable the NIC, and fetch our backup listing
+     Scripts::Backend::enableNic(Nic, IP, Netmask, DNS, Gate, false);
+     Scripts::Backend::setupSSHKeys(Host, User, Port);
      comboMirror->clear();
-     while ( !file.atEnd() ) {
-       tmp = file.readLine(); // line of text excluding '\n'
-       if ( tmp.indexOf("\n") != -1 )
-         tmp.truncate(tmp.size() -1 );
-       comboMirror->addItem(tmp);
-     }
-     file.close();
+     comboMirror->addItems(Scripts::Backend::listRsyncBackups(Host, User, Port));
+     comboMirror->setEnabled(TRUE);
+     pushCancel->setEnabled(TRUE);
+     if (! comboMirror->currentText().isEmpty())
+        pushSelect->setEnabled(TRUE);
+     else
+        pushSelect->setEnabled(FALSE);
+     
    } else {
-     // No mirrors-list.txt file, so lets disable internet install
-     radioManual->setChecked(true);
-     radioInternet->setEnabled(false);
+     // Enable the NIC, and fetch mirror listing
+     Scripts::Backend::enableNic(Nic, IP, Netmask, DNS, Gate, true);
+
+     radioInternet->setEnabled(true);
      comboMirror->setEnabled(false);
+     radioManual->setEnabled(true);
+     groupNetwork->setEnabled(false);
+     pushSelect->setEnabled(true);
+     pushCancel->setEnabled(true);
+     radioChangedSlot();
+
+     QString tmp;
+     // Populate our combo box with the public mirror listing
+     QFile file( "/tmp/mirrors-list.txt" );
+     if ( file.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
+       comboMirror->clear();
+       while ( !file.atEnd() ) {
+         tmp = file.readLine(); // line of text excluding '\n'
+         if ( tmp.indexOf("\n") != -1 )
+           tmp.truncate(tmp.size() -1 );
+         comboMirror->addItem(tmp);
+       }
+       file.close();
+     } else {
+       // No mirrors-list.txt file, so lets disable internet install
+       radioManual->setChecked(true);
+       radioInternet->setEnabled(false);
+       comboMirror->setEnabled(false);
+     }
+
    }
 
+   labelStatus->setText("");
 }
 
 // Check if the radio has changed
@@ -140,8 +169,12 @@
   if ( radioInternet->isChecked() )
   {
     tmp = comboMirror->currentText();
-    tmp.remove(0, tmp.indexOf("=") + 1);
-    tmp = tmp + "/netinstall";
+    if ( usingRsync) {
+      tmp = "life-preserver/" + tmp;
+    } else {
+      tmp.remove(0, tmp.indexOf("=") + 1);
+      tmp = tmp + "/netinstall";
+    }
     emit saved(tmp);
   } else {
 

Modified: pcbsd/trunk/SysInstaller/dialogSelectNet.h
===================================================================
--- pcbsd/trunk/SysInstaller/dialogSelectNet.h	2009-12-01 18:20:08 UTC (rev 5175)
+++ pcbsd/trunk/SysInstaller/dialogSelectNet.h	2009-12-01 18:54:05 UTC (rev 5176)
@@ -12,9 +12,11 @@
         dialogSelectNetServer() : QDialog()
         {
           setupUi(this);
+          usingRsync = false;
         }
 
     void dialogInit(QString tmpNic, QString tmpIP, QString tmpNetmask, QString tmpDNS, QString tmpGate);
+    void setUsingRsync(QString rsyncHost, QString rsyncUser, QString rsyncPort);
 
 public slots:
 
@@ -32,6 +34,10 @@
     QString Netmask; 
     QString DNS;
     QString Gate;
+    bool usingRsync;
+    QString Host;
+    QString User;
+    QString Port;
 
 signals:
    void saved(QString);

Modified: pcbsd/trunk/SysInstaller/dialogSelectNet.ui
===================================================================
--- pcbsd/trunk/SysInstaller/dialogSelectNet.ui	2009-12-01 18:20:08 UTC (rev 5175)
+++ pcbsd/trunk/SysInstaller/dialogSelectNet.ui	2009-12-01 18:54:05 UTC (rev 5176)
@@ -101,7 +101,7 @@
      </layout>
     </widget>
    </item>
-   <item row="4" column="0">
+   <item row="5" column="0">
     <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
       <widget class="QPushButton" name="pushSelect">
@@ -129,6 +129,19 @@
      </property>
     </widget>
    </item>
+   <item row="4" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>40</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
   </layout>
  </widget>
  <resources/>

Modified: pcbsd/trunk/SysInstaller/sysinstaller.cpp
===================================================================
--- pcbsd/trunk/SysInstaller/sysinstaller.cpp	2009-12-01 18:20:08 UTC (rev 5175)
+++ pcbsd/trunk/SysInstaller/sysinstaller.cpp	2009-12-01 18:54:05 UTC (rev 5176)
@@ -199,9 +199,16 @@
 
 void SysInstaller::slotNext()
 {
+   QString tmp;
+
    // If we've been called on the NIC page, and using network install
    if ( stackWidget->currentIndex() == 2 && radioNetworkInstall->isChecked() ) {
       dsn = new dialogSelectNetServer();
+
+      // If we are doing a rsync restore, set this now
+      if ( radioRestore->isChecked() )
+        dsn->setUsingRsync(lineRsyncHost->text(), lineRsyncUser->text(), tmp.setNum(spinRsyncPort->value()));
+
       dsn->dialogInit(comboSelectNic->currentText(), \
                       lineIP->text(), \
                       lineNetmask->text(), \
@@ -344,16 +351,57 @@
 
   if ( radioRestore->isChecked() )
   {
+    tmpList << "installType=PCBSD";
     tmpList << "installMedium=rsync";
+    tmpList << "";
+    tmpList << "# Rsync Information";
+    tmpList << "rsyncPath=" + netURL;
+    tmpList << "rsyncHost=" + lineRsyncHost->text();
+    tmpList << "rsyncUser=" + lineRsyncUser->text();
+    tmpList << "rsyncPort=" + tmp.setNum(spinRsyncPort->value());
+
   } else {
-    tmpList << "installMedium=dvd";
-
-    if ( radioInstallPCBSD->isChecked() )
+    if ( radioInstallPCBSD->isChecked() ) {
       tmpList << "installType=PCBSD";
-    else
+      tmpList << "packageType=uzip";
+    } else {
       tmpList << "installType=FreeBSD";
+      tmpList << "packageType=tar";
+    }
   }
 
+  // Check if we are doing net or DVD/usb install
+  if ( radioNetworkInstall->isChecked() )
+  {
+    // If this is rsync restore, only print the network settings
+    if ( ! radioRestore->isChecked() ) {
+      tmpList << "installMedium=ftp";
+      tmpList << "ftpPath=" + netURL;
+    } 
+    tmpList << "";
+    tmpList << "# Network Settings";
+    tmpList << "netDev=" + comboSelectNic->currentText();
+    if ( comboSelectNic->currentText() != "AUTO-DHCP" )
+    {
+      tmpList << "netIP=" + lineIP->text();
+      tmpList << "netMask=" + lineNetmask->text();
+      tmpList << "netNameServer=" + lineDNS->text();
+      tmpList << "netDefaultRouter=" + lineDefaultRouter->text();
+    }
+
+    tmpList << "netSaveDev=" + comboSelectNic->currentText();
+    if ( comboSelectNic->currentText() != "AUTO-DHCP" )
+    {
+      tmpList << "netSaveIP=" + lineIP->text();
+      tmpList << "netSaveMask=" + lineNetmask->text();
+      tmpList << "netSaveNameServer=" + lineDNS->text();
+      tmpList << "netSaveDefaultRouter=" + lineDefaultRouter->text();
+    }
+  } else {
+    // Doing a regular DVD/USB install
+    tmpList << "installMedium=dvd";
+  }
+
   if ( comboLanguage->currentIndex() != 0 ) {
     QString lang = languages.at(comboLanguage->currentIndex());
     tmpList << "";



More information about the Commits mailing list