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