xref: /netbsd/external/bsd/unbound/dist/winrc/setup.nsi (revision 9295812b)
1# The NSIS (http://nsis.sourceforge.net) install script.
2# This script is BSD licensed.
3
4# use the default compression to help anti-virus in scanning us
5#SetCompressor /solid /final lzma
6
7!include LogicLib.nsh
8!include MUI2.nsh
9
10!define VERSION "0.0.0"
11!define QUADVERSION "0.0.0.0"
12
13outFile "unbound_setup_${VERSION}.exe"
14Name "Unbound"
15
16# default install directory
17installDir "$PROGRAMFILES64\Unbound"
18installDirRegKey HKLM "Software\Unbound" "InstallLocation"
19RequestExecutionLevel admin
20#give credits to Nullsoft: BrandingText ""
21VIAddVersionKey "ProductName" "Unbound"
22VIAddVersionKey "CompanyName" "NLnet Labs"
23VIAddVersionKey "FileDescription" "(un)install the unbound DNS resolver"
24VIAddVersionKey "LegalCopyright" "Copyright 2009, NLnet Labs"
25VIAddVersionKey "FileVersion" "${QUADVERSION}"
26VIAddVersionKey "ProductVersion" "${QUADVERSION}"
27VIProductVersion "${QUADVERSION}"
28
29# Global Variables
30Var StartMenuFolder
31
32# use ReserveFile for files required before actual installation
33# makes the installer start faster
34#ReserveFile "System.dll"
35#ReserveFile "NsExec.dll"
36
37!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install-nsis.ico"
38!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall-nsis.ico"
39
40!define MUI_HEADERIMAGE
41!define MUI_HEADERIMAGE_RIGHT
42!define MUI_HEADERIMAGE_BITMAP "setup_top.bmp"
43!define MUI_WELCOMEFINISHPAGE_BITMAP "setup_left.bmp"
44!define MUI_ABORTWARNING
45#!define MUI_FINISHPAGE_NOAUTOCLOSE  # so we can inspect install log.
46
47!insertmacro MUI_PAGE_WELCOME
48!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
49!insertmacro MUI_PAGE_COMPONENTS
50!insertmacro MUI_PAGE_DIRECTORY
51
52!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
53!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Unbound"
54!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
55!define MUI_STARTMENUPAGE_DEFAULTFOLDER "Unbound"
56!insertmacro MUI_PAGE_STARTMENU UnboundStartMenu $StartMenuFolder
57
58!insertmacro MUI_PAGE_INSTFILES
59!insertmacro MUI_PAGE_FINISH
60
61!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the uninstallation of Unbound.$\r$\n$\r$\nClick Next to continue."
62!insertmacro MUI_UNPAGE_WELCOME
63!insertmacro MUI_UNPAGE_CONFIRM
64!insertmacro MUI_UNPAGE_INSTFILES
65!insertmacro MUI_UNPAGE_FINISH
66
67!insertmacro MUI_LANGUAGE "English"
68
69# default section, one per component, we have one component.
70section "Unbound" SectionUnbound
71	SectionIn RO  # cannot unselect this one
72	# real work in postinstall
73sectionEnd
74
75section "Root anchor - DNSSEC" SectionRootKey
76	# add estimated size for key (Kb)
77	AddSize 2
78sectionEnd
79
80section "-hidden.postinstall"
81	# copy files
82	SetRegView 64
83	setOutPath $INSTDIR
84	File "..\LICENSE"
85	File "README.txt"
86	File "..\unbound.exe"
87	File "..\unbound-checkconf.exe"
88	File "..\unbound-control.exe"
89	File "..\unbound-host.exe"
90	File "..\unbound-anchor.exe"
91	File "..\unbound-service-install.exe"
92	File "..\unbound-service-remove.exe"
93	File "..\anchor-update.exe"
94	File "..\root.key"
95	File "unbound-control-setup.cmd"
96	File "unbound-website.url"
97	File "..\doc\example.conf"
98	File "..\doc\Changelog"
99
100	# Does service.conf already exist?
101	IfFileExists "$INSTDIR\service.conf" 0 service_conf_not_found
102	# if so, leave it be and place the shipped file under another name
103	File /oname=service.conf.shipped "service.conf"
104	goto end_service_conf_not_found
105	# or, it is not there, place it and fill it.
106	service_conf_not_found:
107	File "service.conf"
108
109	# Store Root Key choice
110	SectionGetFlags ${SectionRootKey} $R0
111	IntOp $R0 $R0 & ${SF_SELECTED}
112	${If} $R0 == ${SF_SELECTED}
113		ClearErrors
114		FileOpen $R1 "$INSTDIR\service.conf" a
115		IfErrors done_rk
116		FileSeek $R1 0 END
117		FileWrite $R1 "$\nserver: auto-trust-anchor-file: $\"$INSTDIR\root.key$\"$\n"
118		FileClose $R1
119	  done_rk:
120		WriteRegStr HKLM "Software\Unbound" "RootAnchor" "$\"$INSTDIR\unbound-anchor.exe$\" -a $\"$INSTDIR\root.key$\" -c $\"$INSTDIR\icannbundle.pem$\""
121	${Else}
122		WriteRegStr HKLM "Software\Unbound" "RootAnchor" ""
123	${EndIf}
124	end_service_conf_not_found:
125
126	# store installation folder
127	WriteRegStr HKLM "Software\Unbound" "InstallLocation" "$INSTDIR"
128	WriteRegStr HKLM "Software\Unbound" "ConfigFile" "$INSTDIR\service.conf"
129	WriteRegStr HKLM "Software\Unbound" "CronAction" ""
130	WriteRegDWORD HKLM "Software\Unbound" "CronTime" 86400
131
132	# uninstaller
133	WriteUninstaller "uninst.exe"
134
135	# register uninstaller
136	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "DisplayName" "Unbound"
137	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "UninstallString" "$\"$INSTDIR\uninst.exe$\""
138	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "QuietUninstallString" "$\"$INSTDIR\uninst.exe$\" /S"
139	WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "NoModify" "1"
140	WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "NoRepair" "1"
141	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "URLInfoAbout" "http://unbound.net"
142	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound" "Publisher" "NLnet Labs"
143
144	# start menu items
145	!insertmacro MUI_STARTMENU_WRITE_BEGIN UnboundStartMenu
146	CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
147	CreateShortCut "$SMPROGRAMS\$StartMenuFolder\unbound.net website.lnk" "$INSTDIR\unbound-website.url" "" "$INSTDIR\unbound.exe" "" "" "" "Visit the unbound website"
148	CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe" "" "" "" "" "" "Uninstall unbound"
149	!insertmacro MUI_STARTMENU_WRITE_END
150
151	# install service entry
152	nsExec::ExecToLog '"$INSTDIR\unbound-service-install.exe"'
153	Pop $0 # return value/error/timeout
154	# start unbound service
155	nsExec::ExecToLog '"$INSTDIR\unbound-service-install.exe" start'
156	Pop $0 # return value/error/timeout
157sectionEnd
158
159# set section descriptions
160LangString 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."
161LangString 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."
162
163!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
164  !insertmacro MUI_DESCRIPTION_TEXT ${SectionUnbound} $(DESC_unbound)
165  !insertmacro MUI_DESCRIPTION_TEXT ${SectionRootKey} $(DESC_rootkey)
166!insertmacro MUI_FUNCTION_DESCRIPTION_END
167
168# setup macros for uninstall functions.
169!ifdef UN
170!undef UN
171!endif
172!define UN "un."
173
174# uninstaller section
175section "un.Unbound"
176	SetRegView 64
177	# stop unbound service
178	nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe" stop'
179	Pop $0 # return value/error/timeout
180	# uninstall service entry
181	nsExec::ExecToLog '"$INSTDIR\unbound-service-remove.exe"'
182	Pop $0 # return value/error/timeout
183	# deregister uninstall
184	DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Unbound"
185	Delete "$INSTDIR\uninst.exe"   # delete self
186	Delete "$INSTDIR\LICENSE"
187	Delete "$INSTDIR\README.txt"
188	Delete "$INSTDIR\unbound.exe"
189	Delete "$INSTDIR\unbound-checkconf.exe"
190	Delete "$INSTDIR\unbound-control.exe"
191	Delete "$INSTDIR\unbound-host.exe"
192	Delete "$INSTDIR\unbound-anchor.exe"
193	Delete "$INSTDIR\unbound-service-install.exe"
194	Delete "$INSTDIR\unbound-service-remove.exe"
195	Delete "$INSTDIR\anchor-update.exe"
196	Delete "$INSTDIR\unbound-control-setup.cmd"
197	Delete "$INSTDIR\unbound-website.url"
198	# keep the service.conf with potential local modifications
199	#Delete "$INSTDIR\service.conf"
200	Delete "$INSTDIR\service.conf.shipped"
201	Delete "$INSTDIR\example.conf"
202	Delete "$INSTDIR\Changelog"
203	Delete "$INSTDIR\root.key"
204	RMDir "$INSTDIR"
205
206	# start menu items
207	!insertmacro MUI_STARTMENU_GETFOLDER UnboundStartMenu $StartMenuFolder
208	Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
209	Delete "$SMPROGRAMS\$StartMenuFolder\unbound.net website.lnk"
210	RMDir "$SMPROGRAMS\$StartMenuFolder"
211
212	DeleteRegKey HKLM "Software\Unbound"
213sectionEnd
214