]> git.proxmox.com Git - mirror_smartmontools-debian.git/blob - os_win32/installer.nsi
Merge commit 'upstream/5.40+svn3296'
[mirror_smartmontools-debian.git] / os_win32 / installer.nsi
1 ;
2 ; smartmontools install NSIS script
3 ;
4 ; Home page of code is: http://smartmontools.sourceforge.net
5 ;
6 ; Copyright (C) 2006-11 Christian Franke <smartmontools-support@lists.sourceforge.net>
7 ;
8 ; This program is free software; you can redistribute it and/or modify
9 ; it under the terms of the GNU General Public License as published by
10 ; the Free Software Foundation; either version 2, or (at your option)
11 ; any later version.
12 ;
13 ; You should have received a copy of the GNU General Public License
14 ; (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
15 ;
16 ; $Id: installer.nsi 3296 2011-03-16 22:17:51Z chrfranke $
17 ;
18
19
20 ;--------------------------------------------------------------------
21 ; Command line arguments:
22 ; makensis -DINPDIR=<input-dir> -DOUTFILE=<output-file> -DVERSTR=<version-string> installer.nsi
23
24 !ifndef INPDIR
25 !define INPDIR "."
26 !endif
27
28 !ifndef OUTFILE
29 !define OUTFILE "smartmontools.win32-setup.exe"
30 !endif
31
32 ;--------------------------------------------------------------------
33 ; General
34
35 Name "smartmontools"
36 OutFile "${OUTFILE}"
37
38 SetCompressor /solid lzma
39
40 XPStyle on
41 InstallColors /windows
42
43 InstallDir "$PROGRAMFILES\smartmontools"
44 InstallDirRegKey HKLM "Software\smartmontools" "Install_Dir"
45 Var UBCDDIR
46
47 LicenseData "${INPDIR}\doc\COPYING.txt"
48
49 ;--------------------------------------------------------------------
50 ; Pages
51
52 Page license
53 Page components
54 Page directory SkipProgPath "" ""
55 PageEx directory
56 PageCallbacks SkipUBCDPath "" ""
57 DirText "Setup will install the UBCD4Win plugin in the following folder."
58 DirVar $UBCDDIR
59 PageExEnd
60 Page instfiles
61
62 UninstPage uninstConfirm
63 UninstPage instfiles
64
65 InstType "Full"
66 InstType "Extract files only"
67 InstType "Drive menu"
68 InstType "UBCD4Win plugin"
69
70
71 ;--------------------------------------------------------------------
72 ; Sections
73
74 SectionGroup "!Program files"
75
76 Section "smartctl" SMARTCTL_SECTION
77
78 SectionIn 1 2
79
80 SetOutPath "$INSTDIR\bin"
81 File "${INPDIR}\bin\smartctl.exe"
82
83 SectionEnd
84
85 Section "smartd" SMARTD_SECTION
86
87 SectionIn 1 2
88
89 SetOutPath "$INSTDIR\bin"
90
91 ; Stop service ?
92 StrCpy $1 ""
93 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
94 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
95 StrCmp $0 "" nosrv
96 ExecWait "net stop smartd" $1
97 nosrv:
98 File "${INPDIR}\bin\smartd.exe"
99
100 IfFileExists "$INSTDIR\bin\smartd.conf" 0 +2
101 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Replace existing configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO +2
102 File "${INPDIR}\doc\smartd.conf"
103
104 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
105 File /nonfatal "${INPDIR}\bin\syslogevt.exe"
106
107 ; Restart service ?
108 StrCmp $1 "0" 0 +3
109 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Restart smartd service ?" IDYES 0 IDNO +2
110 ExecWait "net start smartd"
111
112 SectionEnd
113
114 Section "smartctl-nc (GSmartControl)" SMARTCTL_NC_SECTION
115
116 SectionIn 1 2
117
118 SetOutPath "$INSTDIR\bin"
119 File "${INPDIR}\bin\smartctl-nc.exe"
120
121 SectionEnd
122
123 Section "drivedb.h (Drive Database)" DRIVEDB_SECTION
124
125 SectionIn 1 2
126
127 SetOutPath "$INSTDIR\bin"
128 File "${INPDIR}\bin\drivedb.h"
129 File "${INPDIR}\bin\update-smart-drivedb.exe"
130
131 SectionEnd
132
133 SectionGroupEnd
134
135 Section "!Documentation" DOC_SECTION
136
137 SectionIn 1 2
138
139 SetOutPath "$INSTDIR\doc"
140 File "${INPDIR}\doc\AUTHORS.txt"
141 File "${INPDIR}\doc\CHANGELOG.txt"
142 File "${INPDIR}\doc\COPYING.txt"
143 File "${INPDIR}\doc\INSTALL.txt"
144 File "${INPDIR}\doc\NEWS.txt"
145 File "${INPDIR}\doc\README.txt"
146 File "${INPDIR}\doc\TODO.txt"
147 File "${INPDIR}\doc\WARNINGS.txt"
148 File "${INPDIR}\doc\checksums.txt"
149 File "${INPDIR}\doc\smartctl.8.html"
150 File "${INPDIR}\doc\smartctl.8.txt"
151 File "${INPDIR}\doc\smartd.8.html"
152 File "${INPDIR}\doc\smartd.8.txt"
153 File "${INPDIR}\doc\smartd.conf"
154 File "${INPDIR}\doc\smartd.conf.5.html"
155 File "${INPDIR}\doc\smartd.conf.5.txt"
156
157 SectionEnd
158
159 Section "Uninstaller" UNINST_SECTION
160
161 SectionIn 1
162 AddSize 35
163
164 CreateDirectory "$INSTDIR"
165
166 ; Save installation location
167 WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR"
168
169 ; Write uninstall keys and program
170 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools"
171 !ifdef VERSTR
172 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayVersion" "${VERSTR}"
173 !endif
174 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools"
175 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"'
176 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://smartmontools.sourceforge.net/"
177 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://smartmontools.sourceforge.net/"
178 ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=64297"
179 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools-win32.dyndns.org/"
180 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1
181 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1
182 WriteUninstaller "uninst-smartmontools.exe"
183
184 SectionEnd
185
186 Section "Start Menu Shortcuts" MENU_SECTION
187
188 SectionIn 1
189
190 CreateDirectory "$SMPROGRAMS\smartmontools"
191
192 ; smartctl
193 IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl
194 SetOutPath "$INSTDIR\bin"
195 DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
196 Push "$INSTDIR\bin\smartctl-run.bat"
197 Call CreateSmartctlBat
198 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
199 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl (CMD).lnk" "cmd.exe" "/k smartctl-run.bat"
200 CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples"
201 FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w"
202 FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n"
203 FileClose $0
204 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk" "$INSTDIR\bin\smartctl-run.bat" "-a sda"
205 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\smartctl-run.bat" "-i sda"
206 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk" "$INSTDIR\bin\smartctl-run.bat" "-A sda"
207 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\smartctl-run.bat" "-c sda"
208 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\smartctl-run.bat" "-H sda"
209 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l error sda"
210 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l selftest sda"
211 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t long sda"
212 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t offline sda"
213 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t short sda"
214 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\smartctl-run.bat" "-X sda"
215 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s off sda"
216 CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s on sda"
217 noctl:
218
219 ; smartd
220 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod
221 SetOutPath "$INSTDIR\bin"
222 DetailPrint "Create file: $INSTDIR\bin\smartd-run.bat"
223 FileOpen $0 "$INSTDIR\bin\smartd-run.bat" "w"
224 FileWrite $0 '@echo off$\r$\necho smartd %1 %2 %3 %4 %5$\r$\n"$INSTDIR\bin\smartd" %1 %2 %3 %4 %5$\r$\npause$\r$\n'
225 FileClose $0
226 CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples"
227 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\smartd-run.bat" "-l local0"
228 IfFileExists "$WINDIR\system32\cmd.exe" 0 +2
229 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\smartd-run.bat" ""
230 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\smartd-run.bat" "stop"
231 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\smartd-run.bat" "-q onecheck"
232 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\smartd-run.bat" "-d"
233 IfFileExists "$WINDIR\notepad.exe" 0 nopad
234 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Edit smartd.conf.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.conf"
235 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\View smartd.log.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.log"
236 nopad:
237
238 ; smartd service (not on 9x/ME)
239 IfFileExists "$WINDIR\system32\cmd.exe" 0 nosvc
240 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install"
241 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0 -i 600"
242 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0"
243 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\smartd-run.bat" "remove"
244 DetailPrint "Create file: $INSTDIR\bin\net-run.bat"
245 FileOpen $0 "$INSTDIR\bin\net-run.bat" "w"
246 FileWrite $0 "@echo off$\r$\necho net %1 %2 %3 %4 %5$\r$\nnet %1 %2 %3 %4 %5$\r$\npause$\r$\n"
247 FileClose $0
248 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\net-run.bat" "start smartd"
249 CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\net-run.bat" "stop smartd"
250 nosvc:
251 nod:
252
253 ; Documentation
254 IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc
255 SetOutPath "$INSTDIR\doc"
256 CreateDirectory "$SMPROGRAMS\smartmontools\Documentation"
257 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html"
258 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html"
259 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html"
260 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt"
261 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt"
262 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt"
263 IfFileExists "$WINDIR\notepad.exe" 0 +5
264 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$WINDIR\notepad.exe" "$INSTDIR\doc\smartd.conf"
265 IfFileExists "$INSTDIR\bin\drivedb.h" 0 +3
266 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb.h (view).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb.h"
267 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb-add.h (create, edit).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb-add.h"
268 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\AUTHORS.lnk" "$INSTDIR\doc\AUTHORS.txt"
269 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\CHANGELOG.lnk" "$INSTDIR\doc\CHANGELOG.txt"
270 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt"
271 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\INSTALL.lnk" "$INSTDIR\doc\INSTALL.txt"
272 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt"
273 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\README.lnk" "$INSTDIR\doc\README.txt"
274 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\TODO.lnk" "$INSTDIR\doc\TODO.txt"
275 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\WARNINGS.lnk" "$INSTDIR\doc\WARNINGS.txt"
276 CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools-win32.dyndns.org/smartmontools/"
277 nodoc:
278
279 ; Homepage
280 CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/"
281
282 ; drivedb.h update
283 IfFileExists "$INSTDIR\bin\update-smart-drivedb.exe" 0 +2
284 CreateShortCut "$SMPROGRAMS\smartmontools\drivedb.h update.lnk" "$INSTDIR\bin\update-smart-drivedb.exe"
285
286 ; Uninstall
287 IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 +2
288 CreateShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe"
289
290 SectionEnd
291
292 Section "Add install dir to PATH" PATH_SECTION
293
294 SectionIn 1
295
296 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
297 Push "$INSTDIR\bin"
298 Call AddToPath
299
300 SectionEnd
301
302 SectionGroup "Add smartctl to drive menu"
303
304 !macro DriveMenuRemove
305 DetailPrint "Remove drive menu entries"
306 DeleteRegKey HKCR "Drive\shell\smartctl0"
307 DeleteRegKey HKCR "Drive\shell\smartctl1"
308 DeleteRegKey HKCR "Drive\shell\smartctl2"
309 DeleteRegKey HKCR "Drive\shell\smartctl3"
310 DeleteRegKey HKCR "Drive\shell\smartctl4"
311 DeleteRegKey HKCR "Drive\shell\smartctl5"
312 !macroend
313
314 Section "Remove existing entries first"
315 SectionIn 3
316 !insertmacro DriveMenuRemove
317 SectionEnd
318
319 !macro DriveSection id name args
320 Section 'smartctl ${args} ...' DRIVE_${id}_SECTION
321 SectionIn 3
322 Call CheckSmartctlBat
323 DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...'
324 WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}"
325 WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\smartctl-run.bat" ${args} %L'
326 SectionEnd
327 !macroend
328
329 !insertmacro DriveSection 0 "SMART all info" "-a"
330 !insertmacro DriveSection 1 "SMART status" "-Hc"
331 !insertmacro DriveSection 2 "SMART attributes" "-A"
332 !insertmacro DriveSection 3 "SMART short selftest" "-t short"
333 !insertmacro DriveSection 4 "SMART long selftest" "-t long"
334 !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"'
335
336 SectionGroupEnd
337
338 Section "UBCD4Win Plugin" UBCD_SECTION
339
340 SectionIn 4
341
342 SetOutPath "$UBCDDIR"
343 DetailPrint "Create file: smartmontools.inf"
344 FileOpen $0 "$UBCDDIR\smartmontools.inf" "w"
345 FileWrite $0 '; smartmontools.inf$\r$\n; PE Builder v3 plug-in INF file$\r$\n'
346 FileWrite $0 '; Created by smartmontools installer$\r$\n'
347 FileWrite $0 '; http://smartmontools.sourceforge.net/$\r$\n$\r$\n'
348 FileWrite $0 '[Version]$\r$\nSignature= "$$Windows NT$$"$\r$\n$\r$\n'
349 FileWrite $0 '[PEBuilder]$\r$\nName="Disk -Diagnostic: smartmontools"$\r$\n'
350 FileWrite $0 'Enable=1$\r$\nHelp="files\smartctl.8.html"$\r$\n$\r$\n'
351 FileWrite $0 '[WinntDirectories]$\r$\na=Programs\smartmontools,2$\r$\n$\r$\n'
352 FileWrite $0 '[SourceDisksFolders]$\r$\nfiles=a,,1$\r$\n$\r$\n'
353 FileWrite $0 '[Append]$\r$\nnu2menu.xml, smartmontools_nu2menu.xml$\r$\n'
354 FileClose $0
355
356 DetailPrint "Create file: smartmontools_nu2menu.xml"
357 FileOpen $0 "$UBCDDIR\smartmontools_nu2menu.xml" "w"
358 FileWrite $0 '<!-- Nu2Menu entry for smartmontools -->$\r$\n<NU2MENU>$\r$\n'
359 FileWrite $0 '$\t<MENU ID="Programs">$\r$\n$\t$\t<MITEM TYPE="POPUP" MENUID="Disk Tools">'
360 FileWrite $0 'Disk Tools</MITEM>$\r$\n$\t</MENU>$\r$\n$\t<MENU ID="Disk Tools">$\r$\n'
361 FileWrite $0 '$\t$\t<MITEM TYPE="POPUP" MENUID="Diagnostic">Diagnostic</MITEM>$\r$\n$\t</MENU>'
362 FileWrite $0 '$\r$\n$\t<MENU ID="Diagnostic">$\r$\n$\t$\t<MITEM TYPE="ITEM" DISABLED="'
363 FileWrite $0 '@Not(@FileExists(@GetProgramDrive()\Programs\smartmontools\smartctl.exe))" '
364 FileWrite $0 'CMD="RUN" FUNC="cmd.exe /k cd /d @GetProgramDrive()\Programs\smartmontools&'
365 FileWrite $0 'set PATH=@GetProgramDrive()\Programs\smartmontools;%PATH%&smartctl-run.bat ">'
366 FileWrite $0 'smartctl</MITEM>$\r$\n$\t</MENU>$\r$\n</NU2MENU>$\r$\n'
367 FileClose $0
368
369 SetOutPath "$UBCDDIR\files"
370 DetailPrint "Create file: smartctl-run.bat"
371 Push "$UBCDDIR\files\smartctl-run.bat"
372 Call CreateSmartctlBat
373 File "${INPDIR}\bin\smartctl.exe"
374 File "${INPDIR}\bin\smartd.exe"
375 File "${INPDIR}\doc\smartctl.8.html"
376 File "${INPDIR}\doc\smartctl.8.txt"
377 File "${INPDIR}\doc\smartd.8.html"
378 File "${INPDIR}\doc\smartd.8.txt"
379 File "${INPDIR}\doc\smartd.conf"
380
381 SectionEnd
382
383
384 ;--------------------------------------------------------------------
385
386 Section "Uninstall"
387
388 ; Stop & remove service
389 IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv
390 ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath"
391 StrCmp $0 "" nosrv
392 ExecWait "net stop smartd"
393 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Remove smartd service ?" IDYES 0 IDNO nosrv
394 ExecWait "$INSTDIR\bin\smartd.exe remove"
395 nosrv:
396
397 ; Remove installer registry keys
398 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools"
399 DeleteRegKey HKLM "Software\smartmontools"
400
401 ; Remove conf file ?
402 IfFileExists "$INSTDIR\bin\smartd.conf" 0 noconf
403 ; Assume unchanged if timestamp is equal to sample file
404 GetFileTime "$INSTDIR\bin\smartd.conf" $0 $1
405 GetFileTime "$INSTDIR\doc\smartd.conf" $2 $3
406 StrCmp "$0:$1" "$2:$3" +2 0
407 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO noconf
408 Delete "$INSTDIR\bin\smartd.conf"
409 noconf:
410
411 ; Remove log file ?
412 IfFileExists "$INSTDIR\bin\smartd.log" 0 +3
413 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete log file$\n$INSTDIR\bin\smartd.log ?" IDYES 0 IDNO +2
414 Delete "$INSTDIR\bin\smartd.log"
415
416 ; Remove drivedb-add file ?
417 IfFileExists "$INSTDIR\bin\drivedb-add.h" 0 +3
418 MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete local drive database file$\n$INSTDIR\bin\drivedb-add.h ?" IDYES 0 IDNO +2
419 Delete "$INSTDIR\bin\drivedb-add.h"
420
421 ; Remove files
422 Delete "$INSTDIR\bin\smartctl.exe"
423 Delete "$INSTDIR\bin\smartctl-nc.exe"
424 Delete "$INSTDIR\bin\smartd.exe"
425 Delete "$INSTDIR\bin\syslogevt.exe"
426 Delete "$INSTDIR\bin\drivedb.h"
427 Delete "$INSTDIR\bin\drivedb.h.error"
428 Delete "$INSTDIR\bin\drivedb.h.lastcheck"
429 Delete "$INSTDIR\bin\drivedb.h.old"
430 Delete "$INSTDIR\bin\update-smart-drivedb.exe"
431 Delete "$INSTDIR\bin\smartctl-run.bat"
432 Delete "$INSTDIR\bin\smartd-run.bat"
433 Delete "$INSTDIR\bin\net-run.bat"
434 Delete "$INSTDIR\doc\AUTHORS.txt"
435 Delete "$INSTDIR\doc\CHANGELOG.txt"
436 Delete "$INSTDIR\doc\COPYING.txt"
437 Delete "$INSTDIR\doc\INSTALL.txt"
438 Delete "$INSTDIR\doc\NEWS.txt"
439 Delete "$INSTDIR\doc\README.txt"
440 Delete "$INSTDIR\doc\TODO.txt"
441 Delete "$INSTDIR\doc\WARNINGS.txt"
442 Delete "$INSTDIR\doc\checksums.txt"
443 Delete "$INSTDIR\doc\smartctl.8.html"
444 Delete "$INSTDIR\doc\smartctl.8.txt"
445 Delete "$INSTDIR\doc\smartd.8.html"
446 Delete "$INSTDIR\doc\smartd.8.txt"
447 Delete "$INSTDIR\doc\smartd.conf"
448 Delete "$INSTDIR\doc\smartd.conf.5.html"
449 Delete "$INSTDIR\doc\smartd.conf.5.txt"
450 Delete "$INSTDIR\uninst-smartmontools.exe"
451
452 ; Remove shortcuts
453 Delete "$SMPROGRAMS\smartmontools\*.*"
454 Delete "$SMPROGRAMS\smartmontools\Documentation\*.*"
455 Delete "$SMPROGRAMS\smartmontools\smartctl Examples\*.*"
456 Delete "$SMPROGRAMS\smartmontools\smartd Examples\*.*"
457
458 ; Remove folders
459 RMDir "$SMPROGRAMS\smartmontools\Documentation"
460 RMDir "$SMPROGRAMS\smartmontools\smartctl Examples"
461 RMDir "$SMPROGRAMS\smartmontools\smartd Examples"
462 RMDir "$SMPROGRAMS\smartmontools"
463 RMDir "$INSTDIR\bin"
464 RMDir "$INSTDIR\doc"
465 RMDir "$INSTDIR"
466
467 ; Remove install dir from PATH
468 IfFileExists "$WINDIR\system32\cmd.exe" 0 +3
469 Push "$INSTDIR\bin"
470 Call un.RemoveFromPath
471
472 ; Remove drive menu registry entries
473 !insertmacro DriveMenuRemove
474
475 ; Check for still existing entries
476 IfFileExists "$INSTDIR\bin\smartd.exe" 0 +3
477 MessageBox MB_OK|MB_ICONEXCLAMATION "$INSTDIR\bin\smartd.exe could not be removed.$\nsmartd is possibly still running."
478 Goto +3
479 IfFileExists "$INSTDIR" 0 +2
480 MessageBox MB_OK "Note: $INSTDIR could not be removed."
481
482 IfFileExists "$SMPROGRAMS\smartmontools" 0 +2
483 MessageBox MB_OK "Note: $SMPROGRAMS\smartmontools could not be removed."
484
485 SectionEnd
486
487 ;--------------------------------------------------------------------
488 ; Functions
489
490 Function .onInit
491
492 ; Get UBCD4Win install location
493 ReadRegStr $0 HKLM "Software\UBCD4Win" "InstallPath"
494 StrCmp $0 "" 0 +2
495 StrCpy $0 "C:\UBCD4Win"
496 StrCpy $UBCDDIR "$0\plugin\Disk\Diagnostic\smartmontools"
497
498 ; Hide "Add install dir to PATH" on 9x/ME
499 IfFileExists "$WINDIR\system32\cmd.exe" +2 0
500 SectionSetText ${PATH_SECTION} ""
501
502 FunctionEnd
503
504 ; Directory page callbacks
505
506 !macro CheckSection section
507 SectionGetFlags ${section} $0
508 IntOp $0 $0 & 1
509 IntCmp $0 1 done
510 !macroend
511
512 Function SkipProgPath
513 !insertmacro CheckSection ${SMARTCTL_SECTION}
514 !insertmacro CheckSection ${SMARTCTL_NC_SECTION}
515 !insertmacro CheckSection ${SMARTD_SECTION}
516 !insertmacro CheckSection ${DRIVEDB_SECTION}
517 !insertmacro CheckSection ${DOC_SECTION}
518 !insertmacro CheckSection ${MENU_SECTION}
519 !insertmacro CheckSection ${PATH_SECTION}
520 !insertmacro CheckSection ${DRIVE_0_SECTION}
521 !insertmacro CheckSection ${DRIVE_1_SECTION}
522 !insertmacro CheckSection ${DRIVE_2_SECTION}
523 !insertmacro CheckSection ${DRIVE_3_SECTION}
524 !insertmacro CheckSection ${DRIVE_4_SECTION}
525 !insertmacro CheckSection ${DRIVE_5_SECTION}
526 Abort
527 done:
528 FunctionEnd
529
530 Function SkipUBCDPath
531 !insertmacro CheckSection ${UBCD_SECTION}
532 Abort
533 done:
534 FunctionEnd
535
536
537 ; Create smartctl-run.bat
538
539 Function CreateSmartctlBat
540 Exch $0
541 FileOpen $0 $0 "w"
542 FileWrite $0 '@echo off$\r$\nif not "%1" == "" goto run$\r$\n'
543 FileWrite $0 'echo Examples (for first drive):$\r$\n'
544 FileWrite $0 'echo smartctl -i sda Show identify information$\r$\n'
545 FileWrite $0 'echo smartctl -H sda Show SMART health status$\r$\n'
546 FileWrite $0 'echo smartctl -c sda Show SMART capabilities$\r$\n'
547 FileWrite $0 'echo smartctl -A sda Show SMART attributes$\r$\n'
548 FileWrite $0 'echo smartctl -l error sda Show error log$\r$\n'
549 FileWrite $0 'echo smartctl -l selftest sda Show self-test log$\r$\n'
550 FileWrite $0 'echo smartctl -a sda Show all of the above$\r$\n'
551 FileWrite $0 'echo smartctl -t short sda Start short self test$\r$\n'
552 FileWrite $0 'echo smartctl -t long sda Start long self test$\r$\n'
553 FileWrite $0 'echo Use "sdb", "sdc", ... for second, third, ... drive.$\r$\n'
554 FileWrite $0 'echo See man page (smartctl.8.*) for further info.$\r$\n'
555 FileWrite $0 'goto end$\r$\n:run$\r$\n'
556 FileWrite $0 'echo smartctl %1 %2 %3 %4 %5$\r$\n'
557 FileWrite $0 '"$INSTDIR\bin\smartctl" %1 %2 %3 %4 %5$\r$\n'
558 FileWrite $0 'pause$\r$\n:end$\r$\n'
559 FileClose $0
560 Pop $0
561 FunctionEnd
562
563 ; Create smartctl-run.bat if missing
564
565 Function CheckSmartctlBat
566 IfFileExists "$INSTDIR\bin\smartctl-run.bat" done 0
567 SetOutPath "$INSTDIR\bin"
568 DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat"
569 Push "$INSTDIR\bin\smartctl-run.bat"
570 Call CreateSmartctlBat
571 done:
572 FunctionEnd
573
574
575 ;--------------------------------------------------------------------
576 ; Path functions
577 ;
578 ; Based on example from:
579 ; http://nsis.sourceforge.net/Path_Manipulation
580 ;
581
582
583 !include "WinMessages.nsh"
584
585 ; Registry Entry for environment (NT4,2000,XP)
586 ; All users:
587 ;!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
588 ; Current user only:
589 !define Environ 'HKCU "Environment"'
590
591
592 ; AddToPath - Appends dir to PATH
593 ; (does not work on Win9x/ME)
594 ;
595 ; Usage:
596 ; Push "dir"
597 ; Call AddToPath
598
599 Function AddToPath
600 Exch $0
601 Push $1
602 Push $2
603 Push $3
604
605 ReadRegStr $1 ${Environ} "PATH"
606 Push "$1;"
607 Push "$0;"
608 Call StrStr
609 Pop $2
610 StrCmp $2 "" 0 done
611 Push "$1;"
612 Push "$0\;"
613 Call StrStr
614 Pop $2
615 StrCmp $2 "" 0 done
616
617 DetailPrint "Add to PATH: $0"
618 StrCpy $2 $1 1 -1
619 StrCmp $2 ";" 0 +2
620 StrCpy $1 $1 -1 ; remove trailing ';'
621 StrCmp $1 "" +2 ; no leading ';'
622 StrCpy $0 "$1;$0"
623 WriteRegExpandStr ${Environ} "PATH" $0
624 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
625
626 done:
627 Pop $3
628 Pop $2
629 Pop $1
630 Pop $0
631 FunctionEnd
632
633
634 ; RemoveFromPath - Removes dir from PATH
635 ;
636 ; Usage:
637 ; Push "dir"
638 ; Call RemoveFromPath
639
640 Function un.RemoveFromPath
641 Exch $0
642 Push $1
643 Push $2
644 Push $3
645 Push $4
646 Push $5
647 Push $6
648
649 ReadRegStr $1 ${Environ} "PATH"
650 StrCpy $5 $1 1 -1
651 StrCmp $5 ";" +2
652 StrCpy $1 "$1;" ; ensure trailing ';'
653 Push $1
654 Push "$0;"
655 Call un.StrStr
656 Pop $2 ; pos of our dir
657 StrCmp $2 "" done
658
659 DetailPrint "Remove from PATH: $0"
660 StrLen $3 "$0;"
661 StrLen $4 $2
662 StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove
663 StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
664 StrCpy $3 "$5$6"
665 StrCpy $5 $3 1 -1
666 StrCmp $5 ";" 0 +2
667 StrCpy $3 $3 -1 ; remove trailing ';'
668 WriteRegExpandStr ${Environ} "PATH" $3
669 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
670
671 done:
672 Pop $6
673 Pop $5
674 Pop $4
675 Pop $3
676 Pop $2
677 Pop $1
678 Pop $0
679 FunctionEnd
680
681
682 ; StrStr - find substring in a string
683 ;
684 ; Usage:
685 ; Push "this is some string"
686 ; Push "some"
687 ; Call StrStr
688 ; Pop $0 ; "some string"
689
690 !macro StrStr un
691 Function ${un}StrStr
692 Exch $R1 ; $R1=substring, stack=[old$R1,string,...]
693 Exch ; stack=[string,old$R1,...]
694 Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...]
695 Push $R3
696 Push $R4
697 Push $R5
698 StrLen $R3 $R1
699 StrCpy $R4 0
700 ; $R1=substring, $R2=string, $R3=strlen(substring)
701 ; $R4=count, $R5=tmp
702 loop:
703 StrCpy $R5 $R2 $R3 $R4
704 StrCmp $R5 $R1 done
705 StrCmp $R5 "" done
706 IntOp $R4 $R4 + 1
707 Goto loop
708 done:
709 StrCpy $R1 $R2 "" $R4
710 Pop $R5
711 Pop $R4
712 Pop $R3
713 Pop $R2
714 Exch $R1 ; $R1=old$R1, stack=[result,...]
715 FunctionEnd
716 !macroend
717 !insertmacro StrStr ""
718 !insertmacro StrStr "un."