]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - winrc/setup.nsi
import unbound 1.4.22
[FreeBSD/FreeBSD.git] / winrc / setup.nsi
1 # The NSIS (http://nsis.sourceforge.net) install script.
2 # This script is BSD licensed.
3 SetCompressor /solid /final lzma
4
5 !include LogicLib.nsh
6 !include MUI2.nsh
7
8 !define VERSION "0.0.0"
9 !define QUADVERSION "0.0.0.0"
10
11 outFile "unbound_setup_${VERSION}.exe"
12 Name "Unbound"
13
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}"
26
27 # Global Variables
28 Var StartMenuFolder
29
30 # use ReserveFile for files required before actual installation
31 # makes the installer start faster
32 #ReserveFile "System.dll"
33 #ReserveFile "NsExec.dll"
34
35 !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install-nsis.ico"
36 !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico"
37
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.
44
45 !insertmacro MUI_PAGE_WELCOME
46 !insertmacro MUI_PAGE_LICENSE "..\LICENSE"
47 !insertmacro MUI_PAGE_COMPONENTS
48 !insertmacro MUI_PAGE_DIRECTORY
49
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
55
56 !insertmacro MUI_PAGE_INSTFILES
57 !insertmacro MUI_PAGE_FINISH
58
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
64
65 !insertmacro MUI_LANGUAGE "English" 
66
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
71 sectionEnd
72
73 section "Root anchor - DNSSEC" SectionRootKey
74         # add estimated size for key (Kb)
75         AddSize 2
76 sectionEnd
77
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)
81         AddSize 2
82         SetOutPath $INSTDIR
83
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"
86
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
91                 SetOutPath "C:\"
92                 RMDir "$INSTDIR"  # doesnt work directory in use by us ...
93                 Abort
94         ${EndIf}
95 sectionEnd
96
97 section "-hidden.postinstall"
98         # copy files
99         setOutPath $INSTDIR
100         File "..\LICENSE"
101         File "README.txt"
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"
111         File "service.conf"
112         File "..\doc\example.conf"
113
114         # Store Root Key choice
115         SectionGetFlags ${SectionRootKey} $R0
116         IntOp $R0 $R0 & ${SF_SELECTED}
117         ${If} $R0 == ${SF_SELECTED}
118                 ClearErrors
119                 FileOpen $R1 "$INSTDIR\service.conf" a
120                 IfErrors done_rk
121                 FileSeek $R1 0 END
122                 FileWrite $R1 "$\nserver: auto-trust-anchor-file: $\"$INSTDIR\root.key$\"$\n"
123                 FileClose $R1
124           done_rk:
125                 WriteRegStr HKLM "Software\Unbound" "RootAnchor" "$\"$INSTDIR\unbound-anchor.exe$\" -a $\"$INSTDIR\root.key$\" -c $\"$INSTDIR\icannbundle.pem$\""
126         ${Else}
127                 WriteRegStr HKLM "Software\Unbound" "RootAnchor" ""
128         ${EndIf}
129
130         # Store DLV choice
131         SectionGetFlags ${SectionDLV} $R0
132         IntOp $R0 $R0 & ${SF_SELECTED}
133         ${If} $R0 == ${SF_SELECTED}
134                 ClearErrors
135                 FileOpen $R1 "$INSTDIR\service.conf" a
136                 IfErrors done_dlv
137                 FileSeek $R1 0 END
138                 FileWrite $R1 "$\nserver: dlv-anchor-file: $\"$INSTDIR\dlv.isc.org.key$\"$\n"
139                 FileClose $R1
140           done_dlv:
141                 WriteRegStr HKLM "Software\Unbound" "CronAction" "$\"$INSTDIR\anchor-update.exe$\" dlv.isc.org $\"$INSTDIR\dlv.isc.org.key$\""
142         ${Else}
143                 WriteRegStr HKLM "Software\Unbound" "CronAction" ""
144         ${EndIf}
145
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
150
151         # uninstaller
152         WriteUninstaller "uninst.exe"
153
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"
162
163         # start menu items
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
169
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'
174 sectionEnd
175
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."
180
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
186
187 # setup macros for uninstall functions.
188 !ifdef UN
189 !undef UN
190 !endif
191 !define UN "un."
192
193 # uninstaller section
194 section "un.Unbound"
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"
217         RMDir "$INSTDIR"
218
219         # start menu items
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"
224
225         DeleteRegKey HKLM "Software\Unbound"
226 sectionEnd