mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 20:13:44 +02:00
Ready to test app-driven service install on Mac.
This commit is contained in:
parent
a19c19c58c
commit
e525e3a571
4 changed files with 52 additions and 16 deletions
|
@ -42,7 +42,7 @@
|
||||||
<key>positionOfDivider</key>
|
<key>positionOfDivider</key>
|
||||||
<real>333</real>
|
<real>333</real>
|
||||||
<key>savedFrame</key>
|
<key>savedFrame</key>
|
||||||
<string>68 169 602 597 0 0 1280 778 </string>
|
<string>57 445 602 597 0 0 1920 1058 </string>
|
||||||
<key>selectedTabView</key>
|
<key>selectedTabView</key>
|
||||||
<string>event log</string>
|
<string>event log</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
Binary file not shown.
|
@ -2,13 +2,25 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_installdialog.h"
|
#include "ui_installdialog.h"
|
||||||
|
|
||||||
|
#include "../node/Constants.hpp"
|
||||||
#include "../node/Defaults.hpp"
|
#include "../node/Defaults.hpp"
|
||||||
#include "../node/SoftwareUpdater.hpp"
|
#include "../node/SoftwareUpdater.hpp"
|
||||||
|
|
||||||
|
#ifdef __UNIX_LIKE__
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QSslSocket>
|
#include <QSslSocket>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
InstallDialog::InstallDialog(QWidget *parent) :
|
InstallDialog::InstallDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
|
@ -40,7 +52,7 @@ void InstallDialog::on_networkReply(QNetworkReply *reply)
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
|
|
||||||
if (reply->error() != QNetworkReply::NoError) {
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
QMessageBox::critical(this,"Download Failed",QString("Download failed: ") + reply->errorString(),QMessageBox::Ok,QMessageBox::NoButton);
|
QMessageBox::critical(this,"Download Failed",QString("Download failed: ") + reply->errorString() + "\n\nAre you connected to the Internet?",QMessageBox::Ok,QMessageBox::NoButton);
|
||||||
QApplication::exit(1);
|
QApplication::exit(1);
|
||||||
} else {
|
} else {
|
||||||
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
|
if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
|
||||||
|
@ -68,6 +80,44 @@ void InstallDialog::on_networkReply(QNetworkReply *reply)
|
||||||
QApplication::exit(1);
|
QApplication::exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
QString zt1Caches(QDir::homePath() + "/Library/Caches/ZeroTier/One");
|
||||||
|
QDir::root().mkpath(zt1Caches);
|
||||||
|
QString instPath(zt1Caches+"/ZeroTierOneInstaller");
|
||||||
|
|
||||||
|
int outfd = ::open(instPath.toStdString().c_str(),O_CREAT|O_TRUNC|O_WRONLY,0755);
|
||||||
|
if (outfd <= 0) {
|
||||||
|
QMessageBox::critical(this,"Download Failed",QString("Installation failed: unable to write to ")+instPath,QMessageBox::Ok,QMessageBox::NoButton);
|
||||||
|
QApplication::exit(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (::write(outfd,installerData.data(),installerData.length()) != installerData.length()) {
|
||||||
|
QMessageBox::critical(this,"Installation Failed",QString("Installation failed: unable to write to ")+instPath,QMessageBox::Ok,QMessageBox::NoButton);
|
||||||
|
QApplication::exit(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
::close(outfd);
|
||||||
|
::chmod(instPath.toStdString().c_str(),0755);
|
||||||
|
|
||||||
|
QString installHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Install).app/Contents/MacOS/applet");
|
||||||
|
if (!QFile::exists(installHelperPath)) {
|
||||||
|
QMessageBox::critical(this,"Unable to Locate Helper","Unable to locate install helper, cannot install service.",QMessageBox::Ok,QMessageBox::NoButton);
|
||||||
|
QApplication::exit(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QProcess::execute(installHelperPath,QStringList());
|
||||||
|
|
||||||
|
if (!QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
|
||||||
|
QMessageBox::critical(this,"Installation Failed","Installation failed. Are you sure you entered your password correctly?",QMessageBox::Ok,QMessageBox::NoButton);
|
||||||
|
QApplication::exit(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
((QMainWindow *)this->parent())->setHidden(false);
|
||||||
|
this->close();
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,8 +136,6 @@ void InstallDialog::on_InstallDialog_rejected()
|
||||||
QApplication::exit();
|
QApplication::exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
//((QMainWindow *)this->parent())->setHidden(false);
|
|
||||||
|
|
||||||
void InstallDialog::on_cancelButton_clicked()
|
void InstallDialog::on_cancelButton_clicked()
|
||||||
{
|
{
|
||||||
QApplication::exit();
|
QApplication::exit();
|
||||||
|
|
|
@ -116,18 +116,6 @@ void MainWindow::timerEvent(QTimerEvent *event)
|
||||||
id->show();
|
id->show();
|
||||||
this->setHidden(true);
|
this->setHidden(true);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Run the little AppleScript hack that asks for admin credentials and
|
|
||||||
// then installs the auth token file in the current user's home.
|
|
||||||
/*
|
|
||||||
QString installHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Install).app/Contents/MacOS/applet");
|
|
||||||
if (!QFile::exists(installHelperPath)) {
|
|
||||||
QMessageBox::critical(this,"Unable to Locate Helper","Unable to locate install helper, cannot install service.",QMessageBox::Ok,QMessageBox::NoButton);
|
|
||||||
QApplication::exit(1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QProcess::execute(installHelperPath,QStringList());
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue