From 59b1623477e7cd9081d3cf75ea3fa0411214d58f Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 3 Jan 2014 15:39:09 -0800 Subject: [PATCH] More install/deploy work for mac... --- ZeroTierUI/ZeroTierUI.pro | 14 ++--- .../Contents/Info.plist | 2 +- .../Contents/Resources/Scripts/main.scpt | Bin 1768 -> 2214 bytes .../Contents/Info.plist | 2 +- .../Contents/Resources/Scripts/main.scpt | Bin 2818 -> 3946 bytes ZeroTierUI/mainwindow.cpp | 53 ++++++++++++------ ZeroTierUI/mainwindow.h | 6 ++ ext/installfiles/mac/install.tmpl.sh | 32 ++++++++++- 8 files changed, 82 insertions(+), 27 deletions(-) diff --git a/ZeroTierUI/ZeroTierUI.pro b/ZeroTierUI/ZeroTierUI.pro index 082477ca3..1b7355537 100644 --- a/ZeroTierUI/ZeroTierUI.pro +++ b/ZeroTierUI/ZeroTierUI.pro @@ -37,9 +37,9 @@ SOURCES += main.cpp\ ../node/Topology.cpp \ ../node/UdpSocket.cpp \ ../node/Utils.cpp \ - ../ext/lz4/lz4.c \ - ../ext/lz4/lz4hc.c \ - networkwidget.cpp + ../ext/lz4/lz4.c \ + ../ext/lz4/lz4hc.c \ + networkwidget.cpp HEADERS += mainwindow.h \ aboutwindow.h \ @@ -86,13 +86,13 @@ HEADERS += mainwindow.h \ ../node/Thread.hpp \ ../node/Topology.hpp \ ../node/UdpSocket.hpp \ - ../ext/lz4/lz4.h \ - ../ext/lz4/lz4hc.h \ - networkwidget.h + ../ext/lz4/lz4.h \ + ../ext/lz4/lz4hc.h \ + networkwidget.h FORMS += mainwindow.ui \ aboutwindow.ui \ - networkwidget.ui + networkwidget.ui RESOURCES += \ resources.qrc diff --git a/ZeroTierUI/helpers/mac/ZeroTier One (Authenticate).app/Contents/Info.plist b/ZeroTierUI/helpers/mac/ZeroTier One (Authenticate).app/Contents/Info.plist index ca85986a9..c658bc21b 100644 --- a/ZeroTierUI/helpers/mac/ZeroTier One (Authenticate).app/Contents/Info.plist +++ b/ZeroTierUI/helpers/mac/ZeroTier One (Authenticate).app/Contents/Info.plist @@ -44,7 +44,7 @@ positionOfDivider 333 savedFrame - 36 164 602 597 0 0 1280 778 + 239 124 602 597 0 0 1280 778 selectedTabView event log diff --git a/ZeroTierUI/helpers/mac/ZeroTier One (Authenticate).app/Contents/Resources/Scripts/main.scpt b/ZeroTierUI/helpers/mac/ZeroTier One (Authenticate).app/Contents/Resources/Scripts/main.scpt index cb578574d16dac0c86545454f3d933d346b7cfe0..5707e8e4fffbe11cb8255f5511953fc5097b6027 100644 GIT binary patch delta 1022 zcmYLINmCO+6#ixsl*-r>21H08BoKzM7*^T$eL2WMZ&q2wk}8!z*g1H>i=4&$2QQXY z_!lgGfn^oQCbIAQ$;2&R&o5cyw%XFxN0B@(l1-D>`+bPIEreIJ;W9J4uIy_LmBFjJ)9%2+D7{+T%!iONn z83O{DP$En>kW5z^T}6{@E|=T7B87dtI=u1!>5?u4{8kaXL+8ka>7a8iVm{YO+KnRQ$t?2z*#*c)fnbOg8O$=RvV~}zEu~T zm6jx|CY@W(J2y3 zVV{`_O#%WX)>SMR>U7k}tLhEZ!)`SsXu0~4OD7tg#G)5jE+*^Lprb*$G#Y5cM;SdD zw0oQdmRA7zbga=ad-;+JShgk|O_JVhpc%7FpPj!46E-?R3mrOmvO5L`hDQZjtQagW z9XRL!iP~T!GCMsv6S_x-velOoE@Z!Rc(l^KK&#bnem}HFyR@Uwo+Rx`*kLB^13Hu8 zOoEMr{ze-_yTUWS-!>*~N0$<^=5@5=eiHpc2W`(GOJA)zEeUM zleG+5qn}8jRsLJN{1$4sDGg|%6$h;?PGlGwpZ;&4MysrD+EWLu#I-YM1LfOq9zf~* v-oG20fAsG!n+K*`_a82sN9H&4*jzSGc$}JNp)l_|F)%eW2?gTM*4CH5WfSRk literal 1768 zcmbVNTT>HR5dLNeA>C=5qpVMD=pYHseuZ$fZI@Udq z9mwh70Ei_;V8BG3K?aJvaf<8uieelkky83FD@G z)Sy}Qk}XR}Ex~XK`8y?CKCK9YxAPN`q~7(M+%&3IW`1oHym22J3zY`_`7XXwD&_!JhO>UdSCG zXUGQ){JjS5aI|2JA_;&uA%j+VBd--&L!exdztDzuOHV6AwGHMdBh`c+tVM?+iR3P< zL#HB%Q$+Cg266x zZ-g3}>&GzlJkEJ)R+)w>cTaI;0$Efz7pUcNHKQ#nYz{NyGUKmoc~v7bit2$ADJHnj zL7#SFtBb8TKvP+q}JEV{f0WjC{(w3LY-m$`l&}b{O zoONi1M*CeFjD^^H!lUh2D=%z$Q4@Ptcufa0%>vKqYX)2l;Ftf2y+nV;2qA}^9Jvro zX9$LGNS@pBye62A5KI?O4LTUqV79r~M(_SpAmeC9ojk*Kd1`TrS)=)}lEU`zcD_@2 zV#yOE>`~u8T`f;}ae1nX>y0L_b%m|r*ddDwJHGZY$b!tvoFNNZXE>PwrY2YhSOh=WDCZV84m|bg>=>Oukax1`nDzNTx;Z zm~uyZcTamatv%SQ$v(DRTW-srNXac0Y9Eu5!=T)>G+% z%3W-_|9c~h!`Fvrg89bq?6vgc^wsoS`dWIPVpositionOfDivider 333 savedFrame - 265 106 602 597 0 0 1280 778 + 68 169 602 597 0 0 1280 778 selectedTabView event log diff --git a/ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Resources/Scripts/main.scpt b/ZeroTierUI/helpers/mac/ZeroTier One (Install).app/Contents/Resources/Scripts/main.scpt index 6aff34e8ee721e30170dcd754c14c7c1ea9c06b6..af0d80f5cc7bc1c79b47314e45a29b91313f9694 100644 GIT binary patch literal 3946 zcmc&%S#wlH6#ixsLb#W{$t5TtE<OtVhC2pBHBi# z$}tX?V7wvZ+hcGkE;EFD`yyP9D-0puu0RYE48dB3B%v}ur7Aix#6)hbYWC1B9UN1G z+4dhpmB9q3Z%7`$_2t_F`WotFm#!dfR|dFJmyU;sV?C;I8`hx>85%u<&1~Pynr@gv zmaUa6Gu*m`qqJ6y1bSKf_Z!#W%(q$OxJEbsI-?46C^m(?%n3`j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ig)ohX7aYBg3xpe+_Gud1ksNEOif06{I7=vo)Xxbg`iil~U7h=96xb3C`x5EFHh`^|UmoO|AP=GI(Yap#7rv{?_FA!|hK zQCiY0&${V|6>LI2EzrC`KGa?SUTi`E3I&6s7Ang=nuDLdX*74eXLXJrN>@s49Rdad zQ0^jVB4~|e+#dV}2oyp|vI0LetJ5r21d$mZ=x^^&b|kuO8k1C^1wf&Bu#+vkim+8M zI69ecMjb-*m1YD&a5l3oxl@c1`a+)t6E%|B%f~i^1w+bZ&=ks1q0tm)Jy;I4jXnBNg-S#OLt2htJ9Y?$v|NFm zs1gimxeU9oTQH>MF!rEYFr?)Y>_v@WNXsGYL#<#)%SG6aI+4qmD!ZR69yJh^aUU>o zz`C4y&0S}wA3%^k>Ga9+x>l~Owe`8EIB4LY)UP*D&w&Owi%ZrONA_S92GEao#E?V> z66ogES8&76@Lm!ZSoR9k*v3OBrb(S9;R?bz(3jv*5vaDElyCzY3^Yh5jV2o5lv5!=5UbObFte0@w4*Gzj^j_naQ)`Q#?GiX@TjK`O zJB{AKrMD%M=lgpH5=-bkk1c(X1N>RSR|zw6l(+IaM&km<>`|8Y;4O{O8-?CVrNS|Z zZ{+cDz+i2-J#eu9*Eo(QggM27NGIz1tw1txTQ zLC>*_o?$&UU?V+6fS&MWiSi&daFb#hy+E$N?_!@-W8}D>|1lIgJ>yQ~Uvftj3y!N51dAhrS=aN4}rD;_&!p6P>Kl1V_6&-gl-K L3bKApOx*en!5%KT diff --git a/ZeroTierUI/mainwindow.cpp b/ZeroTierUI/mainwindow.cpp index 4028b7893..521868ccc 100644 --- a/ZeroTierUI/mainwindow.cpp +++ b/ZeroTierUI/mainwindow.cpp @@ -23,6 +23,8 @@ #include #include +QNetworkAccessManager *nam; + // Globally visible ZeroTier::Node::LocalClient *zeroTierClient = (ZeroTier::Node::LocalClient *)0; @@ -51,7 +53,8 @@ static void handleZTMessage(void *arg,unsigned long id,const char *line) MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), - ui(new Ui::MainWindow) + ui(new Ui::MainWindow), + nam(new QNetworkAccessManager(this)) { ui->setupUi(this); this->startTimer(1000); // poll service every second @@ -59,6 +62,8 @@ MainWindow::MainWindow(QWidget *parent) : mainWindow = this; this->cyclesSinceResponseFromService = 0; + QObject::connect(nam,SIGNAL(finished(QNetworkReply*)),this,SLOT(on_networkReply(QNetworkReply*))); + if (ui->networkListWidget->verticalScrollBar()) ui->networkListWidget->verticalScrollBar()->setSingleStep(8); @@ -79,30 +84,40 @@ void MainWindow::timerEvent(QTimerEvent *event) { event->accept(); -#ifdef __APPLE__ -#else -#endif - if (!zeroTierClient) { - std::string dotAuthFile((QDir::homePath() + QDir::separator() + ".zeroTierOneAuthToken").toStdString()); std::string authToken; - if (!ZeroTier::Utils::readFile(dotAuthFile.c_str(),authToken)) { + if (!ZeroTier::Utils::readFile(ZeroTier::Node::LocalClient::authTokenDefaultUserPath().c_str(),authToken)) { #ifdef __APPLE__ - // Run the little AppleScript hack that asks for admin credentials and - // then installs the auth token file in the current user's home. - 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("/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. + QString authHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/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); + // 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; + } + } + QProcess::execute(authHelperPath,QStringList()); + } else { + // Download the latest version and install it + this->setEnabled(false); + + // 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()); } - QProcess::execute(authHelperPath,QStringList()); #endif if (!ZeroTier::Utils::readFile(dotAuthFile.c_str(),authToken)) { @@ -291,3 +306,7 @@ void MainWindow::on_addressButton_clicked() { QApplication::clipboard()->setText(this->myAddress); } + +void MainWindow::on_networkReply(QNetworkReply *reply) +{ +} diff --git a/ZeroTierUI/mainwindow.h b/ZeroTierUI/mainwindow.h index f4ca51b45..d3ec15d89 100644 --- a/ZeroTierUI/mainwindow.h +++ b/ZeroTierUI/mainwindow.h @@ -4,6 +4,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -51,10 +55,12 @@ private slots: void on_actionAbout_triggered(); void on_networkIdLineEdit_textChanged(const QString &text); void on_addressButton_clicked(); + void on_networkReply(QNetworkReply *reply); private: Ui::MainWindow *ui; + QNetworkAccessManager *nam; QString myAddress; QString myStatus; QString myVersion; diff --git a/ext/installfiles/mac/install.tmpl.sh b/ext/installfiles/mac/install.tmpl.sh index fcb3b69ba..a1675b1db 100644 --- a/ext/installfiles/mac/install.tmpl.sh +++ b/ext/installfiles/mac/install.tmpl.sh @@ -15,10 +15,19 @@ fi if [ $dryRun -gt 0 ]; then alias ln="echo '>> dry run: ln'" alias rm="echo '>> dry run: rm'" + alias mv="echo '>> dry run: mv'" + alias chown="echo '>> dry run: chown'" + alias chgrp="echo '>> dry run: chgrp'" alias launchctl="echo '>> dry run: launchctl'" alias zerotier-cli="echo '>> dry run: zerotier-cli'" fi +zthome="/Library/Application Support/ZeroTier/One" +ztapp=`mdfind kMDItemCFBundleIdentifier == 'com.zerotier.ZeroTierOne'` +if [ ! -d "$ztapp" ]; then + ztapp="/Applications/ZeroTier One.app" +fi + scriptPath="`dirname "$0"`/`basename "$0"`" if [ ! -r "$scriptPath" ]; then scriptPath="$0" @@ -46,11 +55,32 @@ else tail -c +$blobStart "$scriptPath" | bunzip2 -c | tar -xvop -C / -f - fi -if [ $dryRun -eq 0 -a ! -f "/Library/LaunchDaemons/com.zerotier.one.plist" ]; then +if [ $dryRun -eq 0 -a ! -d "/Applications/ZeroTierOne_app.LATEST" ]; then echo 'Archive extraction failed, cannot find zerotier-one binary.' exit 2 fi +echo 'Installing/updating ZeroTier One.app...' + +if [ -d "$ztapp" ]; then + # Preserve ownership of existing .app and install new version in the + # same location. + currentAppOwner=`stat -f '%u' "$ztapp"` + currentAppGroup=`stat -f '%g' "$ztapp"` + if [ ! -z "$currentAppOwner" -a ! -z "$currentAppGroup" ]; then + rm -rf "$ztapp" + mv -f "/Application/ZeroTierOne_app.LATEST" "$ztapp" + chown -R $currentAppOwner "$ztapp" + chgrp -R $currentAppGroup "$ztapp" + else + rm -rf "$ztapp" + mv -f "/Application/ZeroTierOne_app.LATEST" "$ztapp" + fi +else + # If there is no existing app, just drop the shipped one into place + mv -f "/Applications/ZeroTierOne_app.LATEST" "/Applications/ZeroTierOne.app" +fi + echo 'Installing zerotier-cli command line utility...' ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" /usr/bin/zerotier-cli