diff --git a/scripts/ci/osx/after_success.sh b/scripts/ci/osx/after_success.sh index 76c0eebd..d7a7a898 100755 --- a/scripts/ci/osx/after_success.sh +++ b/scripts/ci/osx/after_success.sh @@ -38,9 +38,10 @@ cat build/$APP.app/Contents/Info.plist cp build/moolticuted build/$APP.app/Contents/MacOS/ #Get 3rd party tools -wget_retry https://calaos.fr/mooltipass/tools/macos/mc-agent -O build/$APP.app/Contents/MacOS/mc-agent -wget_retry https://calaos.fr/mooltipass/tools/macos/mc-cli -O build/$APP.app/Contents/MacOS/mc-cli -chmod +x build/$APP.app/Contents/MacOS/mc-agent build/$APP.app/Contents/MacOS/mc-cli +mkdir -p build/$APP.app/Contents/MacOS/cli +wget_retry https://calaos.fr/mooltipass/tools/macos/mc-agent -O build/$APP.app/Contents/MacOS/cli/mc-agent +wget_retry https://calaos.fr/mooltipass/tools/macos/mc-cli -O build/$APP.app/Contents/MacOS/cli/mc-cli +chmod +x build/$APP.app/Contents/MacOS/cli/mc-agent build/$APP.app/Contents/MacOS/cli/mc-cli # use macdeployqt to deploy the application echo "Calling macdeployqt" diff --git a/src/AppGui.cpp b/src/AppGui.cpp index d3375c24..16edc8f6 100644 --- a/src/AppGui.cpp +++ b/src/AppGui.cpp @@ -294,7 +294,7 @@ void AppGui::startSSHAgent() if (s.value("settings/auto_start_ssh").toBool()) { sshAgentProcess = new QProcess(this); - QString program = QCoreApplication::applicationDirPath () + "/mc-agent"; + QString program = QCoreApplication::applicationDirPath () + "/cli/mc-agent"; QStringList arguments; #ifndef Q_OS_WIN arguments << "--no-fork"; diff --git a/src/SSHManagement.cpp b/src/SSHManagement.cpp index ac78f30a..ed63c0e0 100644 --- a/src/SSHManagement.cpp +++ b/src/SSHManagement.cpp @@ -101,7 +101,7 @@ void SSHManagement::onServiceExists(const QString service, bool exists) if (exists) { sshProcess = new QProcess(this); - const auto program = QCoreApplication::applicationDirPath () + "/mc-agent"; + const auto program = QCoreApplication::applicationDirPath () + "/cli/mc-agent"; auto actualProg = program; #ifdef Q_OS_WIN actualProg += ".exe"; @@ -386,7 +386,7 @@ void SSHManagement::on_pushButtonImport_clicked() currentAction = Action::ImportKey; sshProcess = new QProcess(this); - QString program = QCoreApplication::applicationDirPath () + "/mc-agent"; + QString program = QCoreApplication::applicationDirPath () + "/cli/mc-agent"; QStringList arguments; arguments << "--output_progress" << "cli" @@ -432,7 +432,7 @@ void SSHManagement::on_pushButtonDelete_clicked() currentAction = Action::DeleteKey; sshProcess = new QProcess(this); - QString program = QCoreApplication::applicationDirPath () + "/mc-agent"; + QString program = QCoreApplication::applicationDirPath () + "/cli/mc-agent"; QStringList arguments; arguments << "--output_progress" << "cli" diff --git a/win/installer.iss b/win/installer.iss index 02fc0734..f4c84686 100644 --- a/win/installer.iss +++ b/win/installer.iss @@ -57,7 +57,6 @@ Filename: "{app}\moolticute.exe"; WorkingDir: "{app}"; Description: "Start Moolt [Registry] Root: "HKCU"; Subkey: "SOFTWARE\Microsoft\Windows\CurrentVersion\Run"; ValueType: string; ValueName: "Moolticute"; ValueData: "{app}\moolticute.exe --autolaunched"; Flags: uninsdeletevalue -Root: "HKCU"; Subkey: "Environment"; ValueType: expandsz; ValueName: "PATH"; ValueData: "{olddata};{app}\cli" [Code] function IsAppRunning(const FileName : string): Boolean; @@ -186,3 +185,87 @@ begin ShellExec('', ExpandConstant('{sys}\taskkill.exe'),'/f /im SnoreToast.exe', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode); END end; + +const EnvironmentKey = 'Environment'; + +procedure EnvAddPath(instlPath: string); +var + Paths: string; +begin + { Retrieve current path (use empty string if entry not exists) } + if not RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', Paths) then + Paths := ''; + + if Paths = '' then + Paths := instlPath + ';' + else + begin + { Skip if string already found in path } + if Pos(';' + Uppercase(instlPath) + ';', ';' + Uppercase(Paths) + ';') > 0 then exit; + if Pos(';' + Uppercase(instlPath) + '\;', ';' + Uppercase(Paths) + ';') > 0 then exit; + + { Append App Install Path to the end of the path variable } + Log(Format('Right(Paths, 1): [%s]', [Paths[length(Paths)]])); + if Paths[length(Paths)] = ';' then + Paths := Paths + instlPath + ';' { don't double up ';' in env(PATH) } + else + Paths := Paths + ';' + instlPath + ';' ; + end; + + { Overwrite (or create if missing) path environment variable } + if RegWriteStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', Paths) + then Log(Format('The [%s] added to PATH: [%s]', [instlPath, Paths])) + else Log(Format('Error while adding the [%s] to PATH: [%s]', [instlPath, Paths])); +end; + +procedure EnvRemovePath(instlPath: string); +var + Paths: string; + P, Offset, DelimLen: Integer; +begin + { Skip if registry entry not exists } + if not RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', Paths) then + exit; + + P := 1; + + { Remove all occurences of instlPath to fix issue created by old installer } + while P > 0 do + begin + { Skip if string not found in path } + DelimLen := 1; { Length(';') } + P := Pos(';' + Uppercase(instlPath) + ';', ';' + Uppercase(Paths) + ';'); + if P = 0 then + begin + { perhaps instlPath lives in Paths, but terminated by '\;' } + DelimLen := 2; { Length('\;') } + P := Pos(';' + Uppercase(instlPath) + '\;', ';' + Uppercase(Paths) + ';'); + if P = 0 then exit; + end; + + { Decide where to start string subset in Delete() operation. } + if P = 1 then + Offset := 0 + else + Offset := 1; + { Update path variable } + Delete(Paths, P - Offset, Length(instlPath) + DelimLen); + + { Overwrite path environment variable } + if RegWriteStringValue(HKEY_CURRENT_USER, EnvironmentKey, 'Path', Paths) + then Log(Format('The [%s] removed from PATH: [%s]', [instlPath, Paths])) + else Log(Format('Error while removing the [%s] from PATH: [%s]', [instlPath, Paths])); + end; +end; + +procedure CurStepChanged(CurStep: TSetupStep); +begin + if (CurStep = ssPostInstall) + then EnvAddPath(ExpandConstant('{app}') +'\cli'); +end; + +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +begin + if CurUninstallStep = usPostUninstall + then EnvRemovePath(ExpandConstant('{app}') +'\cli'); +end; diff --git a/win/psvince.dll b/win/psvince.dll deleted file mode 100644 index e910509d..00000000 Binary files a/win/psvince.dll and /dev/null differ