Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#include "configurator.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QProcess>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
QStringList arguments = app.arguments();
|
||||
|
||||
if (arguments.count() < 2)
|
||||
{
|
||||
qWarning() << "usage:" << arguments.at(0)
|
||||
<< "<project name (" << Configurator::projectNames().join(QStringLiteral(", ")) << ")>";
|
||||
return -1;
|
||||
}
|
||||
|
||||
QString projectName = arguments.at(1);
|
||||
if (!Configurator::projectNames().contains(projectName))
|
||||
{
|
||||
QMessageBox::critical(nullptr, QString(),
|
||||
QStringLiteral("Unknown project. Available project names: %1").arg(
|
||||
Configurator::projectNames().join(QStringLiteral(", "))));
|
||||
return -2;
|
||||
}
|
||||
|
||||
bool isDebug = (arguments.count() > 2 && arguments.at(2) == QStringLiteral("debug"));
|
||||
|
||||
if (!isDebug)
|
||||
{
|
||||
// restart if not root
|
||||
uid_t uid = getuid();
|
||||
|
||||
if (uid != 0) // root
|
||||
{
|
||||
QProcess::startDetached(QStringLiteral("xgd-su -c %1 %2").arg(arguments.at(0), projectName));
|
||||
//qWarning() << "wrong uid" << uid;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Configurator *c = new Configurator(projectName);
|
||||
c->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
Reference in new issue
Block a user