mirror of
https://github.com/netdata/netdata.git
synced 2025-04-27 22:26:21 +00:00
Improve windows installer (#18649)
This commit is contained in:
parent
54b7248f36
commit
ebb3e36431
5 changed files with 70 additions and 69 deletions
2
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
2
.github/ISSUE_TEMPLATE/BUG_REPORT.yml
vendored
|
@ -72,6 +72,8 @@ body:
|
||||||
uname -a; uname -K
|
uname -a; uname -K
|
||||||
# macOS
|
# macOS
|
||||||
uname -a; sw_vers
|
uname -a; sw_vers
|
||||||
|
# Windows (prompt)
|
||||||
|
ver
|
||||||
```
|
```
|
||||||
> NOTE: This will be automatically formatted into code, so no need for backticks.
|
> NOTE: This will be automatically formatted into code, so no need for backticks.
|
||||||
render: shell
|
render: shell
|
||||||
|
|
|
@ -2357,7 +2357,7 @@ add_executable(netdata
|
||||||
|
|
||||||
if(OS_WINDOWS)
|
if(OS_WINDOWS)
|
||||||
add_executable(NetdataClaim ${CLAIM_WINDOWS_FILES} ${NETDATA_CLAIM_RES_FILES})
|
add_executable(NetdataClaim ${CLAIM_WINDOWS_FILES} ${NETDATA_CLAIM_RES_FILES})
|
||||||
target_link_libraries(NetdataClaim shell32;gdi32;msftedit)
|
target_link_libraries(NetdataClaim shell32 gdi32 msftedit)
|
||||||
target_compile_options(NetdataClaim PUBLIC -mwindows)
|
target_compile_options(NetdataClaim PUBLIC -mwindows)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ RequestExecutionLevel admin
|
||||||
!insertmacro MUI_PAGE_LICENSE "C:\msys64\cloud.txt"
|
!insertmacro MUI_PAGE_LICENSE "C:\msys64\cloud.txt"
|
||||||
!insertmacro MUI_PAGE_LICENSE "C:\msys64\gpl-3.0.txt"
|
!insertmacro MUI_PAGE_LICENSE "C:\msys64\gpl-3.0.txt"
|
||||||
!insertmacro MUI_PAGE_DIRECTORY
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
!insertmacro MUI_PAGE_INSTFILES
|
|
||||||
Page Custom NetdataConfigPage NetdataConfigLeave
|
Page Custom NetdataConfigPage NetdataConfigLeave
|
||||||
|
!insertmacro MUI_PAGE_INSTFILES
|
||||||
!insertmacro MUI_PAGE_FINISH
|
!insertmacro MUI_PAGE_FINISH
|
||||||
|
|
||||||
!insertmacro MUI_UNPAGE_CONFIRM
|
!insertmacro MUI_UNPAGE_CONFIRM
|
||||||
|
@ -66,6 +66,8 @@ var hCtrlButton
|
||||||
var hStartMsys
|
var hStartMsys
|
||||||
var startMsys
|
var startMsys
|
||||||
|
|
||||||
|
var hCloudURL
|
||||||
|
var cloudURL
|
||||||
var hCloudToken
|
var hCloudToken
|
||||||
var cloudToken
|
var cloudToken
|
||||||
var hCloudRooms
|
var hCloudRooms
|
||||||
|
@ -148,7 +150,7 @@ FunctionEnd
|
||||||
|
|
||||||
Function ShowHelp
|
Function ShowHelp
|
||||||
Pop $0
|
Pop $0
|
||||||
MessageBox MB_ICONQUESTION|MB_OK "$\"Proxy URL$\" set the proxy server address to use if your network requires one.$\n$\n$\"Insecure connection$\" disable verification of the server's certificate chain and host name.$\n$\n$\"Open Terminal$\" open MSYS2 terminal to run additional commands after installation." IDOK endHelp
|
MessageBox MB_ICONQUESTION|MB_OK "$\"Cloud URL$\" The Netdata Cloud base URL.$\n$\n$\"Proxy URL$\" set the proxy server address to use if your network requires one.$\n$\n$\"Insecure connection$\" disable verification of the server's certificate chain and host name.$\n$\n$\"Open Terminal$\" open MSYS2 terminal to run additional commands after installation." IDOK endHelp
|
||||||
endHelp:
|
endHelp:
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
|
@ -181,13 +183,18 @@ Function NetdataConfigPage
|
||||||
${NSD_CreateText} 21% 60% 79% 10% ""
|
${NSD_CreateText} 21% 60% 79% 10% ""
|
||||||
Pop $hProxy
|
Pop $hProxy
|
||||||
|
|
||||||
${NSD_CreateCheckbox} 0 75% 50% 10u "Insecure connection"
|
${NSD_CreateLabel} 0 75% 20% 10% "Cloud URL"
|
||||||
|
Pop $0
|
||||||
|
${NSD_CreateText} 21% 75% 79% 10% "https://app.netdata.cloud"
|
||||||
|
Pop $hCloudURL
|
||||||
|
|
||||||
|
${NSD_CreateCheckbox} 0 92% 25% 10u "Insecure connection"
|
||||||
Pop $hInsecure
|
Pop $hInsecure
|
||||||
|
|
||||||
${NSD_CreateCheckbox} 0 90% 50% 10u "Open terminal"
|
${NSD_CreateCheckbox} 50% 92% 25% 10u "Open terminal"
|
||||||
Pop $hStartMsys
|
Pop $hStartMsys
|
||||||
|
|
||||||
${NSD_CreateButton} 80% 90% 30u 15u "&Help"
|
${NSD_CreateButton} 90% 90% 30u 15u "&Help"
|
||||||
Pop $hCtrlButton
|
Pop $hCtrlButton
|
||||||
${NSD_OnClick} $hCtrlButton ShowHelp
|
${NSD_OnClick} $hCtrlButton ShowHelp
|
||||||
|
|
||||||
|
@ -204,38 +211,11 @@ FunctionEnd
|
||||||
Function NetdataConfigLeave
|
Function NetdataConfigLeave
|
||||||
${If} $avoidClaim == ${BST_UNCHECKED}
|
${If} $avoidClaim == ${BST_UNCHECKED}
|
||||||
${NSD_GetText} $hCloudToken $cloudToken
|
${NSD_GetText} $hCloudToken $cloudToken
|
||||||
|
${NSD_GetText} $hCloudURL $cloudURL
|
||||||
${NSD_GetText} $hCloudRooms $cloudRooms
|
${NSD_GetText} $hCloudRooms $cloudRooms
|
||||||
${NSD_GetText} $hProxy $proxy
|
${NSD_GetText} $hProxy $proxy
|
||||||
${NSD_GetState} $hStartMsys $startMsys
|
${NSD_GetState} $hStartMsys $startMsys
|
||||||
${NSD_GetState} $hInsecure $insecure
|
${NSD_GetState} $hInsecure $insecure
|
||||||
|
|
||||||
StrLen $0 $cloudToken
|
|
||||||
StrLen $1 $cloudRooms
|
|
||||||
${If} $0 == 0
|
|
||||||
${OrIf} $1 == 0
|
|
||||||
Goto runMsys
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
${If} $0 == 135
|
|
||||||
${AndIf} $1 >= 36
|
|
||||||
nsExec::ExecToLog '$INSTDIR\usr\bin\NetdataClaim.exe /T $cloudToken /R $cloudRooms /P $proxy /I $insecure'
|
|
||||||
pop $0
|
|
||||||
${Else}
|
|
||||||
MessageBox MB_OK "The Cloud information does not have the expected length."
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
runMsys:
|
|
||||||
${If} $startMsys == ${BST_CHECKED}
|
|
||||||
nsExec::ExecToLog '$INSTDIR\msys2.exe'
|
|
||||||
pop $0
|
|
||||||
${EndIf}
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
ClearErrors
|
|
||||||
nsExec::ExecToLog '$SYSDIR\sc.exe start Netdata'
|
|
||||||
pop $0
|
|
||||||
${If} $0 != 0
|
|
||||||
MessageBox MB_OK "Warning: Failed to start Netdata service."
|
|
||||||
${EndIf}
|
${EndIf}
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
|
@ -297,44 +277,37 @@ Section "Install Netdata"
|
||||||
DetailPrint "Warning: Failed to add Netdata service description."
|
DetailPrint "Warning: Failed to add Netdata service description."
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
Call NetdataUninstallRegistry
|
Call NetdataUninstallRegistry
|
||||||
|
|
||||||
IfSilent runcmds goodbye
|
StrLen $0 $cloudToken
|
||||||
runcmds:
|
StrLen $1 $cloudRooms
|
||||||
nsExec::ExecToLog '$SYSDIR\sc.exe start Netdata'
|
${If} $0 == 0
|
||||||
pop $0
|
${OrIf} $1 == 0
|
||||||
|
Goto runCmds
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
System::Call 'kernel32::AttachConsole(i -1)i.r0'
|
${If} $0 == 135
|
||||||
${If} $0 != 0
|
${AndIf} $1 >= 36
|
||||||
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
|
nsExec::ExecToLog '$INSTDIR\usr\bin\NetdataClaim.exe /T $cloudToken /R $cloudRooms /P $proxy /I $insecure /U $cloudURL'
|
||||||
FileWrite $0 "Netdata installed with success.$\r$\n"
|
pop $0
|
||||||
${EndIf}
|
${Else}
|
||||||
${If} $startMsys == ${BST_CHECKED}
|
MessageBox MB_OK "The Cloud information does not have the expected length."
|
||||||
nsExec::ExecToLog '$INSTDIR\msys2.exe'
|
${EndIf}
|
||||||
pop $0
|
|
||||||
${EndIf}
|
|
||||||
|
|
||||||
StrLen $0 $cloudToken
|
runCmds:
|
||||||
StrLen $1 $cloudRooms
|
ClearErrors
|
||||||
${If} $0 == 0
|
nsExec::ExecToLog '$SYSDIR\sc.exe start Netdata'
|
||||||
${OrIf} $1 == 0
|
pop $0
|
||||||
Goto goodbye
|
${If} $0 != 0
|
||||||
${EndIf}
|
MessageBox MB_OK "Warning: Failed to start Netdata service."
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
${If} $0 == 135
|
${If} $startMsys == ${BST_CHECKED}
|
||||||
${AndIf} $1 >= 36
|
nsExec::ExecToLog '$INSTDIR\msys2.exe'
|
||||||
nsExec::ExecToLog '$INSTDIR\usr\bin\NetdataClaim.exe /T $cloudToken /R $cloudRooms /P $proxy /I $insecure'
|
pop $0
|
||||||
pop $0
|
${EndIf}
|
||||||
${Else}
|
|
||||||
System::Call 'kernel32::AttachConsole(i -1)i.r0'
|
|
||||||
${If} $0 != 0
|
|
||||||
System::Call 'kernel32::GetStdHandle(i -11)i.r0'
|
|
||||||
FileWrite $0 "Room(s) or Token invalid.$\r$\n"
|
|
||||||
${EndIf}
|
|
||||||
${EndIf}
|
|
||||||
goodbye:
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section "Uninstall"
|
Section "Uninstall"
|
||||||
|
@ -352,7 +325,8 @@ Section "Uninstall"
|
||||||
DetailPrint "Warning: Failed to delete Netdata service."
|
DetailPrint "Warning: Failed to delete Netdata service."
|
||||||
${EndIf}
|
${EndIf}
|
||||||
|
|
||||||
RMDir /r "$INSTDIR"
|
# https://nsis.sourceforge.io/Reference/RMDir
|
||||||
|
RMDir /r /REBOOTOK "$INSTDIR"
|
||||||
|
|
||||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata"
|
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata"
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
|
@ -14,11 +14,13 @@
|
||||||
LPWSTR token = NULL;
|
LPWSTR token = NULL;
|
||||||
LPWSTR room = NULL;
|
LPWSTR room = NULL;
|
||||||
LPWSTR proxy = NULL;
|
LPWSTR proxy = NULL;
|
||||||
|
LPWSTR url = NULL;
|
||||||
LPWSTR *argv = NULL;
|
LPWSTR *argv = NULL;
|
||||||
|
|
||||||
char *aToken = NULL;
|
char *aToken = NULL;
|
||||||
char *aRoom = NULL;
|
char *aRoom = NULL;
|
||||||
char *aProxy = NULL;
|
char *aProxy = NULL;
|
||||||
|
char *aURL = NULL;
|
||||||
int insecure = 0;
|
int insecure = 0;
|
||||||
|
|
||||||
LPWSTR netdata_claim_get_formatted_message(LPWSTR pMessage, ...)
|
LPWSTR netdata_claim_get_formatted_message(LPWSTR pMessage, ...)
|
||||||
|
@ -89,6 +91,13 @@ int nd_claim_parse_args(int argc, LPWSTR *argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(wcscasecmp(L"/U", argv[i]) == 0) {
|
||||||
|
if (argc <= i + 1)
|
||||||
|
continue;
|
||||||
|
i++;
|
||||||
|
url = argv[i];
|
||||||
|
}
|
||||||
|
|
||||||
if(wcscasecmp(L"/I", argv[i]) == 0) {
|
if(wcscasecmp(L"/I", argv[i]) == 0) {
|
||||||
if (argc <= i + 1)
|
if (argc <= i + 1)
|
||||||
continue;
|
continue;
|
||||||
|
@ -142,6 +151,15 @@ static int netdata_claim_prepare_strings()
|
||||||
|
|
||||||
netdata_claim_convert_str(aProxy, proxy, length - 1);
|
netdata_claim_convert_str(aProxy, proxy, length - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (url) {
|
||||||
|
length = wcslen(url) + 1;
|
||||||
|
aURL = calloc(sizeof(char), length - 1);
|
||||||
|
if (!aURL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
netdata_claim_convert_str(aURL, url, length - 1);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +175,9 @@ static void netdata_claim_exit_callback(int signal)
|
||||||
if (aProxy)
|
if (aProxy)
|
||||||
free(aProxy);
|
free(aProxy);
|
||||||
|
|
||||||
|
if (aURL)
|
||||||
|
free(aURL);
|
||||||
|
|
||||||
if (argv)
|
if (argv)
|
||||||
LocalFree(argv);
|
LocalFree(argv);
|
||||||
}
|
}
|
||||||
|
@ -165,9 +186,12 @@ static inline int netdata_claim_prepare_data(char *out, size_t length)
|
||||||
{
|
{
|
||||||
char *proxyLabel = (aProxy) ? "proxy = " : "# proxy = ";
|
char *proxyLabel = (aProxy) ? "proxy = " : "# proxy = ";
|
||||||
char *proxyValue = (aProxy) ? aProxy : "";
|
char *proxyValue = (aProxy) ? aProxy : "";
|
||||||
|
|
||||||
|
char *urlValue = (aURL) ? aURL : "https://app.netdata.cloud";
|
||||||
return snprintf(out,
|
return snprintf(out,
|
||||||
length,
|
length,
|
||||||
"[global]\n url = https://app.netdata.cloud\n token = %s\n rooms = %s\n %s%s\n insecure = %s",
|
"[global]\n url = %s\n token = %s\n rooms = %s\n %s%s\n insecure = %s",
|
||||||
|
urlValue,
|
||||||
aToken,
|
aToken,
|
||||||
aRoom,
|
aRoom,
|
||||||
proxyLabel,
|
proxyLabel,
|
||||||
|
|
|
@ -25,6 +25,7 @@ LRESULT CALLBACK WndProc(HWND hNetdatawnd, UINT message, WPARAM wParam, LPARAM l
|
||||||
L"/T TOKEN: The cloud token;",
|
L"/T TOKEN: The cloud token;",
|
||||||
L"/R ROOMS: A list of rooms to claim;",
|
L"/R ROOMS: A list of rooms to claim;",
|
||||||
L"/P PROXY: The proxy information;",
|
L"/P PROXY: The proxy information;",
|
||||||
|
L"/U URL : The cloud URL;",
|
||||||
L"/I : Use insecure connection;"
|
L"/I : Use insecure connection;"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ int netdata_claim_window_loop(HINSTANCE hInstance, int nCmdShow)
|
||||||
L"Netdata Claim",
|
L"Netdata Claim",
|
||||||
WS_OVERLAPPEDWINDOW,
|
WS_OVERLAPPEDWINDOW,
|
||||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||||
460, 220,
|
460, 240,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
hInstance,
|
hInstance,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue