1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
|
# The NSIS (http://nsis.sourceforge.net) install script.
# This script is BSD licensed.
# use default compression to make anti-virus programs life easier
#SetCompressor /solid /final lzma
!include LogicLib.nsh
!include MUI2.nsh
!include WinMessages.nsh
!include FileFunc.nsh
!insertmacro GetParameters
!insertmacro GetOptions
!define VERSION "0.0.0"
!define QUADVERSION "0.0.0.0"
outFile "dnssec_trigger_setup_${VERSION}.exe"
Name "DnssecTrigger"
# default install directory
installDir "$PROGRAMFILES\DnssecTrigger"
installDirRegKey HKLM "Software\DnssecTrigger" "InstallLocation"
RequestExecutionLevel admin
#give credits to Nullsoft: BrandingText ""
VIAddVersionKey "ProductName" "Dnssec Trigger"
VIAddVersionKey "CompanyName" "NLnet Labs"
VIAddVersionKey "FileDescription" "(un)install dnssec-trigger"
VIAddVersionKey "LegalCopyright" "Copyright 2011, NLnet Labs"
VIAddVersionKey "FileVersion" "${QUADVERSION}"
VIAddVersionKey "ProductVersion" "${QUADVERSION}"
VIProductVersion "${QUADVERSION}"
!addplugindir .
; typedef struct _RECT {
; LONG left;
; LONG top;
; LONG right;
; LONG bottom;
; } RECT, *PRECT;
!define stRECT "(i, i, i, i) i"
# http://nsis.sourceforge.net/Refresh_SysTray
!macro RefreshSysTray
; $0: SysTray Window Handle
FindWindow $0 "Shell_TrayWnd" ""
FindWindow $0 "TrayNotifyWnd" "" $0
FindWindow $0 "SysPager" "" $0
FindWindow $0 "ToolbarWindow32" "" $0
; Create RECT struct
System::Call "*${stRECT} .r1"
; Get windows information
System::Call "User32::GetWindowRect(i, i) i (i r0, r1) .r2"
; Get left/top/right/bottom coords
; $2: Left, $3: Top, $4: Right, $5: Bottom
System::Call "*$1${stRECT} (.r2, .r3, .r4, .r5)"
System::Free $1
; $2: Width
IntOp $2 $4 - $2
; $3: Height
IntOp $3 $5 - $3
; $4: Small Icon Width
System::Call 'User32::GetSystemMetrics(i 49) i .r4'
; $5: Small Icon Height
System::Call 'User32::GetSystemMetrics(i 50) i .r5'
; $7: y - Start at the bottom
IntOp $7 $4 / 2
IntOp $7 $3 - $7
LoopY:
; $6: X - Start at the right
IntOp $6 $5 / 2
IntOp $6 $2 - $6
LoopX:
SendMessage $0 ${WM_MOUSEMOVE} 0 "$6 | $7"
IntOp $6 $6 - $4
IntCmp $6 0 EndLoopX EndLoopX LoopX
EndLoopX:
IntOp $7 $7 - $5
IntCmp $7 0 EndLoopY EndLoopY LoopY
EndLoopY:
!macroend
# delete tray icon for panel.
;typedef struct _NOTIFYICONDATA {
; DWORD cbSize;
; HWND hWnd;
; UINT uID;
; UINT uFlags;
; UINT uCallbackMessage;
; HICON hIcon;
; TCHAR szTip[64];
;}
!define stNOTIFYICONDATA '(&l4, i, i, i, i, i, &t64) i'
!define NIF_MESSAGE 0x00000001
!define NIF_ICON 0x00000002
!define NIF_TIP 0x00000004
!define NIM_ADD 0x00000000
!define NIM_MODIFY 0x00000001
!define NIM_DELETE 0x00000002
!macro DeleteTrayPanel
; $0: HWND of tray icon
FindWindow $0 "dnssec trigger tray icon" "" ""
#MessageBox MB_OK "panel found $0" ; 0 on failure
; this exits if no such tray icons exist
IntCmp $0 0 EndLoopTray
LoopTray:
; $1: NOTIFYICON structure
System::Call "*${stNOTIFYICONDATA} .r1"
; fill in the structure (skip the tooltiptext, skip icon)
System::Call "*$1${stNOTIFYICONDATA} (., r0, 5000, ${NIF_ICON}|${NIF_MESSAGE}|${NIF_TIP}, 0x401, 0)"
; tell tray to remove it
System::Call 'Shell32::Shell_NotifyIcon(i ${NIM_DELETE}, i r1) i.r2'
#MessageBox MB_OK "NIMDELETE $2" ; 1 on success, 0 on failure
System::Free $1
; find next tray icon
FindWindow $0 "dnssec trigger tray icon" "" "" $0
IntCmp $0 0 EndLoopTray LoopTray LoopTray
EndLoopTray:
!macroend
# Global Variables
Var StartMenuFolder
# use ReserveFile for files required before actual installation
# makes the installer start faster
#ReserveFile "System.dll"
#ReserveFile "NsExec.dll"
!define MUI_ICON "install.ico"
!define MUI_UNICON "uninstall.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_RIGHT
!define MUI_HEADERIMAGE_BITMAP "setup_top.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "setup_left.bmp"
!define MUI_ABORTWARNING
#!define MUI_FINISHPAGE_NOAUTOCLOSE # so we can inspect install log.
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "..\LICENSE"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\DnssecTrigger"
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
!define MUI_STARTMENUPAGE_DEFAULTFOLDER "DnssecTrigger"
!insertmacro MUI_PAGE_STARTMENU DnssecTriggerStartMenu $StartMenuFolder
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the uninstallation of Dnssec Trigger.$\r$\n$\r$\nClick Next to continue."
!define MUI_UNWELCOMEFINISHPAGE_BITMAP "setup_left_un.bmp"
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
!insertmacro MUI_LANGUAGE "English"
# default section, one per component, we have one component.
section "DnssecTrigger" SectionDnssecTrigger
SectionIn RO # cannot unselect this one
# real work in postinstall
sectionEnd
section "-hidden.postinstall"
# check if unbound installed (but not via dnssec-trigger)
ReadRegStr $R1 HKLM "Software\Unbound" "InstallLocation"
StrCmp $R1 "" doinstall 0
ReadRegStr $R1 HKLM "Software\Unbound" "DnssecTrigger"
StrCmp $R1 "yes" doinstall 0
# unbound installed but not ours, fail
Abort "Unbound is already installed, please uninstall it"
doinstall:
# must stop dnssec-triggerd, panel and unbound to update their exe
# (if installed).
ReadRegStr $R1 HKLM "Software\Unbound" "InstallLocation"
StrCmp $R1 "" donestop 0
DetailPrint "Stop tray icons"
nsExec::ExecToLog '"$R1\dnssec-trigger-control.exe" stoppanels'
DetailPrint "Stop dnssec-trigger daemon"
nsExec::ExecToLog '"$R1\dnssec-triggerd.exe" -w stop'
nsExec::ExecToLog '"$R1\dnssec-triggerd.exe" -c dnssectrigger -w waitstop'
DetailPrint "Stop unbound daemon"
nsExec::ExecToLog '"$R1\unbound.exe" -w stop'
nsExec::ExecToLog '"$R1\dnssec-triggerd.exe" -c unbound -w waitstop'
Sleep 1000
DetailPrint "Terminate processes"
# if somehow not gone, remove the tray icons forcefully.
# delete icons while HWNDs still exist.
!insertmacro DeleteTrayPanel
# killed 8 times, because there may be multiple users logged on.
proc::KillProcess "dnssec-trigger-panel"
proc::KillProcess "dnssec-trigger-panel"
proc::KillProcess "dnssec-trigger-panel"
proc::KillProcess "dnssec-trigger-panel"
proc::KillProcess "dnssec-trigger-panel"
proc::KillProcess "dnssec-trigger-panel"
proc::KillProcess "dnssec-trigger-panel"
proc::KillProcess "dnssec-trigger-panel"
proc::KillProcess "dnssec-triggerd"
proc::KillProcess "unbound"
Sleep 3000
donestop:
# copy files
setOutPath $INSTDIR
File "..\LICENSE"
File "..\tmp.collect\README.txt"
File /oname=dnssec-triggerd-temp.exe "..\dnssec-triggerd.exe"
Delete dnssec-triggerd.exe
Rename dnssec-triggerd-temp.exe dnssec-triggerd.exe
File "..\dnssec-trigger-panel.exe"
File "..\dnssec-trigger-control.exe"
File "..\dnssec-trigger-keygen.exe"
File /oname=unbound-temp.exe "..\tmp.collect\unbound.exe"
Delete unbound.exe
Rename unbound-temp.exe unbound.exe
File "..\tmp.collect\unbound-control.exe"
File "..\tmp.collect\unbound-anchor.exe"
File "..\tmp.collect\unbound-host.exe"
File "..\tmp.collect\unbound-checkconf.exe"
File "/oname=unbound-new.conf" "..\tmp.collect\unbound.conf"
File "..\winrc\alert.ico"
File "..\winrc\status.ico"
File "..\tmp.collect\*.dll"
File "/oname=dnssec-trigger-new.conf" "..\example.conf"
# store installation folder
WriteRegStr HKLM "Software\DnssecTrigger" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\DnssecTrigger" "ConfigFile" "$INSTDIR\dnssec-trigger.conf"
# no cron action at this time.
WriteRegStr HKLM "Software\DnssecTrigger" "CronAction" ""
WriteRegDWORD HKLM "Software\DnssecTrigger" "CronTime" 86400
# uninstaller
WriteUninstaller "uninst.exe"
# see if we are overwriting old IPs version
Var /GLOBAL replaceconfig
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "DisplayName"
# copy 19 characters "DnssecTigger 0.11x" for snapshots and rc versions.
StrCpy $1 $0 19
StrCmp $1 "DnssecTrigger 0.11" replace_ips no_replace_ips
StrCmp $1 "DnssecTrigger 0.10" replace_ips no_replace_ips
StrCmp $1 "DnssecTrigger 0.11_" replace_ips no_replace_ips
StrCmp $1 "DnssecTrigger 0.10_" replace_ips no_replace_ips
StrCmp $1 "DnssecTrigger 0.11r" replace_ips no_replace_ips
StrCmp $1 "DnssecTrigger 0.10r" replace_ips no_replace_ips
replace_ips:
StrCpy $replaceconfig "yes"
goto replace_check_done
no_replace_ips:
StrCpy $replaceconfig "no"
goto replace_check_done
replace_check_done:
# register uninstaller
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "DisplayName" "DnssecTrigger ${VERSION}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "UninstallString" "$\"$INSTDIR\uninst.exe$\""
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "QuietUninstallString" "$\"$INSTDIR\uninst.exe$\" /S"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "NoModify" "1"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "NoRepair" "1"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "URLInfoAbout" "http://nlnetlabs.nl"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger" "Publisher" "NLnet Labs"
# for a silent install (upgrade) config file changes make no
# sense, right now. If we change the registry entries,
# this will have to be fixed up here.
# If the config file contains old IP addresses, then we have to setup
# the config again.
StrCmp $replaceconfig "yes" do_config_anyway
IfSilent skip_config
do_config_anyway:
DetailPrint "Setup config files"
Delete "$INSTDIR\unbound.conf"
Rename "$INSTDIR\unbound-new.conf" "$INSTDIR\unbound.conf"
Delete "$INSTDIR\dnssec-trigger.conf"
Rename "$INSTDIR\dnssec-trigger-new.conf" "$INSTDIR\dnssec-trigger.conf"
# setup unbound registry entries
WriteRegStr HKLM "Software\Unbound" "InstallLocation" "$INSTDIR"
WriteRegStr HKLM "Software\Unbound" "ConfigFile" "$INSTDIR\unbound.conf"
WriteRegStr HKLM "Software\Unbound" "CronAction" ""
# setup that unbound is 'ours'
WriteRegStr HKLM "Software\Unbound" "DnssecTrigger" "yes"
WriteRegDWORD HKLM "Software\Unbound" "CronTime" 86400
# setup unbound.conf
ClearErrors
FileOpen $R1 "$INSTDIR\unbound.conf" a
IfErrors done_rk
FileSeek $R1 0 END
FileWrite $R1 "$\n$\nserver: auto-trust-anchor-file: $\"$INSTDIR\root.key$\"$\n"
FileWrite $R1 "remote-control: control-enable: yes$\n"
FileWrite $R1 " server-key-file: $\"$INSTDIR\unbound_server.key$\"$\n"
FileWrite $R1 " server-cert-file: $\"$INSTDIR\unbound_server.pem$\"$\n"
FileWrite $R1 " control-key-file: $\"$INSTDIR\unbound_control.key$\"$\n"
FileWrite $R1 " control-cert-file: $\"$INSTDIR\unbound_control.pem$\"$\n"
FileWrite $R1 "$\n"
FileClose $R1
done_rk:
WriteRegStr HKLM "Software\Unbound" "RootAnchor" "$\"$INSTDIR\unbound-anchor.exe$\" -a $\"$INSTDIR\root.key$\" -c $\"$INSTDIR\icannbundle.pem$\""
# write key locations to file
ClearErrors
FileOpen $R1 "$INSTDIR\dnssec-trigger.conf" a
IfErrors done_keys
FileSeek $R1 0 END
FileWrite $R1 "$\n"
FileWrite $R1 "server-key-file: $\"$INSTDIR\dnssec_trigger_server.key$\"$\n"
FileWrite $R1 "server-cert-file: $\"$INSTDIR\dnssec_trigger_server.pem$\"$\n"
FileWrite $R1 "control-key-file: $\"$INSTDIR\dnssec_trigger_control.key$\"$\n"
FileWrite $R1 "control-cert-file: $\"$INSTDIR\dnssec_trigger_control.pem$\"$\n"
FileWrite $R1 "$\n"
FileClose $R1
done_keys:
DetailPrint "Setup keys"
# generate keys
nsExec::ExecToLog '"$INSTDIR\dnssec-trigger-keygen.exe" -d "$INSTDIR"'
# generate unbound keys
nsExec::ExecToLog '"$INSTDIR\dnssec-trigger-keygen.exe" -u -d "$INSTDIR"'
skip_config:
# If silent (upgrade), then the start menu items can be left untouched
# (in their original present/absent state).
IfSilent skip_menu
# start menu items
!insertmacro MUI_STARTMENU_WRITE_BEGIN DnssecTriggerStartMenu
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\uninst.exe" "" "" "" "" "" "Uninstall dnssec trigger"
!insertmacro MUI_STARTMENU_WRITE_END
skip_menu:
# install unbound service entry
DetailPrint "Start unbound daemon"
nsExec::ExecToLog '"$INSTDIR\unbound.exe" -w install'
nsExec::ExecToLog '"$INSTDIR\unbound.exe" -w start'
# install service entry
DetailPrint "Start dnssec-trigger daemon"
nsExec::ExecToLog '"$INSTDIR\dnssec-triggerd.exe" -w install'
# start service
nsExec::ExecToLog '"$INSTDIR\dnssec-triggerd.exe" -w start'
# register tray icon
DetailPrint "Start tray icon"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "DnssecTrigger" '"$INSTDIR\dnssec-trigger-panel.exe"'
# start tray icon
Exec '"$INSTDIR\dnssec-trigger-panel.exe"'
# make sure 'old' tray icons disappear.
!insertmacro RefreshSysTray
# is selfdelete set? (/delself on commandline).
${GetParameters} $R0
ClearErrors
${GetOptions} $R0 /delself $0
IfErrors done_delself 0
# delete self (after reboot since we are currently opened to execute)
Delete /REBOOTOK "$EXEPATH"
done_delself:
ClearErrors
sectionEnd
# set section descriptions
LangString DESC_dnssectrigger ${LANG_ENGLISH} "The dnssec trigger package. $\r$\n$\r$\nStarts a service and a tray icon, logs to the Application Log, and the config file is its Program Files folder."
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SectionDnssecTrigger} $(DESC_dnssectrigger)
!insertmacro MUI_FUNCTION_DESCRIPTION_END
# setup macros for uninstall functions.
!ifdef UN
!undef UN
!endif
!define UN "un."
# uninstaller section
section "un.DnssecTrigger"
# remove tray icon from startup list
DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Run" "DnssecTrigger"
# stop tray icon
DetailPrint "Remove tray icons"
nsExec::ExecToLog '"$INSTDIR\dnssec-trigger-control.exe" stoppanels'
# stop service
DetailPrint "Remove dnssec-trigger daemon"
nsExec::ExecToLog '"$INSTDIR\dnssec-triggerd.exe" -w stop'
nsExec::ExecToLog '"$INSTDIR\dnssec-triggerd.exe" -c dnssectrigger -w waitstop'
# uninstall service entry
nsExec::ExecToLog '"$INSTDIR\dnssec-triggerd.exe" -w remove'
# stop unbound service
DetailPrint "Remove unbound daemon"
nsExec::ExecToLog '"$INSTDIR\unbound.exe" -w stop'
nsExec::ExecToLog '"$INSTDIR\dnssec-triggerd.exe" -c unbound -w waitstop'
nsExec::ExecToLog '"$INSTDIR\unbound.exe" -w remove'
# remove DNS override entries from registry
nsExec::ExecToLog '"$INSTDIR\dnssec-triggerd.exe" -u'
# give the panel time to process the messages.
Sleep 2000
# remove tray icon if panel killed too fast to remove it itself.
!insertmacro RefreshSysTray
# give the panel time to process the messages.
Sleep 1000
# deregister uninstall
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\DnssecTrigger"
Delete "$INSTDIR\uninst.exe" # delete self
Delete "$INSTDIR\LICENSE"
Delete "$INSTDIR\README.txt"
Delete "$INSTDIR\dnssec-triggerd.exe"
Delete "$INSTDIR\dnssec-triggerd-temp.exe"
Delete "$INSTDIR\dnssec-trigger-panel.exe"
Delete "$INSTDIR\dnssec-trigger-control.exe"
Delete "$INSTDIR\dnssec-trigger-keygen.exe"
Delete "$INSTDIR\unbound.exe"
Delete "$INSTDIR\unbound-temp.exe"
Delete "$INSTDIR\unbound-control.exe"
Delete "$INSTDIR\unbound-anchor.exe"
Delete "$INSTDIR\unbound-host.exe"
Delete "$INSTDIR\unbound-checkconf.exe"
Delete "$INSTDIR\unbound.conf"
Delete "$INSTDIR\unbound-new.conf"
Delete "$INSTDIR\alert.ico"
Delete "$INSTDIR\status.ico"
Delete "$INSTDIR\*.dll"
Delete "$INSTDIR\dnssec-trigger.conf"
Delete "$INSTDIR\dnssec-trigger-new.conf"
RMDir "$INSTDIR"
# start menu items
!insertmacro MUI_STARTMENU_GETFOLDER DnssecTriggerStartMenu $StartMenuFolder
Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk"
RMDir "$SMPROGRAMS\$StartMenuFolder"
DeleteRegKey HKLM "Software\Unbound"
DeleteRegKey HKLM "Software\DnssecTrigger"
sectionEnd
|