Skip to content

Commit

Permalink
fix(index installer serviceinstall and uninstall): error on installer…
Browse files Browse the repository at this point in the history
… and on first start rendering
  • Loading branch information
stefano-cla committed Jan 13, 2022
1 parent 8a97368 commit 19e6c88
Show file tree
Hide file tree
Showing 9 changed files with 633 additions and 3,115 deletions.
2 changes: 1 addition & 1 deletion components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function Footer() {
>
<div className="container text-center">
<small>
LAC - actual version: 1.1.3 - source code on{' '}
LAC source code on{' '}
<Link href="https://github.com/steledama/lac" passHref>
Github
</Link>
Expand Down
4 changes: 2 additions & 2 deletions lib/zabbix.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ async function zabbixApiRequest(server, token, method, params, id) {
// console.log(response);
return response.data;
} catch (error) {
// console.log(error);
return new Error(error);
console.log(error);
return error;
}
}

Expand Down
3,629 changes: 572 additions & 3,057 deletions package-lock.json

Large diffs are not rendered by default.

103 changes: 53 additions & 50 deletions pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,67 +31,69 @@ async function checkZabbixConnection(confToCheck) {
confToCheck.token,
confToCheck.group
);
if (zabbixRes.isAxiosError) throw zabbixRes;
// Declaration of the return variable
let checkedResult;
// console.log(zabbixRes);
switch (zabbixRes.code) {
case 'Network Error':
// switch (zabbixRes.code) {
// case 'Network Error':
// checkedResult = {
// variant: 'danger',
// text: `ERROR: incorrect zabbix hostname ${confToCheck.server} or server in not responding. Check if the server is up and running or behind a firewall`,
// };
// break;
// case 'ENOTFOUND':
// checkedResult = {
// variant: 'danger',
// text: `ERROR: incorrect zabbix hostname ${confToCheck.server}`,
// };
// break;
// case 'ETIMEDOUT':
// case 'ECONNREFUSED':
// checkedResult = {
// variant: 'danger',
// text: `ERROR: Zabbix server ${confToCheck.server} is not responding. Check if the server is up and running`,
// };
// break;
// case 'EHOSTUNREACH':
// checkedResult = {
// variant: 'danger',
// text: `ERROR: Zabbix server ${confToCheck.server} is not reachable. Check if it is behind a firewall or if there is a port forward rule`,
// };
// break;
// default:
// if (zabbixRes.errors) {
// checkedResult = {
// variant: 'danger',
// text: `ERROR: Incorrect zabbix ip or hostname please check if ${confToCheck.server} is correct`,
// };
// }
// if (zabbixRes.error) {
// checkedResult = {
// variant: 'danger',
// text: `ERROR: Incorrect token please check if ${confToCheck.token} is correct and if is configured in zabbix server`,
// };
// }
if (zabbixRes.result) {
if (zabbixRes.result.length === 0) {
checkedResult = {
variant: 'danger',
text: `ERROR: incorrect zabbix hostname ${confToCheck.server} or server in not responding. Check if the server is up and running or behind a firewall`,
text: `ERROR: Group ${confToCheck.group} not found`,
};
break;
case 'ENOTFOUND':
checkedResult = {
variant: 'danger',
text: `ERROR: incorrect zabbix hostname ${confToCheck.server}`,
};
break;
case 'ETIMEDOUT':
case 'ECONNREFUSED':
checkedResult = {
variant: 'danger',
text: `ERROR: Zabbix server ${confToCheck.server} is not responding. Check if the server is up and running`,
};
break;
case 'EHOSTUNREACH':
checkedResult = {
variant: 'danger',
text: `ERROR: Zabbix server ${confToCheck.server} is not reachable. Check if it is behind a firewall or if there is a port forward rule`,
};
break;
default:
if (zabbixRes.errors) {
checkedResult = {
variant: 'danger',
text: `ERROR: Incorrect zabbix ip or hostname please check if ${confToCheck.server} is correct`,
};
}
if (zabbixRes.error) {
checkedResult = {
variant: 'danger',
text: `ERROR: Incorrect token please check if ${confToCheck.token} is correct and if is configured in zabbix server`,
};
}
if (zabbixRes.result) {
if (zabbixRes.result.length === 0) {
checkedResult = {
variant: 'danger',
text: `ERROR: Group ${confToCheck.group} not found`,
};
}
if (zabbixRes.result[0]) {
const confChecked = confToCheck;
confChecked.groupId = zabbixRes.result[0].groupid;
return confChecked;
}
}
}
if (zabbixRes.result[0]) {
const confChecked = confToCheck;
confChecked.groupId = zabbixRes.result[0].groupid;
return confChecked;
}
}
// console.log(checkedResult);
return checkedResult;
} catch (error) {
// console.log(error);
return {
variant: 'danger',
text: `ERROR: ${error}`,
text: `${error}`,
};
}
}
Expand Down Expand Up @@ -119,6 +121,7 @@ export const getServerSideProps = async () => {
// check zabbix connection and get groupId
const response = await checkZabbixConnection(confFromFile);
// if response is an error
// console.log(response);
if (response.variant) {
// pass the error message
confMessageProp = response;
Expand Down
Binary file modified win/LAC_upgrade.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion win/lacInstall.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "LAC"
#define MyAppVersion "1.1.3"
#define MyAppVersion "1.1.4"
#define MyAppPublisher "steledama"
#define MyAppURL "https://github.com/steledama/lac"
#define user "C:\Users\stefano"
Expand Down
4 changes: 2 additions & 2 deletions win/lacUpgrade.iss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define MyAppVersion "1.1.4"
#define MyAppPublisher "steledama"
#define MyAppURL "https://github.com/steledama/lac"
#define user "C:\Users\stefa"
#define user "C:\Users\stefano"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
Expand All @@ -24,7 +24,7 @@ DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only.)
;PrivilegesRequired=lowest
OutputDir={#user}\Documents\GitHub\lac
OutputDir={#user}\Documents\GitHub\lac\win
OutputBaseFilename=LAC_upgrade
Compression=lzma
SolidCompression=yes
Expand Down
2 changes: 1 addition & 1 deletion win/serviceInstall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Service } from 'node-windows';
const { Service } = require('node-windows');

// const Service = require('node-windows').Service;

Expand Down
2 changes: 1 addition & 1 deletion win/serviceUninstall.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Service } from 'node-windows';
const { Service } = require('node-windows');

// Create a new service object
const svc = new Service({
Expand Down

0 comments on commit 19e6c88

Please sign in to comment.