mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-18 10:46:33 +00:00
More install/deploy work for mac...
This commit is contained in:
parent
22b52858e0
commit
59b1623477
@ -37,9 +37,9 @@ SOURCES += main.cpp\
|
|||||||
../node/Topology.cpp \
|
../node/Topology.cpp \
|
||||||
../node/UdpSocket.cpp \
|
../node/UdpSocket.cpp \
|
||||||
../node/Utils.cpp \
|
../node/Utils.cpp \
|
||||||
../ext/lz4/lz4.c \
|
../ext/lz4/lz4.c \
|
||||||
../ext/lz4/lz4hc.c \
|
../ext/lz4/lz4hc.c \
|
||||||
networkwidget.cpp
|
networkwidget.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
aboutwindow.h \
|
aboutwindow.h \
|
||||||
@ -86,13 +86,13 @@ HEADERS += mainwindow.h \
|
|||||||
../node/Thread.hpp \
|
../node/Thread.hpp \
|
||||||
../node/Topology.hpp \
|
../node/Topology.hpp \
|
||||||
../node/UdpSocket.hpp \
|
../node/UdpSocket.hpp \
|
||||||
../ext/lz4/lz4.h \
|
../ext/lz4/lz4.h \
|
||||||
../ext/lz4/lz4hc.h \
|
../ext/lz4/lz4hc.h \
|
||||||
networkwidget.h
|
networkwidget.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui \
|
FORMS += mainwindow.ui \
|
||||||
aboutwindow.ui \
|
aboutwindow.ui \
|
||||||
networkwidget.ui
|
networkwidget.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources.qrc
|
resources.qrc
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
<key>positionOfDivider</key>
|
<key>positionOfDivider</key>
|
||||||
<real>333</real>
|
<real>333</real>
|
||||||
<key>savedFrame</key>
|
<key>savedFrame</key>
|
||||||
<string>36 164 602 597 0 0 1280 778 </string>
|
<string>239 124 602 597 0 0 1280 778 </string>
|
||||||
<key>selectedTabView</key>
|
<key>selectedTabView</key>
|
||||||
<string>event log</string>
|
<string>event log</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
Binary file not shown.
@ -42,7 +42,7 @@
|
|||||||
<key>positionOfDivider</key>
|
<key>positionOfDivider</key>
|
||||||
<real>333</real>
|
<real>333</real>
|
||||||
<key>savedFrame</key>
|
<key>savedFrame</key>
|
||||||
<string>265 106 602 597 0 0 1280 778 </string>
|
<string>68 169 602 597 0 0 1280 778 </string>
|
||||||
<key>selectedTabView</key>
|
<key>selectedTabView</key>
|
||||||
<string>event log</string>
|
<string>event log</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
Binary file not shown.
@ -23,6 +23,8 @@
|
|||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
|
|
||||||
|
QNetworkAccessManager *nam;
|
||||||
|
|
||||||
// Globally visible
|
// Globally visible
|
||||||
ZeroTier::Node::LocalClient *zeroTierClient = (ZeroTier::Node::LocalClient *)0;
|
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) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::MainWindow)
|
ui(new Ui::MainWindow),
|
||||||
|
nam(new QNetworkAccessManager(this))
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
this->startTimer(1000); // poll service every second
|
this->startTimer(1000); // poll service every second
|
||||||
@ -59,6 +62,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
mainWindow = this;
|
mainWindow = this;
|
||||||
this->cyclesSinceResponseFromService = 0;
|
this->cyclesSinceResponseFromService = 0;
|
||||||
|
|
||||||
|
QObject::connect(nam,SIGNAL(finished(QNetworkReply*)),this,SLOT(on_networkReply(QNetworkReply*)));
|
||||||
|
|
||||||
if (ui->networkListWidget->verticalScrollBar())
|
if (ui->networkListWidget->verticalScrollBar())
|
||||||
ui->networkListWidget->verticalScrollBar()->setSingleStep(8);
|
ui->networkListWidget->verticalScrollBar()->setSingleStep(8);
|
||||||
|
|
||||||
@ -79,30 +84,40 @@ void MainWindow::timerEvent(QTimerEvent *event)
|
|||||||
{
|
{
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!zeroTierClient) {
|
if (!zeroTierClient) {
|
||||||
std::string dotAuthFile((QDir::homePath() + QDir::separator() + ".zeroTierOneAuthToken").toStdString());
|
|
||||||
std::string authToken;
|
std::string authToken;
|
||||||
if (!ZeroTier::Utils::readFile(dotAuthFile.c_str(),authToken)) {
|
if (!ZeroTier::Utils::readFile(ZeroTier::Node::LocalClient::authTokenDefaultUserPath().c_str(),authToken)) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// Run the little AppleScript hack that asks for admin credentials and
|
if (QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
|
||||||
// then installs the auth token file in the current user's home.
|
// Run the little AppleScript hack that asks for admin credentials and
|
||||||
QString authHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Authenticate).app/Contents/MacOS/applet");
|
// then installs the auth token file in the current user's home.
|
||||||
if (!QFile::exists(authHelperPath)) {
|
QString authHelperPath(QCoreApplication::applicationDirPath() + "/../Resources/helpers/mac/ZeroTier One (Authenticate).app/Contents/MacOS/applet");
|
||||||
// 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)) {
|
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);
|
QApplication::exit(1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
QProcess::execute(installHelperPath,QStringList());
|
||||||
}
|
}
|
||||||
QProcess::execute(authHelperPath,QStringList());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!ZeroTier::Utils::readFile(dotAuthFile.c_str(),authToken)) {
|
if (!ZeroTier::Utils::readFile(dotAuthFile.c_str(),authToken)) {
|
||||||
@ -291,3 +306,7 @@ void MainWindow::on_addressButton_clicked()
|
|||||||
{
|
{
|
||||||
QApplication::clipboard()->setText(this->myAddress);
|
QApplication::clipboard()->setText(this->myAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_networkReply(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -51,10 +55,12 @@ private slots:
|
|||||||
void on_actionAbout_triggered();
|
void on_actionAbout_triggered();
|
||||||
void on_networkIdLineEdit_textChanged(const QString &text);
|
void on_networkIdLineEdit_textChanged(const QString &text);
|
||||||
void on_addressButton_clicked();
|
void on_addressButton_clicked();
|
||||||
|
void on_networkReply(QNetworkReply *reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
|
||||||
|
QNetworkAccessManager *nam;
|
||||||
QString myAddress;
|
QString myAddress;
|
||||||
QString myStatus;
|
QString myStatus;
|
||||||
QString myVersion;
|
QString myVersion;
|
||||||
|
@ -15,10 +15,19 @@ fi
|
|||||||
if [ $dryRun -gt 0 ]; then
|
if [ $dryRun -gt 0 ]; then
|
||||||
alias ln="echo '>> dry run: ln'"
|
alias ln="echo '>> dry run: ln'"
|
||||||
alias rm="echo '>> dry run: rm'"
|
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 launchctl="echo '>> dry run: launchctl'"
|
||||||
alias zerotier-cli="echo '>> dry run: zerotier-cli'"
|
alias zerotier-cli="echo '>> dry run: zerotier-cli'"
|
||||||
fi
|
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"`"
|
scriptPath="`dirname "$0"`/`basename "$0"`"
|
||||||
if [ ! -r "$scriptPath" ]; then
|
if [ ! -r "$scriptPath" ]; then
|
||||||
scriptPath="$0"
|
scriptPath="$0"
|
||||||
@ -46,11 +55,32 @@ else
|
|||||||
tail -c +$blobStart "$scriptPath" | bunzip2 -c | tar -xvop -C / -f -
|
tail -c +$blobStart "$scriptPath" | bunzip2 -c | tar -xvop -C / -f -
|
||||||
fi
|
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.'
|
echo 'Archive extraction failed, cannot find zerotier-one binary.'
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
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...'
|
echo 'Installing zerotier-cli command line utility...'
|
||||||
|
|
||||||
ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" /usr/bin/zerotier-cli
|
ln -sf "/Library/Application Support/ZeroTier/One/zerotier-one" /usr/bin/zerotier-cli
|
||||||
|
Loading…
Reference in New Issue
Block a user