[Antergos and Manjaro support] [Download latest detect_linux.sh if bundled script returns unknown] [Display error message if OS is detected as unknown]

This commit is contained in:
2019-07-28 21:12:40 -05:00
parent ba14f36d32
commit f996bb4a74
7 changed files with 67 additions and 21 deletions

View File

@@ -67,6 +67,9 @@ elif [ -f /etc/os-release ]; then
. /etc/os-release
if [ "$ID" == "arch" ]; then
DISTNAME=arch
elif [ "$ID" == "antergos" ] || [ "$ID" == "manjaro" ]; then
DISTNAME=ubuntu
DISTVER=18.10
elif [ "$ID" == "opensuse-leap" ]; then
if [ "$VERSION_ID" == "15.0" ]; then
DISTNAME=opensuse

View File

@@ -650,29 +650,48 @@ ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
});
ipcMain.on(Constants.IPC_Get_Platform, (event) => {
const sendResponse = (appPlatform, platform) => {
event.sender.send(Constants.IPC_Get_Platform_Reply, {
AppPlatform: appPlatform,
Platform: platform,
});
};
const platform = os.platform();
if (platform === 'linux') {
const scriptFile = path.join(os.tmpdir(), 'repertory_detect_linux.sh');
fs.writeFileSync(scriptFile, detectScript);
helpers
.executeScript(scriptFile)
.then(data => {
event.sender.send(Constants.IPC_Get_Platform_Reply, {
AppPlatform: data.replace(/(\r\n|\n|\r)/gm,""),
Platform: platform,
});
let appPlatform = data.replace(/(\r\n|\n|\r)/gm,"");
if (appPlatform === 'unknown') {
helpers
.downloadFile(Constants.LINUX_DETECT_SCRIPT_URL, scriptFile, null, err => {
if (err) {
sendResponse(appPlatform, platform);
} else {
helpers
.executeScript(scriptFile)
.then(data => {
appPlatform = data.replace(/(\r\n|\n|\r)/gm, "");
sendResponse(appPlatform, platform);
})
.catch(() => {
sendResponse(appPlatform, platform);
});
}
});
} else {
sendResponse(appPlatform, platform);
}
})
.catch(() => {
event.sender.send(Constants.IPC_Get_Platform_Reply, {
AppPlatform: platform,
Platform: platform,
});
sendResponse(platform, platform);
});
} else {
event.sender.send(Constants.IPC_Get_Platform_Reply, {
AppPlatform: platform,
Platform: platform,
});
sendResponse(platform, platform);
}
});