1 # The NSIS (http://nsis.sourceforge.net) install script.
2 # This script is BSD licensed.
3 SetCompressor /solid /final lzma
8 !define VERSION "0.0.0"
9 !define QUADVERSION "0.0.0.0"
11 outFile "unbound_setup_${VERSION}.exe"
14 # default install directory
15 installDir "$PROGRAMFILES\Unbound"
16 installDirRegKey HKLM "Software\Unbound" "InstallLocation"
17 RequestExecutionLevel admin
18 #give credits to Nullsoft: BrandingText ""
19 VIAddVersionKey "ProductName" "Unbound"
20 VIAddVersionKey "CompanyName" "NLnet Labs"
21 VIAddVersionKey "FileDescription" "(un)install the unbound DNS resolver"
22 VIAddVersionKey "LegalCopyright" "Copyright 2009, NLnet Labs"
23 VIAddVersionKey "FileVersion" "${QUADVERSION}"
24 VIAddVersionKey "ProductVersion" "${QUADVERSION}"
25 VIProductVersion "${QUADVERSION}"
30 # use ReserveFile for files required before actual installation
31 # makes the installer start faster
32 #ReserveFile "System.dll"
33 #ReserveFile "NsExec.dll"
35 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install-nsis.ico"
36 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico"
38 !define MUI_HEADERIMAGE
39 !define MUI_HEADERIMAGE_RIGHT
40 !define MUI_HEADERIMAGE_BITMAP "setup_top.bmp"
41 !define MUI_WELCOMEFINISHPAGE_BITMAP "setup_left.bmp"
42 !define MUI_ABORTWARNING
43 #!define MUI_FINISHPAGE_NOAUTOCLOSE # so we can inspect install log.
45 !insertmacro MUI_PAGE_WELCOME
46 !insertmacro MUI_PAGE_LICENSE "..\LICENSE"
47 !insertmacro MUI_PAGE_COMPONENTS
48 !insertmacro MUI_PAGE_DIRECTORY
50 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
51 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Unbound"
52 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
53 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "Unbound"
54 !insertmacro MUI_PAGE_STARTMENU UnboundStartMenu $StartMenuFolder
56 !insertmacro MUI_PAGE_INSTFILES
57 !insertmacro MUI_PAGE_FINISH
59 !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the uninstallation of Unbound.$\r$\n$\r$\nClick Next to continue."
60 !insertmacro MUI_UNPAGE_WELCOME
61 !insertmacro MUI_UNPAGE_CONFIRM
62 !insertmacro MUI_UNPAGE_INSTFILES
63 !insertmacro MUI_UNPAGE_FINISH
65 !insertmacro MUI_LANGUAGE "English"
67 # default section, one per component, we have one component.
68 section "Unbound" SectionUnbound
69 SectionIn RO # cannot unselect this one
70 # real work in postinstall
73 section "Root anchor - DNSSEC" SectionRootKey
74 # add estimated size for key (Kb)
78 # the /o means it is not selected by default.
79 section /o "DLV - dlv.isc.org" SectionDLV
80 # add estimated size for key (Kb)
84 # libgcc exception lib used by NSISdl plugin (in crosscompile).
85 File /nonfatal "/oname=$PLUGINSDIR\libgcc_s_sjlj-1.dll" "/usr/i686-w64-mingw32/sys-root/mingw/bin/libgcc_s_sjlj-1.dll"
87 NSISdl::download "http://ftp.isc.org/www/dlv/dlv.isc.org.key" "$INSTDIR\dlv.isc.org.key"
88 Pop $R0 # result from Inetc::get
89 ${If} $R0 != "success"
90 MessageBox MB_OK|MB_ICONEXCLAMATION "Download error (ftp.isc.org: $R0), click OK to abort installation" /SD IDOK
92 RMDir "$INSTDIR" # doesnt work directory in use by us ...
97 section "-hidden.postinstall"
102 File "..\unbound.exe"
103 File "..\unbound-checkconf.exe"
104 File "..\unbound-control.exe"
105 File "..\unbound-host.exe"
106 File "..\unbound-anchor.exe"
107 File "..\unbound-service-install.exe"
108 File "..\unbound-service-remove.exe"
109 File "..\anchor-update.exe"
110 File "unbound-website.url"
112 File "..\doc\example.conf"
114 # Store Root Key choice
115 SectionGetFlags ${SectionRootKey} $R0
116 IntOp $R0 $R0 & ${SF_SELECTED}
117 ${If} $R0 == ${SF_SELECTED}
119 FileOpen $R1 "$INSTDIR\service.conf" a
122 FileWrite $R1 "$\nserver: auto-trust-anchor-file: $\"$INSTDIR\root.key$\"$\n"
125 WriteRegStr HKLM "Software\Unbound" "RootAnchor" "$\"$INSTDIR\unbound-anchor.exe$\" -a $\"$INSTDIR\root.key$\" -c $\"$INSTDIR\icannbundle.pem$\""
127 WriteRegStr HKLM "Software\Unbound" "RootAnchor" ""
131 SectionGetFlags ${SectionDLV} $R0
132 IntOp $R0 $R0 & ${SF_SELECTED}
133 ${If} $R0 == ${SF_SELECTED}
135 FileOpen $R1 "$INSTDIR\service.conf" a
138 FileWrite $R1 "$\nserver: dlv-anchor-file: $\"$INSTDIR\dlv.isc.org.key$\"$\n"
141 WriteRegStr HKLM "Software\Unbound" "CronAction" "$\"$INSTDIR\anchor-update.exe$\" dlv.isc.org $\"$INSTDIR\dlv.isc.org.key$\""
143 WriteRegStr HKLM "Software\Unbound" "CronAction" ""
146 # store installation folder
147 WriteRegStr HKLM "Software\Unbound" "InstallLocation" "$INSTDIR"
148 WriteRegStr HKLM "Software\Unbound" "ConfigFile" "$INSTDIR\service.conf"
149 WriteRegDWORD HKLM "Software\Unbound" "CronTime" 86400
152 WriteUninstaller "uninst.exe"
154 # register uninstaller
155 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "DisplayName" "Unbound"
156 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "UninstallString" "$\"$INSTDIR\uninst.exe$\""
157 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "QuietUninstallString" "$\"$INSTDIR\uninst.exe$\" /S"
158 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "NoModify" "1"
159 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "NoRepair" "1"
160 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "URLInfoAbout" "http://unbound.net"
161 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "Publisher" "NLnet Labs"
164 !insertmacro MUI_STARTMENU_WRITE_BEGIN UnboundStartMenu
165 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
166 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\unbound.net website.lnk" "$INSTDIR\unbound-website.url" "" "$INSTDIR\unbound.exe" "" "" "" "Visit the unbound website"
167 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe" "" "" "" "" "" "Uninstall unbound"
168 !insertmacro MUI_STARTMENU_WRITE_END
170 # install service entry
171 nsExec::ExecToLog '"$INSTDIR\unbound-service-install.exe"'
172 # start unbound service
173 nsExec::ExecToLog '"$INSTDIR\unbound-service-install.exe" start'
176 # set section descriptions
177 LangString DESC_unbound ${LANG_ENGLISH} "The base unbound DNS(SEC) validating caching resolver. $\r$\n$\r$\nStarted at boot from the Services control panel, logs to the Application Log, and the config file is its Program Files folder."
178 LangString DESC_rootkey ${LANG_ENGLISH} "Set up to use the DNSSEC root trust anchor. It is automatically updated. $\r$\n$\r$\nThis provides the main key that is used for security verification."
179 LangString DESC_dlv ${LANG_ENGLISH} "Set up to use DLV with dlv.isc.org. Downloads the key during install. $\r$\n$\r$\nIt fetches additional public keys that are used for security verification by querying the isc.org server with names encountered."
181 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
182 !insertmacro MUI_DESCRIPTION_TEXT ${SectionUnbound} $(DESC_unbound)
183 !insertmacro MUI_DESCRIPTION_TEXT ${SectionRootKey} $(DESC_rootkey)
184 !insertmacro MUI_DESCRIPTION_TEXT ${SectionDLV} $(DESC_dlv)
185 !insertmacro MUI_FUNCTION_DESCRIPTION_END
187 # setup macros for uninstall functions.
193 # uninstaller section
195 # stop unbound service
196 nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe" stop'
197 # uninstall service entry
198 nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe"'
199 # deregister uninstall
200 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound"
201 Delete "$INSTDIR\uninst.exe" # delete self
202 Delete "$INSTDIR\LICENSE"
203 Delete "$INSTDIR\README.txt"
204 Delete "$INSTDIR\unbound.exe"
205 Delete "$INSTDIR\unbound-checkconf.exe"
206 Delete "$INSTDIR\unbound-control.exe"
207 Delete "$INSTDIR\unbound-host.exe"
208 Delete "$INSTDIR\unbound-anchor.exe"
209 Delete "$INSTDIR\unbound-service-install.exe"
210 Delete "$INSTDIR\unbound-service-remove.exe"
211 Delete "$INSTDIR\anchor-update.exe"
212 Delete "$INSTDIR\unbound-website.url"
213 Delete "$INSTDIR\service.conf"
214 Delete "$INSTDIR\example.conf"
215 Delete "$INSTDIR\dlv.isc.org.key"
216 Delete "$INSTDIR\root.key"
220 !insertmacro MUI_STARTMENU_GETFOLDER UnboundStartMenu $StartMenuFolder
221 Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
222 Delete "$SMPROGRAMS\$StartMenuFolder\unbound.net website.lnk"
223 RMDir "$SMPROGRAMS\$StartMenuFolder"
225 DeleteRegKey HKLM "Software\Unbound"