enano-bundle.nsi
changeset 3 0cce88c7cf7c
parent 1 ac5bcb4e5284
child 5 85800cb04cc5
equal deleted inserted replaced
2:0c0d5dadfca3 3:0cce88c7cf7c
     6 !define PRODUCT_PUBLISHER "Enano CMS Project"
     6 !define PRODUCT_PUBLISHER "Enano CMS Project"
     7 !define PRODUCT_WEB_SITE "http://enanocms.org"
     7 !define PRODUCT_WEB_SITE "http://enanocms.org"
     8 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
     8 !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
     9 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
     9 !define PRODUCT_UNINST_ROOT_KEY "HKLM"
    10 !define PRODUCT_SHORTNAME "enanocms"
    10 !define PRODUCT_SHORTNAME "enanocms"
       
    11 ; !define UNINSTALL_DEBUG
    11 
    12 
    12 !ifndef ENANO_ROOT
    13 !ifndef ENANO_ROOT
    13 !define ENANO_ROOT "Q:\enano-1.1\repo"
    14 !define ENANO_ROOT "Q:\enano-1.1\repo"
    14 !endif
    15 !endif
    15 
    16 
    36 Var site_name
    37 Var site_name
    37 Var site_desc
    38 Var site_desc
    38 Var site_copyright
    39 Var site_copyright
    39 Var url_scheme
    40 Var url_scheme
    40 Var start_with
    41 Var start_with
       
    42 Var skip_install
    41 
    43 
    42 !include "inst-resources\bitnamiutils.nsh"
    44 !include "inst-resources\bitnamiutils.nsh"
    43 !include "inst-resources\dbal.nsh"
    45 !include "inst-resources\dbal.nsh"
    44 !include "inst-resources\mysql.nsh"
    46 !include "inst-resources\mysql.nsh"
    45 !include "inst-resources\postgresql.nsh"
    47 !include "inst-resources\postgresql.nsh"
    47 !include "inst-resources\kickstart.nsh"
    49 !include "inst-resources\kickstart.nsh"
    48 !include "inst-resources\apacheconfig.nsh"
    50 !include "inst-resources\apacheconfig.nsh"
    49 !include "inst-resources\applist.nsh"
    51 !include "inst-resources\applist.nsh"
    50 
    52 
    51 Function .onInit
    53 Function .onInit
       
    54   !ifdef UNINSTALL_DEBUG
       
    55     WriteUninstaller "$EXEDIR\uninstall.exe"
       
    56     MessageBox MB_OKCANCEL "Uninstaller written. OK to run installer, Cancel to quit" IDOK +2
       
    57       Abort
       
    58   !endif
    52   Call BNSetWAMPInstalledFlag
    59   Call BNSetWAMPInstalledFlag
    53   Call BNSetWAPPInstalledFlag
    60   Call BNSetWAPPInstalledFlag
    54   
    61   
    55   ; If neither WAMP nor WAPP is installed, die
    62   ; If neither WAMP nor WAPP is installed, die
    56   StrCmp $wampstack_installed 0 "" FoundStack
    63   StrCmp $wampstack_installed 0 "" FoundStack
    73 !define XPUI_ABORTWARNING
    80 !define XPUI_ABORTWARNING
    74 !define XPUI_BRANDINGTEXT "NSIS Installer ${NSIS_VERSION}"
    81 !define XPUI_BRANDINGTEXT "NSIS Installer ${NSIS_VERSION}"
    75 !define XPUI_BRANDINGTEXT_COLOR_FG "b6d9ff"
    82 !define XPUI_BRANDINGTEXT_COLOR_FG "b6d9ff"
    76 !define XPUI_BRANDINGTEXT_COLOR_BG "4c5b6b"
    83 !define XPUI_BRANDINGTEXT_COLOR_BG "4c5b6b"
    77 !define XPUI_FASTERSKINNING
    84 !define XPUI_FASTERSKINNING
       
    85 !define XPUI_UNINSTALLER
    78 
    86 
    79 ; MUI 1.67 compatible / XPUI 1.11 (2.0pre) compatible ------
    87 ; MUI 1.67 compatible / XPUI 1.11 (2.0pre) compatible ------
    80 !ifndef XPUI_SYSDIR
    88 !ifndef XPUI_SYSDIR
    81   !define XPUI_SYSDIR "C:\ExperienceUI\Contrib\ExperienceUI"
    89   !define XPUI_SYSDIR "C:\ExperienceUI\Contrib\ExperienceUI"
    82 !endif
    90 !endif
    86 !define MUI_ABORTWARNING
    94 !define MUI_ABORTWARNING
    87 !define MUI_ICON "inst-resources\generic-install.ico"
    95 !define MUI_ICON "inst-resources\generic-install.ico"
    88 !define MUI_UNICON "inst-resources\generic-uninstall.ico"
    96 !define MUI_UNICON "inst-resources\generic-uninstall.ico"
    89 !include "WinMessages.nsh"
    97 !include "WinMessages.nsh"
    90 
    98 
       
    99 ;
       
   100 ; INSTALL PAGES
       
   101 ;
       
   102 
    91 ; Welcome page
   103 ; Welcome page
    92 !insertmacro XPUI_PAGE_WELCOME2
   104 !insertmacro XPUI_PAGE_WELCOME2
    93 ; License page
   105 ; License page
    94 !insertmacro MUI_PAGE_LICENSE "licenses\GPL.txt"
   106 !insertmacro XPUI_PAGE_LICENSE "licenses\GPL.txt"
    95 ; Stack selection - automatic unless both stacks are installed
   107 ; Stack selection - automatic unless both stacks are installed
    96 !include "pages\StackSelect.nsi"
   108 !include "pages\StackSelect.nsi"
    97 ; Database credentials entry
   109 ; Database credentials entry
    98 !include "pages\DatabaseConfig.nsi"
   110 !include "pages\DatabaseConfig.nsi"
    99 ; Site config page
   111 ; Site config page
   100 !include "pages\SiteConfig.nsi"
   112 !include "pages\SiteConfig.nsi"
   101 ; User credentials page
   113 ; User credentials page
   102 !include "pages\Login.nsi"
   114 !include "pages\Login.nsi"
   103 ; Components page
   115 ; Components page
   104 !insertmacro MUI_PAGE_COMPONENTS
   116 !insertmacro XPUI_PAGE_COMPONENTS
   105 ; Instfiles page
   117 ; Instfiles page
   106 !insertmacro MUI_PAGE_INSTFILES
   118 !insertmacro XPUI_PAGE_INSTFILES
   107 ; Finish page
   119 ; Finish page
   108 !define XPUI_FINISHPAGE_RUN
   120 !define XPUI_FINISHPAGE_RUN
   109 !define XPUI_FINISHPAGE_CHECKBOX_RUN "Go to my new $(^Name) website now"
   121 !define XPUI_FINISHPAGE_CHECKBOX_RUN "Go to my new $(^Name) website now"
   110 !define XPUI_FINISHPAGE_RUN_FUNCTION OpenBitnamiWebsite
   122 !define XPUI_FINISHPAGE_RUN_FUNCTION OpenBitnamiWebsite
   111 Function OpenBitnamiWebsite
   123 Function OpenBitnamiWebsite
   113 FunctionEnd
   125 FunctionEnd
   114 !insertmacro MUI_PAGE_FINISH
   126 !insertmacro MUI_PAGE_FINISH
   115 
   127 
   116 !insertmacro XPUI_PAGE_ABORT
   128 !insertmacro XPUI_PAGE_ABORT
   117 
   129 
   118 ; Uninstaller pages
   130 ;
   119 !insertmacro MUI_UNPAGE_INSTFILES
   131 ; UNINSTALL PAGES
       
   132 ;
       
   133 
       
   134 !insertmacro XPUI_PAGEMODE_UNINST
       
   135 !insertmacro XPUI_PAGE_WELCOME2
       
   136 !insertmacro XPUI_PAGE_INSTFILES
       
   137 !insertmacro XPUI_PAGE_FINISH
   120 
   138 
   121 ; Language files
   139 ; Language files
   122 !insertmacro MUI_LANGUAGE "English"
   140 !insertmacro MUI_LANGUAGE "English"
   123 
   141 
   124 ; Reserve files
   142 ; Reserve files
   137 ShowInstDetails show
   155 ShowInstDetails show
   138 ShowUnInstDetails show
   156 ShowUnInstDetails show
   139 
   157 
   140 Section "-pre"
   158 Section "-pre"
   141   StrCpy $INSTDIR "$stack_instdir"
   159   StrCpy $INSTDIR "$stack_instdir"
       
   160   StrCpy $skip_install 0
       
   161   
       
   162   StrCmp $db_needroot 0 0 SkipManualCheck
       
   163     ; If we were given our own DB credentials and there's already a config, the installation needs to be skipped
       
   164     IfFileExists "$INSTDIR\apps\${PRODUCT_SHORTNAME}\htdocs\config.php" 0 SkipManualCheck
       
   165       StrCpy $skip_install 1
       
   166       Return
       
   167       
       
   168   SkipManualCheck:
       
   169   
   142   IfFileExists "$INSTDIR\apps\${PRODUCT_SHORTNAME}\htdocs\config.php" 0 +2
   170   IfFileExists "$INSTDIR\apps\${PRODUCT_SHORTNAME}\htdocs\config.php" 0 +2
   143     Delete "$INSTDIR\apps\${PRODUCT_SHORTNAME}\htdocs\config.php"
   171     Delete "$INSTDIR\apps\${PRODUCT_SHORTNAME}\htdocs\config.php"
   144 SectionEnd
   172 SectionEnd
   145 
   173 
   146 Section "-DatabaseSetup"
   174 Section "-DatabaseSetup"
   162   DatabaseCreateSuccess:
   190   DatabaseCreateSuccess:
   163 SectionEnd
   191 SectionEnd
   164 
   192 
   165 Section "Enano Core" SEC01
   193 Section "Enano Core" SEC01
   166   SectionIn RO
   194   SectionIn RO
       
   195   WriteUninstaller "$INSTDIR\apps\${PRODUCT_SHORTNAME}\uninstall.exe"
   167   !insertmacro Core_Install
   196   !insertmacro Core_Install
   168 SectionEnd
   197 SectionEnd
   169 
   198 
   170 Section "Enable GMP in PHP" SecGMP
   199 Section "Enable GMP in PHP" SecGMP
   171   ClearErrors
   200   ClearErrors
       
   201   IfFileExists "$stack_instdir\php\ext\php_gmp.dll" +3
       
   202   
       
   203     ; No GMP
       
   204     MessageBox MB_OK|MB_ICONEXCLAMATION "The stack you selected does not contain the GMP extension, so it cannot be enabled. Logins will be several seconds slower. Please consider upgrading your stack."
       
   205     Return
       
   206   
   172   WriteINIStr "$stack_instdir\php\php.ini" "GMP" "extension" "php_gmp.dll"
   207   WriteINIStr "$stack_instdir\php\php.ini" "GMP" "extension" "php_gmp.dll"
   173   IfErrors 0 +2
   208   IfErrors 0 +2
   174     MessageBox MB_OK|MB_ICONEXCLAMATION "GMP was not automatically enabled in PHP. Logins will be several seconds slower."
   209     MessageBox MB_OK|MB_ICONEXCLAMATION "GMP was not automatically enabled in PHP. Logins will be several seconds slower."
   175 SectionEnd
   210 SectionEnd
   176 
   211 
   199   DetailPrint "Configuring Apache web server"
   234   DetailPrint "Configuring Apache web server"
   200   Call write_apache_config
   235   Call write_apache_config
   201   DetailPrint "Restarting Apache"
   236   DetailPrint "Restarting Apache"
   202   nsExec::Exec '"$SYSDIR\net.exe" stop "$stack_typestackApache"'
   237   nsExec::Exec '"$SYSDIR\net.exe" stop "$stack_typestackApache"'
   203   nsExec::Exec '"$SYSDIR\net.exe" start "$stack_typestackApache"'
   238   nsExec::Exec '"$SYSDIR\net.exe" start "$stack_typestackApache"'
   204 SectionEnd
   239   StrCmp $skip_install 1 0 +2
   205 
   240     Return
   206 Section -WriteKickStart
   241   
   207   Call enano_write_kickstart_script
   242   Call enano_write_kickstart_script
   208 SectionEnd
       
   209 
       
   210 Section -DoEnanoDBSetup
       
   211   Call enano_run_kickstart_script
   243   Call enano_run_kickstart_script
       
   244   
       
   245   SetOutPath "$INSTDIR\apps\${PRODUCT_SHORTNAME}\scripts"
       
   246   File "inst-resources\selfdestruct.php"
   212 SectionEnd
   247 SectionEnd
   213 
   248 
   214 Section -InsertApplistEntry
   249 Section -InsertApplistEntry
   215   ; Skip if this is WAPPStack, it doesn't have an applications.html. (!)
   250   ; Skip if this is WAPPStack, it doesn't have an applications.html. (!)
   216   StrCmp $stack_type "WAPP" 0 +2
   251   StrCmp $stack_type "WAPP" 0 +2
   221 
   256 
   222 Section -AdditionalIcons
   257 Section -AdditionalIcons
   223   WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
   258   WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
   224   CreateDirectory "$SMPROGRAMS\Enano CMS"
   259   CreateDirectory "$SMPROGRAMS\Enano CMS"
   225   CreateShortCut "$SMPROGRAMS\Enano CMS\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
   260   CreateShortCut "$SMPROGRAMS\Enano CMS\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
   226   CreateShortCut "$SMPROGRAMS\Enano CMS\Uninstall.lnk" "$INSTDIR\apps\${PRODUCT_SHORTNAME}\uninst.exe"
   261   CreateShortCut "$SMPROGRAMS\Enano CMS\Uninstall.lnk" "$INSTDIR\apps\${PRODUCT_SHORTNAME}\uninstall.exe"
   227 SectionEnd
   262 SectionEnd
   228 
   263 
   229 Section -Post
   264 Section -Post
   230   WriteUninstaller "$INSTDIR\uninst.exe"
       
   231   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
   265   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
   232   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
   266   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\apps\${PRODUCT_SHORTNAME}\uninstall.exe"
   233   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
   267   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
   234   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
   268   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
   235   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
   269   WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
   236 SectionEnd
   270 SectionEnd
   237 
   271 
   247   !insertmacro MUI_DESCRIPTION_TEXT ${SEC12} "Adds several parser extensions that provide MediaWiki-like behavior, including references (footnotes) and Table of Contents support."
   281   !insertmacro MUI_DESCRIPTION_TEXT ${SEC12} "Adds several parser extensions that provide MediaWiki-like behavior, including references (footnotes) and Table of Contents support."
   248   !insertmacro MUI_DESCRIPTION_TEXT ${SecGMP} "Enables PHP's GMP extension, which speeds up cryptographic operations."
   282   !insertmacro MUI_DESCRIPTION_TEXT ${SecGMP} "Enables PHP's GMP extension, which speeds up cryptographic operations."
   249 !insertmacro MUI_FUNCTION_DESCRIPTION_END
   283 !insertmacro MUI_FUNCTION_DESCRIPTION_END
   250 
   284 
   251 
   285 
   252 Function un.onUninstSuccess
   286 Function un.onInit
   253   HideWindow
   287   
   254   MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
   288   StrCpy $stack_instdir "$INSTDIR\..\.."
       
   289   ; this is probably a bad way to determine the stack type
       
   290   ClearErrors
       
   291   StrCpy $stack_type "wamp"
       
   292   ReadINIStr $0 "$stack_instdir\properties.ini" "MySQL" "mysql_port"
       
   293   IfErrors 0 +2
       
   294     StrCpy $stack_type "wapp"
       
   295     
   255 FunctionEnd
   296 FunctionEnd
   256 
   297 
   257 Function un.onInit
       
   258   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
       
   259   Abort
       
   260 FunctionEnd
       
   261 
       
   262 Section Uninstall
   298 Section Uninstall
       
   299   
       
   300   ; Confirm uninstall
       
   301   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you really sure you want to uninstall ${PRODUCT_NAME}?$\r$\n\
       
   302                                                  $\r$\n\
       
   303                                                  Removing ${PRODUCT_NAME} will delete everything that it installed, including your database. If you do not want to \
       
   304                                                  lose data, cancel this uninstaller and back up your database before uninstalling.$\r$\n\
       
   305                                                  $\r$\n\
       
   306                                                  The ${PRODUCT_NAME} uninstaller also deletes any uploaded files, plugins and themes that you may have installed." IDYES +2
       
   307     Abort
       
   308   
   263   Delete "$INSTDIR\apps\${PRODUCT_SHORTNAME}\${PRODUCT_NAME}.url"
   309   Delete "$INSTDIR\apps\${PRODUCT_SHORTNAME}\${PRODUCT_NAME}.url"
   264 
   310 
       
   311   ; Remove from Apache config
       
   312   DetailPrint "Removing ${PRODUCT_NAME} from Apache configuration"
       
   313   Call un.disable_in_apache_config
       
   314   
       
   315   ; Remove from applications.html
       
   316   ; SON OF A BITCH. BitNami, please, PLEASE make applications.html a PHP script that includes all files in a directory.
       
   317   DetailPrint "Removing ${PRODUCT_NAME} from applications.html"
       
   318   Call un.disable_in_applications_html
       
   319   
       
   320   ; Restart Apache
       
   321   DetailPrint "Restarting Apache"
       
   322   nsExec::Exec '"$SYSDIR\net.exe" stop "$stack_typestackApache"'
       
   323   nsExec::Exec '"$SYSDIR\net.exe" start "$stack_typestackApache"'
       
   324   
       
   325   DetailPrint "Uninstalling database"
       
   326   nsExec::ExecToLog '"$stack_instdir\php\php.exe" "$INSTDIR\scripts\selfdestruct.php"'
       
   327   
       
   328   DetailPrint "Deleting files..."
       
   329   SetDetailsPrint listonly
   265   !insertmacro Core_Uninstall
   330   !insertmacro Core_Uninstall
       
   331   SetDetailsPrint both
   266 
   332 
   267   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
   333   DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
   268   SetAutoClose true
   334   SetAutoClose true
   269 SectionEnd
   335 SectionEnd
   270 
   336