
;NSIS Modern User Interface version 1.64
;Osiris Installation Script
;Written by Brian Wotring

!define MUI_PRODUCT "Osiris host security managment system"
!define MUI_VERSION "2.0.0-release"

!include "MUI.nsh"

;--------------------------------
;Configuration

  ;General

  OutFile "osiris_install.exe"

  ;Show installer the commands used to install files.

  ShowInstDetails show
  XPStyle on

;--------------------------------
;Modern UI Configuration

  !define MUI_LICENSEPAGE
  !define MUI_COMPONENTSPAGE
  
  !define MUI_ABORTWARNING
  !define MUI_UNINSTALLER
  !define MUI_UNCONFIRMPAGE
  
;--------------------------------
;Languages
 
  !insertmacro MUI_LANGUAGE "English"
  
;--------------------------------
;Language Strings

  ;Descriptions

  LangString DESC_Osiris ${LANG_ENGLISH} "Osiris comand line utility.  Use this application to communicate with an osiris management host."

  LangString DESC_Osirisd ${LANG_ENGLISH} "Osiris client service.  This is the service used to periodically scan the local filesystem.  Install this on any host you wish to scan."

  LangString DESC_Osirismd ${LANG_ENGLISH} "Osiris management service used to manage a network of scanned hosts.  This service should only be installed on a secure and trusted machine."

  CompletedText "Installation Complete. See http://osiris.shmoo.com/docs for complete documentation." 

;--------------------------------
;License Data
  
  LicenseData "..\..\..\LICENSE"
  LicenseBkColor ffffff

;--------------------------------
;Installer Sections

Section "Osiris CLI" SecCopyOsiris

  SetOutPath "$WINDIR"
  File "..\..\cli\osiris.exe"

  ;Create uninstaller
  WriteUninstaller "$WINDIR\osiris\uninstall_osiris.exe"

SectionEnd

Section "Scanning Service" SecCopyOsirisd

  SetOutPath "$SYSDIR"

  ; first install the service installer in temp.
  ; and stop/uninstall any existing service.

  File "service_installer\service_installer.exe"
  ExecWait "$SYSDIR\service_installer.exe osirisd"

  ; now create the osiris directory.

  CreateDirectory "$WINDIR\osiris"

  ; now install the servivce file.

  File "..\..\osirisd\osirisd.exe"

  ; now install and start the service.

  ExecWait "$SYSDIR\service_installer.exe osirisd Osiris_IDS_Scanner $SYSDIR\osirisd.exe"

  ; delete the service installer.

  Delete "$SYSDIR\service_installer.exe"

  ; now create the reg keys for event viewer madness.

  WriteRegDWORD HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirisd" "MaxSize" 524288
  WriteRegDWORD HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirisd" "CategoryCount" 1
  WriteRegDWORD HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirisd" "TypesSupported" 7
  WriteRegExpandStr HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirisd" "CategoryMessageFile" "%SystemRoot%\system32\osimessage.dll"
  WriteRegExpandStr HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirisd" "EventMessageFile" "%SystemRoot%\system32\osimessage.dll"
  WriteRegExpandStr HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirisd" "File" "%SystemRoot%\system32\config\Logger.evt"

  File "osimessage.dll"

  ;Create uninstaller
  WriteUninstaller "$WINDIR\osiris\uninstall_osiris.exe"

SectionEnd

Section "Management Service" SecCopyOsirismd

  SetOutPath "$SYSDIR"

  ; first install the service installer in temp.
  ; and stop/uninstall any existing service.

  File "service_installer\service_installer.exe"
  ExecWait "$SYSDIR\service_installer.exe osirismd"

  ; now create the osiris directory.

  CreateDirectory "$WINDIR\osiris"

  ; now install the servivce file.

  File "..\..\osirismd\osirismd.exe"

  ; now install and start the service.

  ExecWait "$SYSDIR\service_installer.exe osirismd Osiris_IDS_Management $SYSDIR\osirismd.exe"

  File "osimessage.dll"

  ; now install default configs.

  SetOutPath "$WINDIR\osiris\default-configs"
  File "..\..\configs\*.conf"

  ; delete the service installer.

  Delete "$SYSDIR\service_installer.exe"

  ; now create the reg keys for event viewer madness.

  WriteRegDWORD HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirismd" "CategoryCount" 1
  WriteRegDWORD HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirismd" "TypesSupported" 7
  WriteRegExpandStr HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirismd" "CategoryMessageFile" "%SystemRoot%\system32\osimessage.dll"
  WriteRegExpandStr HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirismd" "EventMessageFile" "%SystemRoot%\system32\osimessage.dll"
  WriteRegExpandStr HKLM "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\osirismd" "File" "%SystemRoot%\system32\config\Logger.evt"

  ;Create uninstaller
  WriteUninstaller "$WINDIR\osiris\uninstall_osiris.exe"

SectionEnd

;--------------------------------
;Show Descriptions

!insertmacro MUI_FUNCTIONS_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyOsiris} $(DESC_Osiris)
  !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyOsirisd} $(DESC_Osirisd)
  !insertmacro MUI_DESCRIPTION_TEXT ${SecCopyOsirismd} $(DESC_Osirismd)
!insertmacro MUI_FUNCTIONS_DESCRIPTION_END

;--------------------------------
;Uninstaller Section

Section "Uninstall"

  ;Add your stuff here

  Delete "$WINDIR\osiris.exe"
  Delete "$WINDIR\osirisd.exe"
  Delete "$WINDIR\osirismd.exe"

  Delete "$WINDIR\osiris\uninstall_osiris.exe"

  RMDir /r "$WINDIR\osiris"

  !insertmacro MUI_UNFINISHHEADER

SectionEnd
