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