enano-bundle.nsi
author Dan
Wed, 27 May 2009 01:15:21 -0400
changeset 1 ac5bcb4e5284
parent 0 67e1cc6cd929
child 3 0cce88c7cf7c
permissions -rw-r--r--
PostgreSQL: skip applications.html stage (not supported in upstream wappstack)

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Enano CMS"
!define PRODUCT_VERSION "1.1.6"
!define PRODUCT_PUBLISHER "Enano CMS Project"
!define PRODUCT_WEB_SITE "http://enanocms.org"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_SHORTNAME "enanocms"

!ifndef ENANO_ROOT
!define ENANO_ROOT "Q:\enano-1.1\repo"
!endif

SetCompressor /FINAL /SOLID lzma
CRCCheck force

Var wampstack_installed
Var wappstack_installed
Var stack_type
Var stack_instdir
Var stack_portbit
Var db_dbmsname
Var db_rootuser
Var db_rootpass
Var db_needroot
Var db_driver
Var db_port
Var db_user
Var db_password
Var db_name
Var enano_user
Var enano_password
Var admin_email
Var site_name
Var site_desc
Var site_copyright
Var url_scheme
Var start_with

!include "inst-resources\bitnamiutils.nsh"
!include "inst-resources\dbal.nsh"
!include "inst-resources\mysql.nsh"
!include "inst-resources\postgresql.nsh"
!include "inst-resources\str_replace.nsh"
!include "inst-resources\kickstart.nsh"
!include "inst-resources\apacheconfig.nsh"
!include "inst-resources\applist.nsh"

Function .onInit
  Call BNSetWAMPInstalledFlag
  Call BNSetWAPPInstalledFlag
  
  ; If neither WAMP nor WAPP is installed, die
  StrCmp $wampstack_installed 0 "" FoundStack
  StrCmp $wampstack_installed 0 "" FoundStack

    MessageBox MB_OK|MB_ICONEXCLAMATION "Setup could not find any BitNami stacks on your server.$\r$\n\
                                         $\r$\n\
                                         Please install a BitNami stack and re-run setup. You can download a BitNami stack for free from http://www.bitnami.org."
    Abort

  FoundStack:
FunctionEnd

; ExperienceUI GUI parameters
!define XPUI_BGIMAGE
!define XPUI_BGIMAGE_BMP "gfx\enano-bg.bmp"
!define XPUI_TEXT_COLOR "F2F2F2"
!define XPUI_TEXT_BGCOLOR "202020" ; irrelevant but still
!define XPUI_TEXT_LIGHTCOLOR "B4C3EA"
!define XPUI_ABORTWARNING
!define XPUI_BRANDINGTEXT "NSIS Installer ${NSIS_VERSION}"
!define XPUI_BRANDINGTEXT_COLOR_FG "b6d9ff"
!define XPUI_BRANDINGTEXT_COLOR_BG "4c5b6b"
!define XPUI_FASTERSKINNING

; MUI 1.67 compatible / XPUI 1.11 (2.0pre) compatible ------
!ifndef XPUI_SYSDIR
  !define XPUI_SYSDIR "C:\ExperienceUI\Contrib\ExperienceUI"
!endif
!include "${XPUI_SYSDIR}\..\..\Include\XPUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "inst-resources\generic-install.ico"
!define MUI_UNICON "inst-resources\generic-uninstall.ico"
!include "WinMessages.nsh"

; Welcome page
!insertmacro XPUI_PAGE_WELCOME2
; License page
!insertmacro MUI_PAGE_LICENSE "licenses\GPL.txt"
; Stack selection - automatic unless both stacks are installed
!include "pages\StackSelect.nsi"
; Database credentials entry
!include "pages\DatabaseConfig.nsi"
; Site config page
!include "pages\SiteConfig.nsi"
; User credentials page
!include "pages\Login.nsi"
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!define XPUI_FINISHPAGE_RUN
!define XPUI_FINISHPAGE_CHECKBOX_RUN "Go to my new $(^Name) website now"
!define XPUI_FINISHPAGE_RUN_FUNCTION OpenBitnamiWebsite
Function OpenBitnamiWebsite
  ExecShell open "http://localhost$stack_portbit/${PRODUCT_SHORTNAME}/"
FunctionEnd
!insertmacro MUI_PAGE_FINISH

!insertmacro XPUI_PAGE_ABORT

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"

; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

; MUI end ------

; File lists
!include "inst-resources\core-files.nsh"
; End file lists

Name "${PRODUCT_NAME}"
Caption "${PRODUCT_NAME} ${PRODUCT_VERSION} Bitnami installer"
OutFile "enano-1.1.6-bitnami-setup.exe"
InstallDir "$PROGRAMFILES\Enano CMS"
ShowInstDetails show
ShowUnInstDetails show

Section "-pre"
  StrCpy $INSTDIR "$stack_instdir"
  IfFileExists "$INSTDIR\apps\${PRODUCT_SHORTNAME}\htdocs\config.php" 0 +2
    Delete "$INSTDIR\apps\${PRODUCT_SHORTNAME}\htdocs\config.php"
SectionEnd

Section "-DatabaseSetup"
  StrCmp $db_needroot 1 +2
    Return
    
  ; Create database
  ${db_create} $R0 "$db_rootuser" "$db_rootpass" "$db_name" "$db_user" "$db_password"
  IntCmp $R0 0 DatabaseCreateSuccess
    !insertmacro XPUI_HEADER_TEXT "Installation failed" "Could not create the database."
    DetailPrint "Database creation failed."
    MessageBox MB_OK|MB_ICONEXCLAMATION "Setup failed to create the database for $(^Name).$\r$\n\
                                         $\r$\n\
                                         It's possible that your authentication details were rejected or that there \
                                         is a bug in the installer. Try removing any special characters (especially \
                                         quote symbols and backslashes) from your password. Make sure to use only \
                                         letters, numbers, and underscores in the database name and username."
    Abort
  DatabaseCreateSuccess:
SectionEnd

Section "Enano Core" SEC01
  SectionIn RO
  !insertmacro Core_Install
SectionEnd

Section "Enable GMP in PHP" SecGMP
  ClearErrors
  WriteINIStr "$stack_instdir\php\php.ini" "GMP" "extension" "php_gmp.dll"
  IfErrors 0 +2
    MessageBox MB_OK|MB_ICONEXCLAMATION "GMP was not automatically enabled in PHP. Logins will be several seconds slower."
SectionEnd

Section "YubiKey auth plugin" SEC02
SectionEnd

Section "AjIM2" SEC03
SectionEnd

Section "Admin Alerts" SEC04
SectionEnd

Section "RSS Feeds" SEC06
SectionEnd

Section "News Portal" SEC08
SectionEnd

Section "Code syntax highlighting" SEC11
SectionEnd

Section "Wiki functionality extensions" SEC12
SectionEnd

Section -ConfigureApache
  DetailPrint "Configuring Apache web server"
  Call write_apache_config
  DetailPrint "Restarting Apache"
  nsExec::Exec '"$SYSDIR\net.exe" stop "$stack_typestackApache"'
  nsExec::Exec '"$SYSDIR\net.exe" start "$stack_typestackApache"'
SectionEnd

Section -WriteKickStart
  Call enano_write_kickstart_script
SectionEnd

Section -DoEnanoDBSetup
  Call enano_run_kickstart_script
SectionEnd

Section -InsertApplistEntry
  ; Skip if this is WAPPStack, it doesn't have an applications.html. (!)
  StrCmp $stack_type "WAPP" 0 +2
    Return
  
  Call enano_add_to_applist
SectionEnd

Section -AdditionalIcons
  WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
  CreateDirectory "$SMPROGRAMS\Enano CMS"
  CreateShortCut "$SMPROGRAMS\Enano CMS\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
  CreateShortCut "$SMPROGRAMS\Enano CMS\Uninstall.lnk" "$INSTDIR\apps\${PRODUCT_SHORTNAME}\uninst.exe"
SectionEnd

Section -Post
  WriteUninstaller "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
  WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
SectionEnd

; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} "Core components of Enano CMS, necessary to run Enano"
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} "Adds support for Yubikey authentication"
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} "An AJAX chatbox sidebar gadget for Enano"
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC04} "Provides a sidebar block that alerts you about unapproved comments, inactive users, and pages with requested deletion."
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC06} "Provides the ability to generate RSS feeds based on the latest page edits and comments. It also has a plugin API so plugins can add their own feeds."
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC08} "Provides a portal with news and static content combined onto one page."
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC11} "Parser extension that adds syntax highlighting support using the GeSHi highlighting engine."
  !insertmacro MUI_DESCRIPTION_TEXT ${SEC12} "Adds several parser extensions that provide MediaWiki-like behavior, including references (footnotes) and Table of Contents support."
  !insertmacro MUI_DESCRIPTION_TEXT ${SecGMP} "Enables PHP's GMP extension, which speeds up cryptographic operations."
!insertmacro MUI_FUNCTION_DESCRIPTION_END


Function un.onUninstSuccess
  HideWindow
  MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
FunctionEnd

Function un.onInit
  MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
  Abort
FunctionEnd

Section Uninstall
  Delete "$INSTDIR\apps\${PRODUCT_SHORTNAME}\${PRODUCT_NAME}.url"

  !insertmacro Core_Uninstall

  DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
  SetAutoClose true
SectionEnd

; Version Information

VIProductVersion "1.1.6.0"
VIAddVersionKey /LANG=1033 "ProductName" "Enano CMS"
VIAddVersionKey /LANG=1033 "Setup Information" "Enano CMS installer module for Windows Apache stacks"
VIAddVersionKey /LANG=1033 "Comments" "This installer contains a beta build of Enano CMS, use with caution!"
VIAddVersionKey /LANG=1033 "Publisher Name" "Neal Gompa (King InuYasha), Enano CMS Project"
VIAddVersionKey /LANG=1033 "LegalCopyright" "©2009 Enano CMS Project"
VIAddVersionKey /LANG=1033 "FileDescription" "Enano - The CMS that focuses on what matters most: content."
VIAddVersionKey /LANG=1033 "FileVersion" "${PRODUCT_VERSION}"