mirror of
https://github.com/tnodir/fort
synced 2024-11-15 05:57:57 +00:00
UI: Add "restart.bat"
This commit is contained in:
parent
e47ba8f627
commit
1cb7c9b457
@ -119,6 +119,9 @@ Type: files; Name: "{app}\curl*.*"
|
|||||||
Type: files; Name: "{app}\ChangeLog"
|
Type: files; Name: "{app}\ChangeLog"
|
||||||
Type: files; Name: "{app}\delay-start.bat"
|
Type: files; Name: "{app}\delay-start.bat"
|
||||||
|
|
||||||
|
[UninstallDelete]
|
||||||
|
Type: files; Name: "{app}\restart.bat"
|
||||||
|
|
||||||
[Registry]
|
[Registry]
|
||||||
Root: HKLM; Subkey: "System\CurrentControlSet\Services\EventLog\System\fortfw"; Flags: uninsdeletekey
|
Root: HKLM; Subkey: "System\CurrentControlSet\Services\EventLog\System\fortfw"; Flags: uninsdeletekey
|
||||||
Root: HKLM; Subkey: "System\CurrentControlSet\Services\EventLog\System\fortfw"; \
|
Root: HKLM; Subkey: "System\CurrentControlSet\Services\EventLog\System\fortfw"; \
|
||||||
|
@ -458,7 +458,8 @@ HEADERS += \
|
|||||||
# Icons, README.*
|
# Icons, README.*
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
fort_icons.qrc \
|
fort_icons.qrc \
|
||||||
fort_readme.qrc
|
fort_readme.qrc \
|
||||||
|
fort_scripts.qrc
|
||||||
|
|
||||||
# Database Migrations
|
# Database Migrations
|
||||||
OTHER_FILES += \
|
OTHER_FILES += \
|
||||||
|
5
src/ui/fort_scripts.qrc
Normal file
5
src/ui/fort_scripts.qrc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<!DOCTYPE RCC><RCC version="1.0">
|
||||||
|
<qresource>
|
||||||
|
<file>scripts/restart.bat</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@ -539,4 +539,5 @@ void FortManager::setupResources()
|
|||||||
Q_INIT_RESOURCE(stat_migrations);
|
Q_INIT_RESOURCE(stat_migrations);
|
||||||
|
|
||||||
Q_INIT_RESOURCE(fort_icons);
|
Q_INIT_RESOURCE(fort_icons);
|
||||||
|
Q_INIT_RESOURCE(fort_scripts);
|
||||||
}
|
}
|
||||||
|
20
src/ui/scripts/restart.bat
Normal file
20
src/ui/scripts/restart.bat
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@rem Restart the UI process after Installer
|
||||||
|
|
||||||
|
@rem Timeout seconds
|
||||||
|
set timeout=30
|
||||||
|
|
||||||
|
:LOOP
|
||||||
|
|
||||||
|
@rem Delay for 1 second
|
||||||
|
ping -n 2 127.0.0.1 >NUL
|
||||||
|
|
||||||
|
@if not exist inst.tmp @goto END
|
||||||
|
|
||||||
|
@set /a timeout=%timeout%-1
|
||||||
|
@if "%timeout%" == "0" @goto END
|
||||||
|
|
||||||
|
@goto LOOP
|
||||||
|
|
||||||
|
|
||||||
|
:END
|
||||||
|
start FortFirewall.exe --launch
|
@ -181,21 +181,39 @@ bool OsUtil::registerAppRestart()
|
|||||||
|
|
||||||
void OsUtil::beginRestartClients()
|
void OsUtil::beginRestartClients()
|
||||||
{
|
{
|
||||||
FileUtil::writeFileData(FileUtil::appBinLocation() + "/inst.tmp", {});
|
const auto appPath = FileUtil::pathSlash(FileUtil::appBinLocation());
|
||||||
|
|
||||||
|
FileUtil::writeFileData(appPath + "inst.tmp", {});
|
||||||
|
|
||||||
|
// Create a restart script
|
||||||
|
{
|
||||||
|
const auto restartScriptPath = appPath + "restart.bat";
|
||||||
|
|
||||||
|
FileUtil::removeFile(restartScriptPath);
|
||||||
|
FileUtil::copyFile(":/scripts/restart.bat", restartScriptPath);
|
||||||
|
QFile::setPermissions(restartScriptPath, QFile::WriteOwner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsUtil::endRestartClients()
|
void OsUtil::endRestartClients()
|
||||||
{
|
{
|
||||||
FileUtil::removeFile(FileUtil::appBinLocation() + "/inst.tmp");
|
const auto appPath = FileUtil::pathSlash(FileUtil::appBinLocation());
|
||||||
|
|
||||||
|
FileUtil::removeFile(appPath + "inst.tmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
void OsUtil::restartClient()
|
void OsUtil::restartClient()
|
||||||
{
|
{
|
||||||
const QFileInfo fi(QCoreApplication::applicationFilePath());
|
const QFileInfo fi(QCoreApplication::applicationFilePath());
|
||||||
|
|
||||||
const auto command = QString("ping -n 4 127.0.0.1 >NUL"
|
QString command;
|
||||||
|
if (FileUtil::fileExists("restart.bat")) {
|
||||||
|
command = "restart.bat";
|
||||||
|
} else {
|
||||||
|
command = QString("ping -n 4 127.0.0.1 >NUL"
|
||||||
" & if not exist inst.tmp start %1 --launch")
|
" & if not exist inst.tmp start %1 --launch")
|
||||||
.arg(fi.fileName());
|
.arg(fi.fileName());
|
||||||
|
}
|
||||||
|
|
||||||
runCommand(command, /*workingDir=*/fi.path());
|
runCommand(command, /*workingDir=*/fi.path());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user