]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/winrc/setup.nsi
network_cmds-543.tar.gz
[apple/network_cmds.git] / unbound / 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-control-setup.cmd"
111 File "unbound-website.url"
112 File "service.conf"
113 File "..\doc\example.conf"
114
115 # Store Root Key choice
116 SectionGetFlags ${SectionRootKey} $R0
117 IntOp $R0 $R0 & ${SF_SELECTED}
118 ${If} $R0 == ${SF_SELECTED}
119 ClearErrors
120 FileOpen $R1 "$INSTDIR\service.conf" a
121 IfErrors done_rk
122 FileSeek $R1 0 END
123 FileWrite $R1 "$\nserver: auto-trust-anchor-file: $\"$INSTDIR\root.key$\"$\n"
124 FileClose $R1
125 done_rk:
126 WriteRegStr HKLM "Software\Unbound" "RootAnchor" "$\"$INSTDIR\unbound-anchor.exe$\" -a $\"$INSTDIR\root.key$\" -c $\"$INSTDIR\icannbundle.pem$\""
127 ${Else}
128 WriteRegStr HKLM "Software\Unbound" "RootAnchor" ""
129 ${EndIf}
130
131 # Store DLV choice
132 SectionGetFlags ${SectionDLV} $R0
133 IntOp $R0 $R0 & ${SF_SELECTED}
134 ${If} $R0 == ${SF_SELECTED}
135 ClearErrors
136 FileOpen $R1 "$INSTDIR\service.conf" a
137 IfErrors done_dlv
138 FileSeek $R1 0 END
139 FileWrite $R1 "$\nserver: dlv-anchor-file: $\"$INSTDIR\dlv.isc.org.key$\"$\n"
140 FileClose $R1
141 done_dlv:
142 WriteRegStr HKLM "Software\Unbound" "CronAction" "$\"$INSTDIR\anchor-update.exe$\" dlv.isc.org $\"$INSTDIR\dlv.isc.org.key$\""
143 ${Else}
144 WriteRegStr HKLM "Software\Unbound" "CronAction" ""
145 ${EndIf}
146
147 # store installation folder
148 WriteRegStr HKLM "Software\Unbound" "InstallLocation" "$INSTDIR"
149 WriteRegStr HKLM "Software\Unbound" "ConfigFile" "$INSTDIR\service.conf"
150 WriteRegDWORD HKLM "Software\Unbound" "CronTime" 86400
151
152 # uninstaller
153 WriteUninstaller "uninst.exe"
154
155 # register uninstaller
156 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "DisplayName" "Unbound"
157 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "UninstallString" "$\"$INSTDIR\uninst.exe$\""
158 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "QuietUninstallString" "$\"$INSTDIR\uninst.exe$\" /S"
159 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "NoModify" "1"
160 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "NoRepair" "1"
161 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "URLInfoAbout" "http://unbound.net"
162 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "Publisher" "NLnet Labs"
163
164 # start menu items
165 !insertmacro MUI_STARTMENU_WRITE_BEGIN UnboundStartMenu
166 CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
167 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\unbound.net website.lnk" "$INSTDIR\unbound-website.url" "" "$INSTDIR\unbound.exe" "" "" "" "Visit the unbound website"
168 CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe" "" "" "" "" "" "Uninstall unbound"
169 !insertmacro MUI_STARTMENU_WRITE_END
170
171 # install service entry
172 nsExec::ExecToLog '"$INSTDIR\unbound-service-install.exe"'
173 # start unbound service
174 nsExec::ExecToLog '"$INSTDIR\unbound-service-install.exe" start'
175 sectionEnd
176
177 # set section descriptions
178 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."
179 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."
180 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
182 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
183 !insertmacro MUI_DESCRIPTION_TEXT ${SectionUnbound} $(DESC_unbound)
184 !insertmacro MUI_DESCRIPTION_TEXT ${SectionRootKey} $(DESC_rootkey)
185 !insertmacro MUI_DESCRIPTION_TEXT ${SectionDLV} $(DESC_dlv)
186 !insertmacro MUI_FUNCTION_DESCRIPTION_END
187
188 # setup macros for uninstall functions.
189 !ifdef UN
190 !undef UN
191 !endif
192 !define UN "un."
193
194 # uninstaller section
195 section "un.Unbound"
196 # stop unbound service
197 nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe" stop'
198 # uninstall service entry
199 nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe"'
200 # deregister uninstall
201 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound"
202 Delete "$INSTDIR\uninst.exe" # delete self
203 Delete "$INSTDIR\LICENSE"
204 Delete "$INSTDIR\README.txt"
205 Delete "$INSTDIR\unbound.exe"
206 Delete "$INSTDIR\unbound-checkconf.exe"
207 Delete "$INSTDIR\unbound-control.exe"
208 Delete "$INSTDIR\unbound-host.exe"
209 Delete "$INSTDIR\unbound-anchor.exe"
210 Delete "$INSTDIR\unbound-service-install.exe"
211 Delete "$INSTDIR\unbound-service-remove.exe"
212 Delete "$INSTDIR\anchor-update.exe"
213 Delete "$INSTDIR\unbound-control-setup.cmd"
214 Delete "$INSTDIR\unbound-website.url"
215 Delete "$INSTDIR\service.conf"
216 Delete "$INSTDIR\example.conf"
217 Delete "$INSTDIR\dlv.isc.org.key"
218 Delete "$INSTDIR\root.key"
219 RMDir "$INSTDIR"
220
221 # start menu items
222 !insertmacro MUI_STARTMENU_GETFOLDER UnboundStartMenu $StartMenuFolder
223 Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
224 Delete "$SMPROGRAMS\$StartMenuFolder\unbound.net website.lnk"
225 RMDir "$SMPROGRAMS\$StartMenuFolder"
226
227 DeleteRegKey HKLM "Software\Unbound"
228 sectionEnd