
Recently I was tasked with automating the installation of a few customized applications. As a requirement for my production site, I must always have the most up to date version of the following:
- Apache Web Server (HTTPD) 2.2.21
- OpenSSL 1.0.0e
- PHP 5.3.8
- Java Runtime 1.6
- ElasticSearch 0.17.1
- Databases supported MySQL, Oracle, MS-SQL Server (various php extensions needed)
- Custom PHP Web Application w/ ExtJS 4.0.6
Maintaining the updates for these products can be a pain when you do not have access to the production system. My original Install guide was quite lengthly and was a pain to keep up to date everytime my installation procedures changed. I was able to fix all of this will Nullsoft's NSIS.
There are a variety of plugins available to help with different tasks. Currently my Installer uses a splash screen, modifys system variables, creates and starts windows services, and uninstalls everything cleanly.
Splash Screen - Just Modify the Splash.bmp's Absolute path in quotes. Add to the NSI file just before you Installer Information. (Name, Outfile, installDir, etc.)
;====================================================
;Splash Screen Information
Function .onInit
SetOutPath $TEMP
File /oname=spltmp.bmp "C:\Users\Charles\Desktop\Splash.bmp"
advsplash::show 1000 600 400 -1 $TEMP\spltmp
Pop $0 ; $0 has '1' if the user closed the splash screen early,
; '0' if everything closed normally, and '-1' if some error occurred.
Delete $TEMP\spltmp.bmp
FunctionEnd
If you want your installer to run with elevated Privledges (Vista, Windows 7)
;====================================================
;Elevate Privs for Installation
RequestExecutionLevel admin
Check Java Version
;====================================================
;Java Installation Check
Section "find java" FINDJAVA
StrCpy $1 "SOFTWARE\JavaSoft\Java Runtime Environment"
StrCpy $2 0
ReadRegStr $2 HKLM "$1" "CurrentVersion"
StrCmp $2 "" DetectTry2
ReadRegStr $5 HKLM "$1\$2" "JavaHome"
StrCmp $5 "" DetectTry2
goto done
DetectTry2:
ReadRegStr $2 HKLM "SOFTWARE\JavaSoft\Java Development Kit" "CurrentVersion"
StrCmp $2 "" NoJava
ReadRegStr $5 HKLM "SOFTWARE\JavaSoft\Java Development Kit\$2" "JavaHome"
StrCMP $5 "" NoJava done
done:
;All done.
NoJava:
;Install Java script
nsExec::Exec "start http:\\www.java.com"
SectionEnd
Check the nullsoft site for downloads and additional information. I used the nsSCM & nsEXEC plugins for manipulation of window's services and other batch script tasks.