Skip to content

Commit

Permalink
Bulk updates for upcomming v6.5
Browse files Browse the repository at this point in the history
  • Loading branch information
deajan committed Nov 10, 2016
1 parent f26e3d7 commit d4c2a0e
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 278 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.TXT
Expand Up @@ -14,17 +14,20 @@ Changelog
! SERVICE NOT RUNNING AFTER INSTALL
- Brand new and shiny python GUI for smartd.conf
- New GUI to configure erroraction_config.cmd parameters
- New commandline options
- Greatly simplified commandline options
- Custom smartd.conf file can now be distributed directly with the installer executuable (see README for more info)
- Custom erroraction_config.cmd file can now be distributed directly with the installer executable (also see README for more info)
- Previous smartd.conf files are now kept
- Updated upstream release to v6.5-1
- Installer now uses 64 bits binaries on 64 bit systems (following upstream)
- Updated mailsend to v1.19
- Improved erroraction.cmd script to detect privileges, and autodetect drives
- Fixed scheduled tests can be disabled in installer
- Fixed scheduled_send.cmd didn't get deleted on uninstall
- Removed a lot of the installer logic from Inno Setup
- Removed old SendEmail support
- Removed legacy smart service uninstall from v5.x series
- Removed russian translation (outdated and not maintained, translators welcome)
- Re-enconded iss files without UTF BOM (issues with Inno Script Studio 5.5.9)


Expand Down
67 changes: 36 additions & 31 deletions README.md
@@ -1,17 +1,18 @@
## Smartmontools for Windows Package
(C) 2012-2016 Orsiris de Jong - http://www.netpower.fr

Smartmontools For Windows is an alternate package for smartmontools by Bruce Allen and Christian Franke, and has been created to quickly install smartmontools as service,
support mail or local alerts, and preconfigure smart monitor options.
Smartmontools For Windows is an alternate package for smartmontools by Bruce Allen and Christian Franke, that has been created to smoothly install smartmontools as service,
support out of the box mail or local alerts, and configure smart daemon options with a graphical user interface.
Installation can be run silently with command line parameters for massive deployments, or with a graphical user interface.

Configuration files are automatically generated (but you can still enjoy manual editing of course).
A service called "SmartD" is created and launched at system startups. This service will enumerate hard disks smartmontools can monitor and send an email and/or show a local message in case of errors.
A file called smart.log is created on error, including all smart information, and sent by mail. A error action log is created under erroraction.log.
A service called "smartd" is created and launched at system startups. This service will enumerate hard disks smartmontools can monitor and send an email and/or show a local message in case of errors.
Everytime smartd detects an issue, the current states of the drives are written to smart.log and an alert is triggered.
When mail alert is triggered, all actions regarding that alerts are logged to erroraction.log

Optionally, an initial smart.log file is kept on the disk, in the case you want to keep initial smart infos for warranty issues.
On install, the current states of all drives smartd can detect are written to smartmontools-install-(version).log for warranty issues.

This software and the software it installs are under GPL licence. No responsibility will be taken for any problems or malfunctions that may occur while using this software.
No responsibility will be taken for any problems or malfunctions that may occur while using this software.

Anyway,feel free to send a mail to ozy [at] netpower.fr for limited support on my free time.

Expand Down Expand Up @@ -43,35 +44,39 @@ Compilation works with Inno Setup & Inno Preprocessor 5.5+.
You'll need to download all the software mentionned above and extract them to the corresponding directories listed in main iss file.
Python executables are frozen versions with py2exe. Just rename the dist directory provided by the setup scripts and put them in the corresponding directories.

## Command line parameters

smartmontools-win-6.5.exe [-c c:\path\to\custom\smartd.conf] [-f source@mail.tld -t destination@mail.tld -s smtp.server.tld] [--port=25] [-u smtpuser] [-p smtppassword] [--security=(none|tls|ssl)]] [--localmessages=(yes|no)] [--warningmessage="Your custom alert message"] [--compresslogs=(yes|no)] [--keepfirstlog=(yes|no)] [--sendtestmessage=(yes|no)] [/silent]

-c Provide a custom smartd.conf for mass installation
-f Email address your alert mail will come from
-t destination email address for your alert
-s your smtp server
--port=your smtp server port (defaults to 25)
-u your smtp server username (not mandatory)
-p your smtp server password (not mandatory)
--tls (no|auto|yes) Use of TLS sécurity, is no if not defined
--localmessages=(no|yes) Display local warning messages on errors, is set to no if not defined
--warningmessage="Your custom warning message", if not set, the default warning message will be used
--compresslogs=(yes|no) is activated if not defined
--keepfirstlog=(yes|no) is activated if not defined
--sendtestmessage=(yes|no) is activated if not defined
/silent or /verysilent are silent switches. Please be aware these are the only switches using a slash, as they are Inno Setup internal logic switches.
## Useful command line parameters

See examples below
smartmontools-win-6.5.exe [OPTIONS]

## Examples
[OPTIONS]

/COMPONENTS="comma separated list of component names"

This setting overrides the default selection.

A basic installation script:
Valid components are:
core : Basic install, cannot be unselected
core\service : Install smartd service
core\service\gui Graphical user interface for smartd and alerts
core\service\mailsupport On alerts send an email
core\service\localsupport On alerts show messages on screen
core\scheduledtestalerts Trigger a test alert every month
fixbadsecttools Fix bad sector script
regext Register SMART right click actions on drives
updatedb Update drive database right after installation
authorlinks Include links to the authors websites

smartmontools-win-6.5.exe -f sourcemail@example.tld -t destination@example.tld -s smtp.of.your.isp.com /silent
/SILENT Installs smartmontools-win silently, without showing the configuration GUI.

This line would silently install smartmontools mail alerts, autodetection of hdds, using all monitor parameters, and schedule a short selftest every day at 08AM and a long selftest every friday at 12AM.
/HELP Shows all possible commandline switches

An other example would be that would use tls for mails, authentificate on your ISP's SMTP server, never ignore temperature changes, show local warning messages, disables short tests and schedules a long selftest every tuesday and sunday at 02PM for the drives /dev/pd0 and /dev/csmi0,1 would look like
You may want to preconfigure smartd settings or alert setting when making an unattended installation.
Putting a preconfigured smartd.conf file along with the setup exe will load it automatically.
Putting a preconfigured erroraction_config.cmd file along with the setup exe will automatically configure alert options.
Those files can be found at https://github.com/deajan/smartmontools-win/unattended

See examples below

## Examples

smartmontools-win-6.5.exe -c c:\smartd.conf -f sourcemail@example.tld -t destination@example.tld -s smtp.of.your.isp.com --port 587 -u username@smtp.server.tld -p pA55W0RD --tls=yes --localmessages=yes /silent
smartmontools-win-6.5-1.exe /COMPONENTS="core\service,core\service\gui,core\service\mailsupport,updatedb" /SILENT
82 changes: 58 additions & 24 deletions erroraction.cmd
@@ -1,9 +1,17 @@
:: Smartmontools for Windows package v6.5 erroraction.cmd
:: Smartmontools for Windows package v6.5 erroraction.cmd 2016111003
:: http://www.netpower.fr
:: (L) 2012-2016 by Orsiris de Jong

:: Config can be changed in erroraction_config.cmd

:: CHANGELOG:
:: 10 Nov 2016:
:: - Added default mailer
:: - Added admin privileges check
:: - CreateSmartOutput now uses drive definitions found in smartd.conf in order to get drive status
:: - Added GetEnvironment function to check for executables before launching
:: - Better test message

@echo off
setlocal enabledelayedexpansion

Expand All @@ -17,8 +25,11 @@ call "%curdir%\erroraction_config.cmd"

:: Load autgenerated configuration
call "erroraction_config.cmd"
set DEBUG=no
set DEBUG=yes
set SCRIPT_ERROR=0

set ERROR_LOG_FILE=%curdir%\erroraction.log
set SMART_LOG_FILE=%curdir%\smart.log
:: ---------------------------- Main -----------------------------
:: This variable contains a newline char... Please leave the empty 2 lines below as they're needed for the "newline" symbol.
:: The newline symbol will be used to parse a space separated list of devices (%DEVICE_LIST%) with the for command.
Expand All @@ -29,6 +40,10 @@ set newline=^
IF "%1"=="--dryrun" ( set DRY=1 ) ELSE ( set DRY=0 )
IF "%1"=="--test" ( call:Tests ) ELSE ( set TEST=0 )


:: GetEnvironment is the only function that triggers premature end of the script as other failures might not interrupt processing
call:GetEnvironment
IF "!SCRIPT_ERROR!"=="1" GOTO END
call:GetComputerName
call:CreateSmartOutput
call:Mailer
Expand All @@ -43,47 +58,64 @@ GOTO:EOF

:Tests
set TEST=1
SC QUERY smartd | FINDSTR "RUNNING" > nul
SC QUERY smartd | FINDSTR "RUNNING" > nul 2> nul
IF "%ERRORLEVEL%"=="0" (
set SERVICE_RUNS=1
set WARNING_MESSAGE=Smartmontools for Windows test: Service runinng
set WARNING_MESSAGE=Smartmontools for Windows test: Service smartd is runinng
) ELSE (
set SERVICE_RUNS=0
set WARNING_MESSAGE=Smartmontools for Windows test: Service not running
set WARNING_MESSAGE=Alert: Smartmontools for Windows test: Service smartd is not running
)
GOTO:EOF

:GetEnvironment

:: Check for PC privileges :)
net session >nul 2>&1
IF NOT %ERRORLEVEL%==0 (
call:Log "PC checked for insufficient privileges"
SET SCRIPT_ERROR=1
)
dir "%curdir%\smartd.conf" > nul 2> nul
IF NOT %ERRORLEVEL%==0 (
call:Log "Missing smartd.conf file"
SET SCRIPT_ERROR=1
)
dir "%curdir%\smartctl.exe" > nul 2> nul
IF NOT %ERRORLEVEL%==0 (
call:Log "Missing smartctl.exe file"
SET SCRIPT_ERROR=1
)
GOTO:EOF

:CheckMailValues
echo "%SOURCE_MAIL%" | findstr /I "@" > nul
IF %ERRORLEVEL%==1 (
call:Log "Source mail not set"
GOTO End
GOTO END
)
echo "%DESTINATION_MAIL%" | findstr /I "@" > nul
IF %ERRORLEVEL%==1 (
call:Log "Destination Mail not Set"
GOTO End
GOTO END
)
IF "%SUBJECT%"=="" (
call:Log "Mail subject not set"
GOTO End
GOTO END
)
echo "%SMTP_SERVER%" | findstr /I "." > nul
IF %ERRORLEVEL%==1 (
call:Log "Smtp sever not set"
GOTO End
GOTO END
)
call:Log "Configuration file check success."
GOTO:EOF

:CreateSmartOutput
echo ------------------------------------------------------------------------------------------------- %DATE:~0,2%-%DATE:~3,2%-%DATE:~6,4% %TIME:~0,2%H%TIME:~3,2%m%TIME:~6,2%s >> "%SMART_LOG_FILE%"
IF "%DEVICE_LIST%"=="DEVICESCAN" (
for /F "delims= " %%i in ('"%PROGRAM_PATH%\smartctl" --scan') do "%PROGRAM_PATH%\smartctl.exe" -a %%i >> "%SMART_LOG_FILE%"

) ELSE (
for /F %%i in ("%DEVICE_LIST: =!newline!%") do "%PROGRAM_PATH%\smartctl.exe" -a %%i >> "%SMART_LOG_FILE%"
)
for /F %%d in ('type "%curdir%\smartd.conf" ^| findstr /R /C:"^/"') do "%curdir%\smartctl.exe" -a %%d >> "%SMART_LOG_FILE%"
for /F %%d in ('type "%curdir%\smartd.conf" ^| findstr /R /C:"^DEVICESCAN"') do SET DEVICESCAN=yes
IF "%DEVICESCAN%"=="yes" FOR /F "delims= " %%i in ('"%curdir%\smartctl.exe" --scan') do "%curdir%\smartctl.exe" -a %%i >> "%SMART_LOG_FILE%"
GOTO:EOF

:GetComputerName
Expand All @@ -110,12 +142,13 @@ call:GetPwd
IF "%MAILER%"=="blat" call:MailerBlat
IF "%MAILER%"=="sendemail" call:MailerSendEmail
IF "%MAILER%"=="mailsend" call:MailerMailSend
IF "%MAILER%"=="" call:MailerMailSend
GOTO:EOF

:MailerMailSend
set attachment=
IF "%COMPRESS_LOGS%"=="yes" (
"%PROGRAM_PATH%\gzip" -c "%SMART_LOG_FILE%" > "%SMART_LOG_FILE%.gz"
"%curdir%\gzip" -c "%SMART_LOG_FILE%" > "%SMART_LOG_FILE%.gz"
set attachment=-attach "%SMART_LOG_FILE%.gz,application/gzip,a"
) ELSE (
set attachment=-attach "%SMART_LOG_FILE%"
Expand All @@ -127,9 +160,9 @@ IF "%SECURITY%"=="ssl" set encryption=-ssl
IF NOT "%SMTP_USER%"=="" set smtpuser=-auth -user "%SMTP_USER%"
IF NOT "%SMTP_PASSWORD%"=="" set smtppassword=-pass "%SMTP_PASSWORD%"
IF %DRY%==1 (
echo "%PROGRAM_PATH%\mailsend.exe" -f "%SOURCE_MAIL%" -t "%DESTINATION_MAIL%" -sub "%SUBJECT%" -M "%MAIL_CONTENT%" %attachment% -smtp "%SMTP_SERVER%" -port %SMTP_PORT% %smtpuser% %smtppassword% %encryption%
echo "%curdir%\mailsend.exe" -f "%SOURCE_MAIL%" -t "%DESTINATION_MAIL%" -sub "%SUBJECT%" -M "%MAIL_CONTENT%" %attachment% -smtp "%SMTP_SERVER%" -port %SMTP_PORT% %smtpuser% %smtppassword% %encryption%
) ELSE (
"%PROGRAM_PATH%\mailsend.exe" -f "%SOURCE_MAIL%" -t "%DESTINATION_MAIL%" -sub "%SUBJECT%" -M "%MAIL_CONTENT%" %attachment% -smtp "%SMTP_SERVER%" -port %SMTP_PORT% %smtpuser% %smtppassword% %encryption%
"%curdir%\mailsend.exe" -f "%SOURCE_MAIL%" -t "%DESTINATION_MAIL%" -sub "%SUBJECT%" -M "%MAIL_CONTENT%" %attachment% -smtp "%SMTP_SERVER%" -port %SMTP_PORT% %smtpuser% %smtppassword% %encryption%
)
IF NOT %ERRORLEVEL%==0 (
set SCRIPT_ERROR=1
Expand All @@ -141,7 +174,7 @@ GOTO:EOF
:MailerSendEmail
set attachment=
IF "%COMPRESS_LOGS%"=="yes" (
"%PROGRAM_PATH%\gzip" -c "%SMART_LOG_FILE%" > "%SMART_LOG_FILE%.gz"
"%curdir%\gzip" -c "%SMART_LOG_FILE%" > "%SMART_LOG_FILE%.gz"
set attachment=-a "%SMART_LOG_FILE%.gz"
) ELSE (
set attachment=-a "%SMART_LOG_FILE%"
Expand All @@ -153,9 +186,9 @@ IF "%SECURITY%"=="ssl" set encryption=-o tls=auto
IF NOT "%SMTP_USER%"=="" set smtpuser=-xu "%SMTP_USER%"
IF NOT "%SMTP_PASSWORD%"=="" set smtppassword=-xp "%SMTP_PASSWORD%"
IF %DRY%==1 (
echo "%PROGRAM_PATH%\sendemail.exe" -f "%SOURCE_MAIL%" -t "%DESTINATION_MAIL%" -u "%SUBJECT%" -m "%MAIL_CONTENT%" %attachment% -s %SMTP_SERVER%:%SMTP_PORT% %encryption% %smtpuser% %smtppassword%
echo "%curdir%\sendemail.exe" -f "%SOURCE_MAIL%" -t "%DESTINATION_MAIL%" -u "%SUBJECT%" -m "%MAIL_CONTENT%" %attachment% -s %SMTP_SERVER%:%SMTP_PORT% %encryption% %smtpuser% %smtppassword%
) ELSE (
"%PROGRAM_PATH%\sendemail.exe" -f "%SOURCE_MAIL%" -t "%DESTINATION_MAIL%" -u "%SUBJECT%" -m "%MAIL_CONTENT%" %attachment% -s %SMTP_SERVER%:%SMTP_PORT% %encryption% %smtpuser% %smtppassword%
"%curdir%\sendemail.exe" -f "%SOURCE_MAIL%" -t "%DESTINATION_MAIL%" -u "%SUBJECT%" -m "%MAIL_CONTENT%" %attachment% -s %SMTP_SERVER%:%SMTP_PORT% %encryption% %smtpuser% %smtppassword%
)
IF NOT %ERRORLEVEL%==0 (
set SCRIPT_ERROR=1
Expand All @@ -182,9 +215,9 @@ IF "%LOCAL_ALERT_TYPE%"=="active" set local_alert_type_switch=-a
IF "%LOCAL_ALERT_TYPE%"=="console" set local_alert_type_switch=-c
IF "%LOCAL_ALERT_TYPE%"=="connected" set local_alert_type_switch=-s
IF %DRY%==1 (
echo "%PROGRAM_PATH%\wtssendmsg.exe" %local_alert_type_switch% "%WARNING_MESSAGE% [%COMPUTER_FQDN%]"
echo "%curdir%\wtssendmsg.exe" %local_alert_type_switch% "%WARNING_MESSAGE% [%COMPUTER_FQDN%]"
) ELSE (
"%PROGRAM_PATH%\wtssendmsg.exe" %local_alert_type_switch% "%WARNING_MESSAGE% [%COMPUTER_FQDN%]"
"%curdir%\wtssendmsg.exe" %local_alert_type_switch% "%WARNING_MESSAGE% [%COMPUTER_FQDN%]"
)
IF NOT %ERRORLEVEL%==0 (
set SCRIPT_ERROR=1
Expand All @@ -193,4 +226,5 @@ IF NOT %ERRORLEVEL%==0 (
GOTO:EOF

:END
IF NOT %SCRIPT_ERROR%==0 echo Something bad happened while executing this script. Please check log file. You can also check what happens with parameter --dryrun
:: Keeping the ping part in order to let commandline window open for some seconds after execution
IF NOT %SCRIPT_ERROR%==0 echo Something bad happened while executing this script. Please check log file. You can also check what happens with parameter --dryrun && ping 127.0.0.1 > nul
5 changes: 0 additions & 5 deletions erroraction_config.cmd
@@ -1,5 +1,4 @@
set MAIL_ALERT=yes
set MAILER=mailsend
set SOURCE_MAIL=
set DESTINATION_MAIL=
set SMTP_SERVER=
Expand All @@ -10,7 +9,3 @@ set SECURITY=none
set LOCAL_ALERT=
set WARNING_MESSAGE=[WARNING_MESSAGE]
set COMPRESS_LOGS=yes
set DEVICE_LIST=DEVICESCAN
set SMART_LOG_FILE=[PATH]\smart.log
set ERROR_LOG_FILE=[PATH]\erroraction.log
set PROGRAM_PATH=[PATH]
Binary file added erroraction_config/erroraction_config.ico
Binary file not shown.

0 comments on commit d4c2a0e

Please sign in to comment.