diff --git a/packaging/installer/installer.nsi b/packaging/installer/installer.nsi deleted file mode 100644 index c14ccb5993..0000000000 --- a/packaging/installer/installer.nsi +++ /dev/null @@ -1,128 +0,0 @@ -!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\gpl-3.0.txt" -!insertmacro MUI_PAGE_DIRECTORY -!insertmacro MUI_PAGE_INSTFILES -!insertmacro MUI_PAGE_FINISH - -!insertmacro MUI_UNPAGE_CONFIRM -!insertmacro MUI_UNPAGE_INSTFILES -!insertmacro MUI_UNPAGE_FINISH - -!insertmacro MUI_LANGUAGE "English" - -Function .onInit - nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata' - pop $0 - ${If} $0 == 0 - nsExec::ExecToLog '$SYSDIR\sc.exe delete Netdata' - 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 - diff --git a/packaging/windows/WINDOWS_INSTALLER.md b/packaging/windows/WINDOWS_INSTALLER.md new file mode 100644 index 0000000000..1b8c6f6be2 --- /dev/null +++ b/packaging/windows/WINDOWS_INSTALLER.md @@ -0,0 +1,50 @@ +# Netdata Windows Installer + +Netdata offers a convenient Windows installer for easy setup. This executable provides two distinct installation modes, outlined below. + +## Graphical User Interface (GUI) + +Double-clicking the installer initiates the setup process. Since Netdata adds a service to your system, you'll need to provide administrator privileges. +The installer will then guide you through these steps: + +1. **Welcome**: This screen provides a summary of the actions the installer will perform. +2. **License Agreements**: + - [Netdata Cloud UI License](/src/web/gui/v2/LICENSE.md): Review and accept the license terms to proceed. + - [GPLv3 License](/LICENSE): Read the GNU General Public License v3, which governs the Netdata software. +3. **Destination**: Choose the installation directory. By default, Netdata installs in `C:\Program Files\Netdata`. +4. **Installation**: The installer will copy the necessary files to the chosen directory. +5. **Claiming**: [Connecting](/src/claim/README.md) your Netdata Agent to your Netdata Cloud Space. Here's what you can configure: + - **Token**: The claiming token for your Netdata Cloud Space. + - **Rooms**: Specify the Room IDs where you want your node to appear (comma-separated list). + - **Proxy**: Enter the address of a proxy server if required for communication with Netdata Cloud. + - **Insecure connection**: By default, Netdata verifies the server's certificate. Enabling this option bypasses verification (use only if necessary). + - **Open Terminal**: Select this option to launch the `MSYS2` terminal after installation completes. +6. **Finish**: The installation process is complete! + +## Silent Mode + +This section provides instructions for installing Netdata in silent mode, which is ideal for automated deployments. +Silent mode skips displaying license agreements, but requires explicitly accepting them using the `/A` option. + +**Available Options**: + +| Option | Description | +|-----------|--------------------------------------------------------------------------------------------------| +| `/S` | Enables silent mode installation. | +| `/A` | Accepts all Netdata licenses. This option is mandatory for silent installations. | +| `/D` | Specifies the desired installation directory (defaults to `C:\Program Files\Netdata`). | +| `/T` | Opens the `MSYS2` terminal after installation. | +| `/I` | Forces insecure connections, bypassing hostname verification (use only if absolutely necessary). | +| `/TOKEN=` | Sets the claiming token for your Netdata Cloud Space. | +| `/ROOMS=` | Comma-separated list of Room IDs where you want your node to appear. | +| `/PROXY=` | Sets the proxy server address if your network requires one. | + +**Example Usage** + +Connect your Agent to your Netdata Cloud Space with token `<YOUR_TOKEN>` and room `<YOUR_ROOM>`: + +```bash +netdata-installer.exe /S /A /TOKEN=<YOUR_TOKEN> /ROOMS=<YOUR_ROOM> +``` + +Replace `<YOUR_TOKEN>` and `<YOUR_ROOM>` with your actual Netdata Cloud Space claim token and room ID, respectively. diff --git a/packaging/windows/installer.nsi b/packaging/windows/installer.nsi index 93a0444bdf..3c070ebec8 100644 --- a/packaging/windows/installer.nsi +++ b/packaging/windows/installer.nsi @@ -29,6 +29,39 @@ Page Custom NetdataConfigPage NetdataConfigLeave !insertmacro MUI_LANGUAGE "English" +!define INSTALLERLOCKFILEGUID "f787d5ef-5c41-4dc0-a115-a1fb654fad1c" + +# https://nsis.sourceforge.io/Allow_only_one_installer_instance +!macro SingleInstanceFile + !if "${NSIS_PTR_SIZE}" > 4 + !include "Util.nsh" + !else ifndef IntPtrCmp + !define IntPtrCmp IntCmp + !endif + + !ifndef NSIS_PTR_SIZE & SYSTYPE_PTR + !define SYSTYPE_PTR i ; NSIS v2.x + !else + !define /ifndef SYSTYPE_PTR p ; NSIS v3.0+ + !endif + + !if "${NSIS_CHAR_SIZE}" < 2 + Push "$TEMP\${INSTALLERLOCKFILEGUID}.lock" + !else + Push "$APPDATA\${INSTALLERLOCKFILEGUID}.lock" + !endif + + System::Call 'KERNEL32::CreateFile(ts,i0x40000000,i0,${SYSTYPE_PTR}0,i4,i0x04000000,${SYSTYPE_PTR}0)${SYSTYPE_PTR}.r0' + ${IntPtrCmp} $0 -1 "" launch launch + System::Call 'kernel32::AttachConsole(i -1)i.r0' + ${If} $0 != 0 + System::Call 'kernel32::GetStdHandle(i -11)i.r0' + FileWrite $0 "The installer is already running.$\r$\n" + ${EndIf} + Quit + launch: +!macroend + var hStartMsys var startMsys @@ -40,10 +73,13 @@ var hProxy var proxy var hInsecure var insecure +var accepted var avoidClaim Function .onInit + !insertmacro SingleInstanceFile + nsExec::ExecToLog '$SYSDIR\sc.exe stop Netdata' pop $0 ${If} $0 == 0 @@ -54,6 +90,59 @@ Function .onInit StrCpy $startMsys ${BST_UNCHECKED} StrCpy $insecure ${BST_UNCHECKED} StrCpy $avoidClaim ${BST_UNCHECKED} + StrCpy $accepted ${BST_UNCHECKED} + + ${GetParameters} $R0 + ${GetOptions} $R0 "/s" $0 + IfErrors +2 0 + SetSilent silent + ClearErrors + + ${GetOptions} $R0 "/t" $0 + IfErrors +2 0 + StrCpy $startMsys ${BST_CHECKED} + ClearErrors + + ${GetOptions} $R0 "/i" $0 + IfErrors +2 0 + StrCpy $insecure ${BST_CHECKED} + ClearErrors + + ${GetOptions} $R0 "/a" $0 + IfErrors +2 0 + StrCpy $accepted ${BST_CHECKED} + ClearErrors + + ${GetOptions} $R0 "/token=" $0 + IfErrors +2 0 + StrCpy $cloudToken $0 + ClearErrors + + ${GetOptions} $R0 "/rooms=" $0 + IfErrors +2 0 + StrCpy $cloudRooms $0 + ClearErrors + + ${GetOptions} $R0 "/proxy=" $0 + IfErrors +2 0 + StrCpy $proxy $0 + ClearErrors + + IfSilent checklicense goahead + checklicense: + ${If} $accepted == ${BST_UNCHECKED} + System::Call 'kernel32::AttachConsole(i -1)i.r0' + ${If} $0 != 0 + System::Call 'kernel32::GetStdHandle(i -11)i.r0' + FileWrite $0 "You must accept the licenses (/A) to continue.$\r$\n" + ${EndIf} + Quit + ${EndIf} + goahead: +FunctionEnd + +Function un.onInit +!insertmacro SingleInstanceFile FunctionEnd Function NetdataConfigPage @@ -199,6 +288,41 @@ Section "Install Netdata" WriteUninstaller "$INSTDIR\Uninstall.exe" Call NetdataUninstallRegistry + + IfSilent runcmds goodbye + runcmds: + nsExec::ExecToLog '$SYSDIR\sc.exe start Netdata' + pop $0 + + System::Call 'kernel32::AttachConsole(i -1)i.r0' + ${If} $0 != 0 + System::Call 'kernel32::GetStdHandle(i -11)i.r0' + FileWrite $0 "Netdata installed with success.$\r$\n" + ${EndIf} + ${If} $startMsys == ${BST_CHECKED} + nsExec::ExecToLog '$INSTDIR\msys2.exe' + pop $0 + ${EndIf} + + StrLen $0 $cloudToken + StrLen $1 $cloudRooms + ${If} $0 == 0 + ${OrIf} $1 == 0 + Goto goodbye + ${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} + 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 Section "Uninstall"