blob: 88d160a1d37192f11da3e5c5638997586fee2870 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
!include "MUI2.nsh"
!include "nsDialogs.nsh"
!include "FileFunc.nsh"
Name "Netdata"
Outfile "netdata-installer.exe"
InstallDir "$PROGRAMFILES\Netdata"
RequestExecutionLevel admin
!define MUI_ICON "NetdataWhite.ico"
!define MUI_UNICON "NetdataWhite.ico"
!define ND_UININSTALL_REG "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata"
!define MUI_ABORTWARNING
!define MUI_UNABORTWARNING
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "C:\msys64\cloud.txt"
!insertmacro MUI_PAGE_LICENSE "C:\msys64\gpl-3.0.txt"
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
Page Custom NetdataConfigPage NetdataConfigLeave
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
var hStartMsys
var startMsys
var hCloudToken
var cloudToken
var hCloudRoom
var cloudRoom
Function .onInit
nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata'
pop $0
${If} $0 == 0
nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata'
pop $0
${EndIf}
StrCpy $startMsys ${BST_UNCHECKED}
FunctionEnd
Function NetdataConfigPage
!insertmacro MUI_HEADER_TEXT "Netdata configuration" "Claim your agent on Netdata Cloud"
nsDialogs::Create 1018
Pop $0
${If} $0 == error
Abort
${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Enter your Token and Cloud Room."
${NSD_CreateLabel} 0 15% 100% 12u "Optionally, you can open a terminal to execute additional commands."
${NSD_CreateLabel} 0 35% 20% 10% "Token"
Pop $0
${NSD_CreateText} 21% 35% 79% 10% ""
Pop $hCloudToken
${NSD_CreateLabel} 0 55% 20% 10% "Room"
Pop $0
${NSD_CreateText} 21% 55% 79% 10% ""
Pop $hCloudRoom
${NSD_CreateCheckbox} 0 70% 100% 10u "Open terminal"
Pop $hStartMsys
nsDialogs::Show
FunctionEnd
Function NetdataConfigLeave
${NSD_GetText} $hCloudToken $cloudToken
${NSD_GetText} $hCloudRoom $cloudRoom
${NSD_GetState} $hStartMsys $startMsys
StrLen $0 $cloudToken
StrLen $1 $cloudRoom
${If} $0 == 125
${AndIf} $0 == 36
# We should start our new claiming software here
MessageBox MB_OK "$cloudToken | $cloudRoom | $startMsys"
${EndIf}
${If} $startMsys == 1
nsExec::ExecToLog '$INSTDIR\msys2.exe'
pop $0
${EndIf}
FunctionEnd
Function NetdataUninstallRegistry
ClearErrors
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"DisplayName" "Netdata - Real-time system monitoring."
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"DisplayIcon" "$INSTDIR\Uninstall.exe,0"
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"UninstallString" "$INSTDIR\Uninstall.exe"
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"RegOwner" "Netdata Inc."
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"RegCompany" "Netdata Inc."
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"Publisher" "Netdata Inc."
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"HelpLink" "https://learn.netdata.cloud/"
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"URLInfoAbout" "https://www.netdata.cloud/"
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"DisplayVersion" "${CURRVERSION}"
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"VersionMajor" "${MAJORVERSION}"
WriteRegStr HKLM "${ND_UININSTALL_REG}" \
"VersionMinor" "${MINORVERSION}"
IfErrors 0 +2
MessageBox MB_ICONEXCLAMATION|MB_OK "Unable to create an entry in the Control Panel!" IDOK end
ClearErrors
${GetSize} "$INSTDIR" "/S=0K" $0 $1 $2
IntFmt $0 "0x%08X" $0
WriteRegDWORD HKLM "${ND_UININSTALL_REG}" "EstimatedSize" "$0"
IfErrors 0 +2
MessageBox MB_ICONEXCLAMATION|MB_OK "Cannot estimate the installation size." IDOK end
end:
FunctionEnd
Section "Install Netdata"
SetOutPath $INSTDIR
SetCompress off
File /r "C:\msys64\opt\netdata\*.*"
ClearErrors
nsExec::ExecToLog '$SYSDIR\sc.exe create Netdata binPath= "$INSTDIR\usr\bin\netdata.exe" start= delayed-auto'
pop $0
${If} $0 != 0
DetailPrint "Warning: Failed to create Netdata service."
${EndIf}
ClearErrors
nsExec::ExecToLog '$SYSDIR\sc.exe description Netdata "Real-time system monitoring service"'
pop $0
${If} $0 != 0
DetailPrint "Warning: Failed to add Netdata service description."
${EndIf}
ClearErrors
nsExec::ExecToLog '$SYSDIR\sc.exe start Netdata'
pop $0
${If} $0 != 0
DetailPrint "Warning: Failed to start Netdata service."
${EndIf}
WriteUninstaller "$INSTDIR\Uninstall.exe"
Call NetdataUninstallRegistry
SectionEnd
Section "Uninstall"
ClearErrors
nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata'
pop $0
${If} $0 != 0
DetailPrint "Warning: Failed to stop Netdata service."
${EndIf}
ClearErrors
nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata'
pop $0
${If} $0 != 0
DetailPrint "Warning: Failed to delete Netdata service."
${EndIf}
RMDir /r "$INSTDIR"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Netdata"
SectionEnd
|