Browse Source

Mac install fixes, more internal use scripts.

Adam Ierymenko 11 years ago
parent
commit
3482d836ae

+ 4 - 1
ZeroTierUI/aboutwindow.cpp

@@ -2,13 +2,16 @@
 #include "ui_aboutwindow.h"
 
 #include <QMessageBox>
-#include "../node/Defaults.hpp"
+
+#include "../node/Node.hpp"
 
 AboutWindow::AboutWindow(QWidget *parent) :
 	QDialog(parent),
 	ui(new Ui::AboutWindow)
 {
 	ui->setupUi(this);
+
+	ui->aboutTextLabel->setText(QString("ZeroTier One\nVersion ")+ZeroTier::Node::versionString()+"\nQt Graphical User Interface\n\n(c)2011-2014 ZeroTier Networks LLC\n\nReleased under the terms of the GNU\nGeneral Public License v3.0, see: http://gplv3.fsf.org for terms.\n\nAuthor(s): Adam Ierymenko");
 }
 
 AboutWindow::~AboutWindow()

+ 0 - 7
ZeroTierUI/aboutwindow.ui

@@ -151,13 +151,6 @@
              <bold>false</bold>
             </font>
            </property>
-           <property name="text">
-            <string>ZeroTier One GUI
-(c)2012-2013 ZeroTier Networks LLC
-
-Author(s): Adam Ierymenko
-Version: 1.0</string>
-           </property>
            <property name="textFormat">
             <enum>Qt::PlainText</enum>
            </property>

BIN
ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Resources/Scripts/main.scpt


+ 6 - 8
ZeroTierUI/installdialog.cpp

@@ -106,16 +106,14 @@ void InstallDialog::on_networkReply(QNetworkReply *reply)
 						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;
-					}
+					// Terminate the GUI and execute the install helper instead
+					::execl(installHelperPath.toStdString().c_str(),installHelperPath.toStdString().c_str(),(const char *)0);
+
+					// We only make it here if execl() failed
+					QMessageBox::critical(this,"Unable to Locate Helper","Unable to locate install helper, cannot install service.",QMessageBox::Ok,QMessageBox::NoButton);
+					QApplication::exit(1);
 
-					((QMainWindow *)this->parent())->setHidden(false);
-					this->close();
 					return;
 #endif
 				}	break;

+ 18 - 11
ZeroTierUI/mainwindow.cpp

@@ -69,6 +69,19 @@ MainWindow::MainWindow(QWidget *parent) :
 	QWidgetList widgets = this->findChildren<QWidget*>();
 	foreach(QWidget* widget, widgets)
 		widget->setAttribute(Qt::WA_MacShowFocusRect,false);
+
+#ifdef __APPLE__
+	if (!QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
+		// If the service is not installed, download the installer and run it
+		// for the first time.
+		this->setEnabled(false);
+		InstallDialog *id = new InstallDialog(this);
+		id->setModal(true);
+		id->show();
+		this->setHidden(true);
+		return;
+	}
+#endif
 }
 
 MainWindow::~MainWindow()
@@ -90,21 +103,15 @@ void MainWindow::timerEvent(QTimerEvent *event)
 		std::string authToken;
 		if (!ZeroTier::Utils::readFile(ZeroTier::Node::LocalClient::authTokenDefaultUserPath().c_str(),authToken)) {
 #ifdef __APPLE__
-			//if (QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
-			if (false) {
+			if (QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
 				// Run the little AppleScript hack that asks for admin credentials and
 				// then installs the auth token file in the current user's home.
+				QMessageBox::information(this,"Authorization Required","You must authenticate to authorize this user to\nadministrate ZeroTier One on this computer.\n\n(This only needs to be done once.)",QMessageBox::Ok,QMessageBox::NoButton);
 				QString authHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Authenticate).app/Contents/MacOS/applet");
 				if (!QFile::exists(authHelperPath)) {
-					// Allow this to also work from the source tree if it's run from there.
-					// This is for debugging purposes and shouldn't harm the live release
-					// in any way.
-					authHelperPath = QCoreApplication::applicationDirPath() + "/../../../../ZeroTierUI/helpers/mac/ZeroTier One (Authenticate).app/Contents/MacOS/applet";
-					if (!QFile::exists(authHelperPath)) {
-						QMessageBox::critical(this,"Unable to Locate Helper","Unable to locate authorization helper, cannot obtain authentication token.",QMessageBox::Ok,QMessageBox::NoButton);
-						QApplication::exit(1);
-						return;
-					}
+					QMessageBox::critical(this,"Unable to Locate Helper","Unable to locate authorization helper, cannot obtain authentication token.",QMessageBox::Ok,QMessageBox::NoButton);
+					QApplication::exit(1);
+					return;
 				}
 				QProcess::execute(authHelperPath,QStringList());
 			} else {

+ 2 - 9
attic/make-official-release.sh

@@ -18,8 +18,8 @@
 
 export PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
-if [ "$#" -ne 2 ]; then
-	echo "Usage: $0 <path to secret signing identity> <path to destination folder for .nfo and installer>"
+if [ "$#" -ne 1 ]; then
+	echo "Usage: $0 <path to secret signing identity>"
 	exit 1
 fi
 
@@ -29,16 +29,11 @@ if [ ! -e zerotier-idtool ]; then
 fi
 
 secret="$1"
-dest="$2"
 
 if [ ! -e "$secret" ]; then
 	echo "Can't find $secret"
 	exit 1
 fi
-if [ ! -d "$dest" ]; then
-	echo "Can't find $dest directory"
-	exit 1
-fi
 
 for inst in `ls ZeroTierOneInstaller-*-*-*_*_*`; do
 	echo "Found installer: $inst"
@@ -51,6 +46,4 @@ for inst in `ls ZeroTierOneInstaller-*-*-*_*_*`; do
 	echo "signedBy=`cat $secret | cut -d : -f 1`" >>"$nfo"
 	echo "ed25519=`./zerotier-idtool sign $secret $inst`" >>"$nfo"
 	echo "url=http://download.zerotier.com/$inst" >>"$nfo"
-	cp $inst $nfo $dest
-	rm -f $nfo
 done

+ 5 - 0
attic/submit-official-release.sh

@@ -0,0 +1,5 @@
+#!/bin/bash
+
+# Completely useless to outsiders. :)
+
+scp ZeroTierOneInstaller-*-*-*_*_* nyarlathotep.zerotier.com:/www/download.zerotier.com/htdocs

+ 1 - 1
ext/installfiles/mac/install.tmpl.sh

@@ -23,7 +23,7 @@ if [ $dryRun -gt 0 ]; then
 fi
 
 zthome="/Library/Application Support/ZeroTier/One"
-ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne'`
+ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne' | sort | head -n 1`
 if [ ! -d "$ztapp" ]; then
 	ztapp="/Applications/ZeroTier One.app"
 fi

+ 1 - 1
ext/installfiles/mac/launch.sh

@@ -2,7 +2,7 @@
 
 zthome="/Library/Application Support/ZeroTier/One"
 export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$zthome"
-ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne'`
+ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne' | sort | head -n 1`
 
 # Clean all other stuff off the system if the user has trashed the .app
 if [ -z "$ztapp" -o ! -d "$ztapp" ]; then

+ 1 - 1
ext/installfiles/mac/uninstall.sh

@@ -3,7 +3,7 @@
 export PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
 zthome="/Library/Application Support/ZeroTier/One"
-ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne'`
+ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne' | sort | head -n 1`
 
 if [ "$UID" -ne 0 ]; then
 	echo "Must be run as root; try: sudo $0"

+ 0 - 4
node/Defaults.cpp

@@ -132,12 +132,8 @@ static inline const char *_mkUpdateUrl()
 #endif
 
 #ifdef __APPLE__
-#ifdef TARGET_OS_IPHONE
-	// TODO
-#else
 	return "http://download.zerotier.com/ZeroTierOneInstaller-mac-combined-LATEST.nfo";
 #define GOT_UPDATE_URL
-#endif
 #endif
 
 	// TODO: Windows