2022-05-21 18:42:56 +02:00
|
|
|
!define APP_NAME "Netbird"
|
|
|
|
!define COMP_NAME "Netbird"
|
|
|
|
!define WEB_SITE "Netbird.io"
|
2021-09-06 10:20:26 +02:00
|
|
|
!define VERSION $%APPVER%
|
2022-05-25 19:41:03 +02:00
|
|
|
!define COPYRIGHT "Netbird Authors, 2022"
|
2021-09-06 10:20:26 +02:00
|
|
|
!define DESCRIPTION "A WireGuard®-based mesh network that connects your devices into a single private network"
|
2022-05-21 18:42:56 +02:00
|
|
|
!define INSTALLER_NAME "netbird-installer.exe"
|
|
|
|
!define MAIN_APP_EXE "Netbird"
|
|
|
|
!define ICON "ui\\netbird.ico"
|
2021-09-06 10:20:26 +02:00
|
|
|
!define BANNER "ui\\banner.bmp"
|
|
|
|
!define LICENSE_DATA "..\\LICENSE"
|
|
|
|
|
|
|
|
!define INSTALL_DIR "$PROGRAMFILES64\${APP_NAME}"
|
|
|
|
!define INSTALL_TYPE "SetShellVarContext all"
|
|
|
|
!define REG_ROOT "HKLM"
|
|
|
|
!define REG_APP_PATH "Software\Microsoft\Windows\CurrentVersion\App Paths\${MAIN_APP_EXE}"
|
|
|
|
!define UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP_NAME}"
|
2022-03-23 18:24:25 +01:00
|
|
|
|
2022-05-21 18:42:56 +02:00
|
|
|
!define UI_APP_NAME "Netbird UI"
|
|
|
|
!define UI_APP_EXE "Netbird-ui"
|
2022-03-23 18:24:25 +01:00
|
|
|
|
|
|
|
!define UI_REG_APP_PATH "Software\Microsoft\Windows\CurrentVersion\App Paths\${UI_APP_EXE}"
|
|
|
|
!define UI_UNINSTALL_PATH "Software\Microsoft\Windows\CurrentVersion\Uninstall\${UI_APP_NAME}"
|
|
|
|
|
2021-09-06 10:20:26 +02:00
|
|
|
Unicode True
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
VIProductVersion "${VERSION}"
|
|
|
|
VIAddVersionKey "ProductName" "${APP_NAME}"
|
|
|
|
VIAddVersionKey "CompanyName" "${COMP_NAME}"
|
|
|
|
VIAddVersionKey "LegalCopyright" "${COPYRIGHT}"
|
|
|
|
VIAddVersionKey "FileDescription" "${DESCRIPTION}"
|
|
|
|
VIAddVersionKey "FileVersion" "${VERSION}"
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
SetCompressor /SOLID Lzma
|
|
|
|
Name "${APP_NAME}"
|
|
|
|
Caption "${APP_NAME}"
|
|
|
|
OutFile "..\\${INSTALLER_NAME}"
|
|
|
|
BrandingText "${APP_NAME}"
|
|
|
|
InstallDirRegKey "${REG_ROOT}" "${REG_APP_PATH}" ""
|
|
|
|
InstallDir "${INSTALL_DIR}"
|
|
|
|
LicenseData "${LICENSE_DATA}"
|
|
|
|
ShowInstDetails Show
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
!define MUI_ICON "${ICON}"
|
|
|
|
!define MUI_UNICON "${ICON}"
|
|
|
|
!define MUI_WELCOMEFINISHPAGE_BITMAP "${BANNER}"
|
|
|
|
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "${BANNER}"
|
2022-05-25 19:41:03 +02:00
|
|
|
!define MUI_FINISHPAGE_RUN
|
|
|
|
!define MUI_FINISHPAGE_RUN_TEXT "Start ${UI_APP_NAME}"
|
|
|
|
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
|
2021-09-06 10:20:26 +02:00
|
|
|
######################################################################
|
|
|
|
|
|
|
|
!include "MUI2.nsh"
|
2022-05-25 19:41:03 +02:00
|
|
|
!include LogicLib.nsh
|
2021-09-06 10:20:26 +02:00
|
|
|
|
|
|
|
!define MUI_ABORTWARNING
|
|
|
|
!define MUI_UNABORTWARNING
|
|
|
|
|
|
|
|
!insertmacro MUI_PAGE_WELCOME
|
|
|
|
|
|
|
|
!insertmacro MUI_PAGE_LICENSE "${LICENSE_DATA}"
|
|
|
|
|
|
|
|
!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"
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
|
2022-05-25 19:41:03 +02:00
|
|
|
Function GetAppFromCommand
|
|
|
|
Exch $1
|
|
|
|
Push $2
|
|
|
|
StrCpy $2 $1 1 0
|
|
|
|
StrCmp $2 '"' 0 done
|
|
|
|
Push $3
|
|
|
|
StrCpy $3 ""
|
|
|
|
loop:
|
|
|
|
IntOp $3 $3 + 1
|
|
|
|
StrCpy $2 $1 1 $3
|
|
|
|
StrCmp $2 '' +2
|
|
|
|
StrCmp $2 '"' 0 loop
|
|
|
|
StrCpy $1 $1 $3
|
|
|
|
StrCpy $1 $1 "" 1 ; Remove starting quote
|
|
|
|
Pop $3
|
|
|
|
done:
|
|
|
|
Pop $2
|
|
|
|
Exch $1
|
|
|
|
FunctionEnd
|
|
|
|
!macro GetAppFromCommand in out
|
|
|
|
Push "${in}"
|
|
|
|
Call GetAppFromCommand
|
|
|
|
Pop ${out}
|
|
|
|
!macroend
|
|
|
|
|
|
|
|
!macro UninstallPreviousNSIS UninstCommand CustomParameters
|
|
|
|
Push $0
|
|
|
|
Push $1
|
|
|
|
Push $2
|
|
|
|
Push '${CustomParameters}'
|
|
|
|
Push '${UninstCommand}'
|
|
|
|
Call GetAppFromCommand ; Remove quotes and parameters from UninstCommand
|
|
|
|
Pop $0
|
|
|
|
Pop $1
|
|
|
|
GetFullPathName $2 "$0\.."
|
|
|
|
ExecWait '"$0" $1 _?=$2'
|
|
|
|
Delete "$0" ; Extra cleanup because we used _?=
|
|
|
|
RMDir "$2"
|
|
|
|
Pop $2
|
|
|
|
Pop $1
|
|
|
|
Pop $0
|
|
|
|
!macroend
|
|
|
|
|
|
|
|
Function .onInit
|
|
|
|
|
|
|
|
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Wiretrustee" "UninstallString"
|
|
|
|
${If} $R0 != ""
|
|
|
|
MessageBox MB_YESNO|MB_ICONQUESTION "Wiretrustee is installed. We must remove it before installing Netbird. Procced?" IDNO noWTUninstOld
|
|
|
|
!insertmacro UninstallPreviousNSIS $R0 "/NoMsgBox"
|
|
|
|
noWTUninstOld:
|
|
|
|
${EndIf}
|
|
|
|
|
|
|
|
ReadRegStr $R0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^NAME)" "UninstallString"
|
|
|
|
${If} $R0 != ""
|
|
|
|
MessageBox MB_YESNO|MB_ICONQUESTION "$(^NAME) is already installed. Do you want to remove the previous version?" IDNO noUninstOld
|
|
|
|
!insertmacro UninstallPreviousNSIS $R0 "/NoMsgBox"
|
|
|
|
noUninstOld:
|
|
|
|
${EndIf}
|
|
|
|
FunctionEnd
|
|
|
|
######################################################################
|
2021-09-06 10:20:26 +02:00
|
|
|
Section -MainProgram
|
|
|
|
${INSTALL_TYPE}
|
|
|
|
SetOverwrite ifnewer
|
|
|
|
SetOutPath "$INSTDIR"
|
2022-05-21 18:42:56 +02:00
|
|
|
File /r "..\\dist\\netbird_windows_amd64\\"
|
2021-09-06 10:20:26 +02:00
|
|
|
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
Section -Icons_Reg
|
|
|
|
SetOutPath "$INSTDIR"
|
2022-05-21 18:42:56 +02:00
|
|
|
WriteUninstaller "$INSTDIR\netbird_uninstall.exe"
|
2021-09-06 10:20:26 +02:00
|
|
|
|
|
|
|
WriteRegStr ${REG_ROOT} "${REG_APP_PATH}" "" "$INSTDIR\${MAIN_APP_EXE}"
|
|
|
|
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayName" "${APP_NAME}"
|
2022-05-21 18:42:56 +02:00
|
|
|
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "UninstallString" "$INSTDIR\netbird_uninstall.exe"
|
2021-09-06 10:20:26 +02:00
|
|
|
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayIcon" "$INSTDIR\${MAIN_APP_EXE}"
|
|
|
|
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "DisplayVersion" "${VERSION}"
|
|
|
|
WriteRegStr ${REG_ROOT} "${UNINSTALL_PATH}" "Publisher" "${COMP_NAME}"
|
|
|
|
|
2022-03-23 18:24:25 +01:00
|
|
|
WriteRegStr ${REG_ROOT} "${UI_REG_APP_PATH}" "" "$INSTDIR\${UI_APP_EXE}"
|
|
|
|
|
2021-09-06 10:20:26 +02:00
|
|
|
EnVar::SetHKLM
|
|
|
|
EnVar::AddValueEx "path" "$INSTDIR"
|
|
|
|
|
2022-05-25 19:41:03 +02:00
|
|
|
SetShellVarContext current
|
|
|
|
CreateShortCut "$SMPROGRAMS\${APP_NAME}.lnk" "$INSTDIR\${UI_APP_EXE}"
|
|
|
|
CreateShortCut "$DESKTOP\${APP_NAME}.lnk" "$INSTDIR\${UI_APP_EXE}"
|
|
|
|
SetShellVarContext all
|
2022-05-21 18:42:56 +02:00
|
|
|
|
2022-05-25 19:41:03 +02:00
|
|
|
ExecWait '"$INSTDIR\${MAIN_APP_EXE}" service install'
|
2022-03-11 14:05:44 +01:00
|
|
|
Exec '"$INSTDIR\${MAIN_APP_EXE}" service start'
|
2021-09-06 10:20:26 +02:00
|
|
|
# sleep a bit for visibility
|
|
|
|
Sleep 1000
|
|
|
|
SectionEnd
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
Section Uninstall
|
|
|
|
${INSTALL_TYPE}
|
|
|
|
|
2022-05-25 19:41:03 +02:00
|
|
|
ExecWait '"$INSTDIR\${MAIN_APP_EXE}" service stop'
|
2021-09-06 10:20:26 +02:00
|
|
|
Exec '"$INSTDIR\${MAIN_APP_EXE}" service uninstall'
|
2022-05-25 19:41:03 +02:00
|
|
|
# kill ui client
|
|
|
|
ExecWait `taskkill /im ${UI_APP_EXE}.exe`
|
2021-09-06 10:20:26 +02:00
|
|
|
# wait the service uninstall take unblock the executable
|
|
|
|
Sleep 3000
|
|
|
|
RmDir /r "$INSTDIR"
|
|
|
|
|
2022-05-25 19:41:03 +02:00
|
|
|
SetShellVarContext current
|
|
|
|
Delete "$DESKTOP\${APP_NAME}.lnk"
|
|
|
|
Delete "$SMPROGRAMS\${APP_NAME}.lnk"
|
|
|
|
SetShellVarContext all
|
|
|
|
|
2021-09-06 10:20:26 +02:00
|
|
|
DeleteRegKey ${REG_ROOT} "${REG_APP_PATH}"
|
|
|
|
DeleteRegKey ${REG_ROOT} "${UNINSTALL_PATH}"
|
|
|
|
EnVar::SetHKLM
|
|
|
|
EnVar::DeleteValue "path" "$INSTDIR"
|
2022-03-23 18:24:25 +01:00
|
|
|
SectionEnd
|
2022-05-25 19:41:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
Function LaunchLink
|
|
|
|
SetShellVarContext current
|
|
|
|
SetOutPath $INSTDIR
|
|
|
|
ShellExecAsUser::ShellExecAsUser "" "$DESKTOP\${APP_NAME}.lnk"
|
|
|
|
SetShellVarContext all
|
|
|
|
FunctionEnd
|