Fixed some minor updater bugs on linux

This commit is contained in:
WolverinDEV 2021-05-02 11:52:51 +02:00
parent 177d6582ea
commit a57246bb8b
3 changed files with 23 additions and 9 deletions

View File

@ -713,10 +713,17 @@ export async function prepareUpdateExecute(targetVersion: UpdateVersion, callbac
console.log("Will prompt the user to execute a command");
}
try {
fs.chmodSync(updateInstallerExecutable, 0o755);
} catch (error) {
console.error("Failed to make update executable executable: %o", error);
throw "failed to make update executable executable";
}
//We have to unpack it later
executeCallback = () => {
if(inaccessiblePaths.length > 0) {
const updateCommand = `sudo "${updateInstallerExecutable}" "${installLogFile}" "${installConfigFile}"`;
const updateCommand = `sudo "${updateInstallerExecutable}" "${installLogFile}" "${installConfigFile}" no-daemon`;
try {
electron.clipboard.writeText(updateCommand);
} catch (error) {
@ -728,7 +735,7 @@ export async function prepareUpdateExecute(targetVersion: UpdateVersion, callbac
"Please do the following steps:\n" +
"1. Close this client\n" +
"2. Execute this command:\n" +
` sudo "${updateInstallerExecutable}" "${installLogFile}" "${installConfigFile}"` + "\n" +
" " + updateCommand + "\n" +
"3. Start the client again\n\n" +
"Note:\n" +
"We've already copied that command to your clipboard."

View File

@ -115,14 +115,16 @@ int main(int argc, char** argv) {
}
if(argc >= 4 && std::string_view{argv[3]} != "no-daemon") {
#ifndef WIN32
logger::info("Deamonize process");
if(!daemonize()) {
logger::fatal("Failed to demonize process", argc);
return 4;
}
logger::info("Deamonized process");
logger::info("Deamonize process");
if(!daemonize()) {
logger::fatal("Failed to demonize process", argc);
return 4;
}
logger::info("Deamonized process");
#endif
}
#ifdef WIN32
if(requires_permission_elevation()) {

View File

@ -46,7 +46,11 @@ using namespace std;
}
#else
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
bool is_executable(const std::string& file) {
chmod(file.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
return access(file.c_str(), F_OK | X_OK) == 0;
}
@ -84,7 +88,8 @@ inline std::string build_callback_info(const std::string& error_id, const std::s
void execute_callback_fail_exit(const std::string& error, const std::string& error_message) {
file::rollback();
//int chmod(const char *path, mode_t mode);
if(!is_executable(config::callback_file)) {
logger::fatal("callback file (%s) is not executable! Ignoring fail callback", config::callback_file.c_str());
logger::flush();