[wpkg-users] Determine profile based on hardware quirks?

Stefan Pendl stefan.pendl.71 at gmail.com
Fri Jan 16 00:35:00 CET 2015


Am 15.01.2015 um 17:17 schrieb Marco Gaiarin:
> To be explicit: i'm preparing a set of recipe for SSD disks, with the
> literature stuff: disable search, defrag, ...
>
>
> There's some way to:
>
> 1) determine automagically if a windows box have an ssd disk
>
> 2) put the box on a profile based on that info.
>
>
> Thanks. ;)
>

I do this with SMARTmontools from 
http://sourceforge.net/projects/smartmontools/

%WPKG_ROOT%\tools\IsSystemSSD.cmd

'---code start (watch for line wraps)

@rem
@echo off

rem --- script to check if the first disk is a SSD
rem --- returns zero for no SSD, one otherwise

set bin_dir="%ProgramFiles(x86)%\smartmontools\bin"
if not exist %bin_dir% set bin_dir="%ProgramFiles%\smartmontools\bin"
if not exist %bin_dir% exit /b 1

cd /d %bin_dir%

set IsSSD=0

for /F "tokens=3,4,5" %%R in ( 'smartctl.exe -i /dev/sda' ) do if "%%R %%S %%T" == "Solid State Device" set IsSSD=1

for /F "tokens=3,4,5" %%R in ( 'smartctl.exe -i /dev/sda -d ata' ) do if "%%R %%S %%T" == "Solid State Device" set IsSSD=1

for /F "tokens=3,4,5" %%R in ( 'smartctl.exe -i /dev/sda -d sat' ) do if "%%R %%S %%T" == "Solid State Device" set IsSSD=1

exit /b %IsSSD%

'---code end


Condition for checking
'---code start (watch for line wraps)

<condition>
	<check type="execute" condition="exitcodeequalto" path="%WPKG_ROOT%\tools\IsSystemSSD.cmd" value="0" />
</condition>

'---code end

SmartMonTools package
'---code start (watch for line wraps)

<package id="SmartMonTools"
		name="S.M.A.R.T. Monitoring Tools"
		revision="%PKG_VERSION%"
		reboot="false"
		priority="10">

	<variable name="PKG_VERSION"        value="6.1-2" />
	<variable name="PKG_SOURCE"         value="%SOFTWARE%\SMART Monitoring Tools\smartmontools-%PKG_VERSION%.win32-setup.exe"/>
	<variable name="PKG_DESTINATION"    value="%ProgramFiles%\smartmontools"      architecture="x86"/>
	<variable name="PKG_DESTINATION"    value="%ProgramFiles(x86)%\smartmontools" architecture="x64"/>
	<variable name="PKG_INSTALL_SWITCH" value="/S /D=%PKG_DESTINATION%"/>
	<variable name="PKG_REMOVE_SWITCH"  value="/S _?=%PKG_DESTINATION%"/>

	<check type="uninstall" condition="versiongreaterorequal" path="smartmontools" value="6.1 2013-03-16 r3800 (sf-%PKG_VERSION%)" />

	<install cmd='"%PKG_SOURCE%" %PKG_INSTALL_SWITCH%' />

	<upgrade include="install" />
	<downgrade include="install" />

	<remove cmd='"%PKG_DESTINATION%\uninst-smartmontools.exe" %PKG_REMOVE_SWITCH%' />
	<remove cmd='%ComSpec% /C ping localhost -n 11 >nul 2>nul' >
		<exit code="any" />
	</remove>
	<remove cmd='%ComSpec% /C if exist "%PKG_DESTINATION%\uninst-smartmontools.exe" del "%PKG_DESTINATION%\uninst-smartmontools.exe"' />
	<remove cmd='%ComSpec% /C if exist "%PKG_DESTINATION%" rmdir "%PKG_DESTINATION%"' />
</package>

'---code end


--
Stefan P.

Top-posting:
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?




More information about the wpkg-users mailing list