doliwamp.iss 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032
  1. ; ----- DoliWamp.iss ---------------------------------------------------------------------
  2. ; Script to build an auto installer for Dolibarr.
  3. ; Works with InnoSetup 5.4.0 (a)
  4. ; Idea from WampServer 2 (http://www.wampserver.com)
  5. ;----------------------------------------------------------------------------------------
  6. ; You must edit some path in this file to build an exe (like SourceDir).
  7. ; WARNING: Be sure that user.* files of Mysql database used to build
  8. ; package contains only one user called root with no password.
  9. ; For this, you can edit the mysql.user table of the source database to keep
  10. ; only the root user with no password, stop server and catch
  11. ; files user.MY* to put them in the Dolibarr build/exe/doliwamp/mysql directory.
  12. ;
  13. ;----------------------------------------------------------------------------------------
  14. [Setup]
  15. ; ----- Change this -----
  16. AppName=DoliWamp
  17. ; Replace key with DoliWamp-x.x.x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x
  18. AppVerName=__FILENAMEEXEDOLIWAMP__
  19. ; Replace key with DoliWamp-x.x x or DoliWamp-x.x.x-alpha or DoliWamp-x.x.x-beta or DoliWamp-x.x.x-rc or DoliWamp-x.x.x
  20. OutputBaseFilename=__FILENAMEEXEDOLIWAMP__
  21. ; ----- End of change
  22. ;OutputManifestFile=build\doliwampbuild.log
  23. ; Define full path from which all relative path are defined
  24. ; You must modify this to put here your dolibarr root directory
  25. ;SourceDir=Z:\home\ldestailleur\git\dolibarrxxx
  26. SourceDir=..\..\..
  27. AppId=doliwamp
  28. AppPublisher=NLTechno
  29. AppPublisherURL=http://www.nltechno.com
  30. AppSupportURL=http://www.dolibarr.org
  31. AppUpdatesURL=http://www.dolibarr.org
  32. AppComments=DoliWamp includes Dolibarr, Apache, PHP and Mysql softwares.
  33. AppCopyright=Copyright (C) 2008-2016 Laurent Destailleur, NLTechno
  34. DefaultDirName=c:\dolibarr
  35. DefaultGroupName=Dolibarr
  36. ;LicenseFile=COPYING
  37. ;Compression=none
  38. Compression=lzma
  39. SolidCompression=yes
  40. WizardImageFile=build\exe\doliwamp\doliwamp.bmp
  41. WizardSmallImageFile=build\exe\doliwamp\doliwampsmall.bmp
  42. SetupIconFile=doc\images\dolibarr.ico
  43. PrivilegesRequired=admin
  44. DisableProgramGroupPage=yes
  45. ChangesEnvironment=no
  46. CreateUninstallRegKey=yes
  47. ;UseSetupLdr=no
  48. ;UninstallDisplayIcon={app}\bidon
  49. OutputDir=build
  50. ShowLanguageDialog=auto
  51. ShowUndisplayableLanguages=no
  52. LanguageDetectionMethod=uilanguage
  53. ;SignedUninstaller=yes
  54. [Languages]
  55. Name: "en"; MessagesFile: "compiler:Default.isl,build\exe\doliwamp\Languages\MyEnglish.isl"
  56. Name: "br"; MessagesFile: "compiler:Languages\Portuguese.isl,build\exe\doliwamp\Languages\MyBrazilianPortuguese.isl"
  57. Name: "ca"; MessagesFile: "compiler:Languages\Catalan.isl,build\exe\doliwamp\Languages\MyCatalan.isl"
  58. Name: "da"; MessagesFile: "compiler:Languages\Danish.isl,build\exe\doliwamp\Languages\MyDanish.isl"
  59. Name: "es"; MessagesFile: "compiler:Languages\Spanish.isl,build\exe\doliwamp\Languages\MySpanish.isl"
  60. Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl,build\exe\doliwamp\Languages\MyDutch.isl"
  61. Name: "fi"; MessagesFile: "compiler:Languages\Finnish.isl,build\exe\doliwamp\Languages\MyFinnish.isl"
  62. Name: "fr"; MessagesFile: "compiler:Languages\French.isl,build\exe\doliwamp\Languages\MyFrench.isl"
  63. Name: "ge"; MessagesFile: "compiler:Languages\German.isl,build\exe\doliwamp\Languages\MyGerman.isl"
  64. Name: "it"; MessagesFile: "compiler:Languages\Italian.isl,build\exe\doliwamp\Languages\MyItalian.isl"
  65. Name: "nb"; MessagesFile: "compiler:Languages\Norwegian.isl,build\exe\doliwamp\Languages\MyNorwegian.isl"
  66. Name: "po"; MessagesFile: "compiler:Languages\Polish.isl,build\exe\doliwamp\Languages\MyPolish.isl"
  67. Name: "pt"; MessagesFile: "compiler:Languages\Portuguese.isl,build\exe\doliwamp\Languages\MyPortuguese.isl"
  68. Name: "ru"; MessagesFile: "compiler:Languages\Russian.isl,build\exe\doliwamp\Languages\MyRussian.isl"
  69. Name: "sv"; MessagesFile: "compiler:Languages\Slovenian.isl,build\exe\doliwamp\Languages\MySlovenian.isl"
  70. [Tasks]
  71. ;Name: "autostart"; Description: "Automatically launch DoliWamp server on startup. If you check this option, Services will be installed as automatic. Otherwise, services will be installed as manual and will start and stop with the service manager."; GroupDescription: "Auto Start:" ;Flags: unchecked;
  72. Name: "quicklaunchicon"; Description: {cm:CreateQuickLaunchIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
  73. Name: "desktopicon"; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Flags: unchecked
  74. [Dirs]
  75. Name: "{app}\logs"
  76. Name: "{app}\tmp"
  77. Name: "{app}\dolibarr_documents"
  78. Name: "{app}\bin\apache\apache2.4.9\logs"
  79. [Files]
  80. ; Stop/start
  81. Source: "build\exe\doliwamp\stopdoliwamp.bat"; DestDir: "{app}\"; Flags: ignoreversion; AfterInstall: close()
  82. Source: "build\exe\doliwamp\startdoliwamp.bat"; DestDir: "{app}\"; Flags: ignoreversion;
  83. Source: "build\exe\doliwamp\install_services.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  84. Source: "build\exe\doliwamp\uninstall_services.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  85. Source: "build\exe\doliwamp\removefiles.bat"; DestDir: "{app}\"; Flags: ignoreversion;
  86. Source: "build\exe\doliwamp\rundoliwamp.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  87. Source: "build\exe\doliwamp\rundolihelp.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  88. Source: "build\exe\doliwamp\rundoliadmin.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  89. Source: "build\exe\doliwamp\mysqlinitpassword.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  90. Source: "build\exe\doliwamp\mysqltestinstall.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  91. Source: "build\exe\doliwamp\startdoliwamp_manual_donotuse.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  92. Source: "build\exe\doliwamp\builddemosslfiles.bat.install"; DestDir: "{app}\"; Flags: ignoreversion;
  93. Source: "build\exe\doliwamp\UsedPort.exe"; DestDir: "{app}\"; Flags: ignoreversion;
  94. ; PhpMyAdmin, Apache, Php, Mysql
  95. ; Put here path of Wampserver applications
  96. ; Value OK: apache 2.2.6, php 5.2.5 (5.2.11, 5.3.0 and 5.3.1 fails if php_exif, php_pgsql, php_zip is on), mysql 5.0.45 or 5.1.36
  97. ; Value OK: apache 2.2.11, php 5.3.0 (if no php_exif, php_pgsql, php_zip), mysql 5.0.45 or 5.1.36
  98. ; Value ???: apache 2.4.19, php 5.5.12, mysql 5.6.17
  99. Source: "C:\Program Files\Wamp\apps\phpmyadmin4.1.14\*.*"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion recursesubdirs; Excludes: "config.inc.php,wampserver.conf,*.log,*_log,darkblue_orange"
  100. Source: "C:\Program Files\Wamp\bin\apache\apache2.4.9\*.*"; DestDir: "{app}\bin\apache\apache2.4.9"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,httpd.conf,wampserver.conf,*.log,*_log"
  101. Source: "C:\Program Files\Wamp\bin\php\php5.5.12\*.*"; DestDir: "{app}\bin\php\php5.5.12"; Flags: ignoreversion recursesubdirs; Excludes: "php.ini,phpForApache.ini,wampserver.conf,*.log,*_log"
  102. Source: "C:\Program Files\Wamp\bin\mysql\mysql5.6.17\*.*"; DestDir: "{app}\bin\mysql\mysql5.6.17"; Flags: ignoreversion recursesubdirs; Excludes: "my.ini,data\*,wampserver.conf,*.log,*_log,MySQLInstanceConfig.exe"
  103. ; Mysql data files (does not overwrite if exists)
  104. Source: "build\exe\doliwamp\mysql\*.*"; DestDir: "{app}\bin\mysql\data\mysql"; Flags: onlyifdoesntexist ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db"
  105. ; Dolibarr
  106. Source: "htdocs\*.*"; DestDir: "{app}\www\dolibarr\htdocs"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,custom\*,custom2\*,documents\*,includes\ckeditor\_source\*,includes\savant\*,includes\phpmailer\*,jquery\plugins\template\*,nltechno*\*,PHPExcel\Shared\PDF\*,PHPExcel\Shared\PCLZip\*,tcpdf\fonts\dejavu-fonts-ttf-2.33\*,tcpdf\fonts\freefont-20100919\*,tcpdf\fonts\utils\*,*\conf.php,*\conf.php.mysql,*\conf.php.old,*\conf.php.postgres,*\conf.php.sav,*\install.forced.php"
  107. Source: "dev\*.*"; DestDir: "{app}\www\dolibarr\dev"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,dbmodel\*,fpdf\*,initdata\*,initdemo\*,iso-normes\*,licence\*,phpcheckstyle\*,phpunit\*,samples\*,test\*,uml\*,vagrant\*,xdebug\*"
  108. Source: "doc\*.*"; DestDir: "{app}\www\dolibarr\doc"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,wiki\*,plaquette\*,dev\*,images\dolibarr_screenshot2.png,images\dolibarr_screenshot3.png,images\dolibarr_screenshot4.png,images\dolibarr_screenshot5.png,images\dolibarr_screenshot6.png,images\dolibarr_screenshot7.png,images\dolibarr_screenshot8.png,images\dolibarr_screenshot9.png,images\dolibarr_screenshot10.png,images\dolibarr_screenshot11.png,images\dolibarr_screenshot12.png"
  109. Source: "scripts\*.*"; DestDir: "{app}\www\dolibarr\scripts"; Flags: ignoreversion recursesubdirs; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,product\materiel.net.php,product\import-product.php"
  110. Source: "*.*"; DestDir: "{app}\www\dolibarr"; Flags: ignoreversion; Excludes: ".gitignore,.project,CVS\*,Thumbs.db,default.properties,install.lock"
  111. ; Config files
  112. Source: "build\exe\doliwamp\phpmyadmin.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion;
  113. Source: "build\exe\doliwamp\dolibarr.conf.install"; DestDir: "{app}\alias"; Flags: ignoreversion;
  114. Source: "build\exe\doliwamp\config.inc.php.install"; DestDir: "{app}\apps\phpmyadmin4.1.14"; Flags: ignoreversion;
  115. Source: "build\exe\doliwamp\httpd.conf.install"; DestDir: "{app}\bin\apache\apache2.4.9\conf"; Flags: ignoreversion;
  116. Source: "build\exe\doliwamp\my.ini.install"; DestDir: "{app}\bin\mysql\mysql5.5.12"; Flags: ignoreversion;
  117. Source: "build\exe\doliwamp\php.ini.install"; DestDir: "{app}\bin\php\php5.6.17"; Flags: ignoreversion;
  118. Source: "build\exe\doliwamp\index.php.install"; DestDir: "{app}\www"; Flags: ignoreversion;
  119. Source: "build\exe\doliwamp\install.forced.php.install"; DestDir: "{app}\www\dolibarr\htdocs\install"; Flags: ignoreversion;
  120. Source: "build\exe\doliwamp\openssl.conf"; DestDir: "{app}"; Flags: ignoreversion;
  121. Source: "build\exe\doliwamp\ca_demo_dolibarr.crt"; DestDir: "{app}"; Flags: ignoreversion;
  122. Source: "build\exe\doliwamp\ca_demo_dolibarr.key"; DestDir: "{app}"; Flags: ignoreversion;
  123. ; Licence
  124. Source: "COPYRIGHT"; DestDir: "{app}"; Flags: ignoreversion;
  125. [Icons]
  126. Name: "{group}\Dolibarr ERP-CRM"; Filename: "{app}\rundoliwamp.bat"; WorkingDir: "{app}"; IconFilename: {app}\www\dolibarr\doc\images\dolibarr.ico
  127. Name: "{group}\Tools\Help center"; Filename: "{app}\rundolihelp.bat"; WorkingDir: "{app}"; IconFilename: {app}\www\dolibarr\doc\images\dolihelp.ico
  128. Name: "{group}\Tools\Host your ERP-CRM in the Cloud"; Filename: "http://wiki.dolibarr.org/index.php/Cloud_Solutions"; WorkingDir: "{app}"; IconFilename: {app}\www\dolibarr\doc\images\dolihelp.ico
  129. Name: "{group}\Tools\Start DoliWamp server"; Filename: "{app}\startdoliwamp.bat"; WorkingDir: "{app}"; IconFilename: {app}\www\dolibarr\doc\images\doliwampon.ico
  130. Name: "{group}\Tools\Stop DoliWamp server"; Filename: "{app}\stopdoliwamp.bat"; WorkingDir: "{app}"; IconFilename: {app}\www\dolibarr\doc\images\doliwampoff.ico
  131. Name: "{group}\Tools\Admin DoliWamp server"; Filename: "{app}\rundoliadmin.bat"; WorkingDir: "{app}"; IconFilename: {app}\www\dolibarr\doc\images\doliadmin.ico
  132. Name: "{group}\Tools\Uninstall DoliWamp"; Filename: "{app}\unins000.exe"; WorkingDir: "{app}"; IconFilename: {app}\uninstall_services.bat
  133. Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Dolibarr"; WorkingDir: "{app}"; Filename: "{app}\rundoliwamp.bat"; Tasks: quicklaunchicon; IconFilename: {app}\www\dolibarr\doc\images\dolibarr.ico
  134. Name: "{userdesktop}\Dolibarr ERP-CRM"; Filename: "{app}\rundoliwamp.bat"; WorkingDir: "{app}"; Tasks: desktopicon; IconFilename: {app}\www\dolibarr\doc\images\dolibarr.ico
  135. Name: "{userdesktop}\Dolibarr Help center"; Filename: "{app}\rundolihelp.bat"; WorkingDir: "{app}"; Tasks: desktopicon; IconFilename: {app}\www\dolibarr\doc\images\dolihelp.ico
  136. ;Start of servers fromstartup menu disabled as services are auto
  137. ;Name: "{userstartup}\DoliWamp server"; Filename: "{app}\startdoliwamp.bat"; WorkingDir: "{app}"; Flags: runminimized; IconFilename: {app}\www\dolibarr\doc\images\dolibarr.ico
  138. [Code]
  139. //variables globales
  140. var phpVersion: String;
  141. var apacheVersion: String;
  142. var path: String;
  143. var pfPath: String;
  144. var winPath: String;
  145. var pathWithSlashes: String;
  146. var Page: TInputQueryWizardPage;
  147. var smtpServer: String;
  148. var apachePort: String;
  149. var mysqlPort: String;
  150. var newPassword: String;
  151. var lockFile: String;
  152. var srcFile: String;
  153. var destFile: String;
  154. var srcFileH: String;
  155. var destFileH: String;
  156. var srcFileA: String;
  157. var destFileA: String;
  158. var srcContents: String;
  159. var browser: String;
  160. var mysqlVersion: String;
  161. var phpmyadminVersion: String;
  162. var phpDllCopy: String;
  163. var batFile: String;
  164. var mysmtp: String;
  165. var myporta: String;
  166. var myportas: String;
  167. var myport: String;
  168. var mypass: String;
  169. var firstinstall: Boolean;
  170. var value: String;
  171. //-----------------------------------------------
  172. //procedures lancees au debut de l'installation
  173. function InitializeSetup(): Boolean;
  174. begin
  175. Result := MsgBox(CustomMessage('YouWillInstallDoliWamp')+#13#13+CustomMessage('ThisAssistantInstallOrUpgrade')+#13#13+CustomMessage('IfYouHaveTechnicalKnowledge')+#13#13+CustomMessage('ButIfYouLook')+#13#13+CustomMessage('DoYouWantToStart'), mbConfirmation, MB_YESNO) = IDYES;
  176. end;
  177. procedure InitializeWizard();
  178. begin
  179. //version des applis, a modifier pour chaque version de WampServer 2
  180. apacheVersion := '2.4.9';
  181. phpVersion := '5.5.12' ;
  182. mysqlVersion := '5.6.17';
  183. phpmyadminVersion := '4.1.14';
  184. smtpServer := 'localhost';
  185. apachePort := '80';
  186. mysqlPort := '3306';
  187. newPassword := 'changeme';
  188. firstinstall := true;
  189. //LoadStringFromFile (srcFile, srcContents);
  190. //posvalue=Pos('$dolibarr_main_db_port=', srcFile);
  191. if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp','smtpServer', value) then
  192. begin
  193. if value <> '' then smtpServer:=value;
  194. end
  195. else
  196. begin
  197. if RegQueryStringValue(HKEY_CURRENT_USER, 'Software\Microsoft\Internet Account Manager\Accounts\00000001','SMTP Server', value) then
  198. begin
  199. if value <> '' then smtpServer:=value;
  200. end
  201. else
  202. begin
  203. if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'PMail\ServiceInfo\Mail_Account_1','SvcSMTPHost', value) then
  204. begin
  205. if value <> '' then smtpServer:=value;
  206. end
  207. else
  208. begin
  209. if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\MSCRM','SMTPServer', value) then
  210. begin
  211. if value <> '' then smtpServer:=value;
  212. end
  213. end
  214. end
  215. end;
  216. if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp','apachePort', value) then
  217. begin
  218. if value <> '' then apachePort:=value;
  219. end;
  220. if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp','mysqlPort', value) then
  221. begin
  222. if value <> '' then mysqlPort:=value;
  223. end;
  224. if RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp','newPassword', value) then
  225. begin
  226. if value <> '' then newPassword:=value;
  227. end;
  228. // Prepare an object calle "Page" of type wpInstalling.
  229. // Object will be show later in NextButtonClick function.
  230. Page := CreateInputQueryPage(wpInstalling, CustomMessage('TechnicalParameters'), '', CustomMessage('IfFirstInstall'));
  231. // TODO Add control differently if first install or update
  232. if firstinstall
  233. then
  234. begin
  235. Page.Add(CustomMessage('SMTPServer'), False);
  236. Page.Add(CustomMessage('ApachePort'), False);
  237. Page.Add(CustomMessage('MySqlPort'), False);
  238. Page.Add(CustomMessage('MySqlPassword'), False);
  239. end
  240. else
  241. begin
  242. Page.Add(CustomMessage('SMTPServer'), False);
  243. Page.Add(CustomMessage('ApachePort'), False);
  244. Page.Add(CustomMessage('MySqlPort'), False);
  245. Page.Add(CustomMessage('MySqlPassword'), False);
  246. end;
  247. // Default values
  248. Page.Values[0] := smtpServer;
  249. Page.Values[1] := apachePort;
  250. Page.Values[2] := mysqlPort;
  251. Page.Values[3] := newPassword;
  252. end;
  253. //-----------------------------------------------
  254. // Stop all services (if exist)
  255. procedure close();
  256. var myResult: Integer;
  257. begin
  258. path := ExpandConstant('{app}');
  259. pfPath := ExpandConstant('{pf}');
  260. winPath := ExpandConstant('{win}');
  261. pathWithSlashes := path;
  262. StringChange (pathWithSlashes, '\','/');
  263. batFile := path+'\stopdoliwamp.bat';
  264. Exec(batFile, '',path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  265. end;
  266. //-----------------------------------------------------------
  267. // Install pages
  268. function NextButtonClick(CurPageID: Integer): Boolean;
  269. var myResult: Integer;
  270. var res: Boolean;
  271. var paramok: Boolean;
  272. var datadirold: String;
  273. var datadirnew: String;
  274. var exedirold: String;
  275. var exedirnew: String;
  276. var themessage: String;
  277. begin
  278. res := True;
  279. //MsgBox(''+CurPageID,mbConfirmation,MB_YESNO);
  280. if CurPageID = Page.ID then
  281. begin
  282. // This must be in if curpage.id = page.id, otherwise it is executed after each Next button
  283. path := ExpandConstant('{app}');
  284. winPath := ExpandConstant('{win}');
  285. pathWithSlashes := path;
  286. StringChange (pathWithSlashes, '\','/');
  287. datadirold := pathWithSlashes+'/bin/mysql/mysql5.6.17/data';
  288. datadirnew := pathWithSlashes+'/bin/mysql/data';
  289. exedirold := pathWithSlashes+'/bin/mysql/mysql5.6.17';
  290. exedirnew := pathWithSlashes+'/bin/mysql/mysql5.6.17';
  291. //----------------------------------------------
  292. // Test if VC11Redist has been installed
  293. //----------------------------------------------
  294. if not FileExists ('c:/windows/system32/msvcr70.dll') and not FileExists ('c:/windows/sysWOW64/msvcr70.dll') and not FileExists ('c:/winnt/system32/msvcr70.dll') and not FileExists ('c:/winnt/sysWOW64/msvcr70.dll') then
  295. begin
  296. // TODO Copy file or ask to install package ?
  297. //CustomMessage('YouWillInstallDoliWamp')+#13#13
  298. MsgBox('The package vcredist_x64.exe or vcredist_86.exe must have been installed first. It seems it is not. Please install it first from <a href="http://ccc">http://www.microsoft.com/en-us/download/details.aspx?id=30679</a> then restart DoliWamp installation/upgrade.',mbInformation,MB_OK);
  299. end;
  300. // If we have a new database version, we should only copy old my.ini file into new directory
  301. // and change only all basedir= strings to use new version. Like this, data dir is still correct.
  302. // Install of service and stop/start scripts are already rebuild by installer.
  303. // FileCopy(exedirold+'/my.ini',exedirnew+'/my.ini', true);
  304. // We should not need this, also databases may not be called dolibarr
  305. // res := RenameFile(ibdata1dirold+'/dolibarr',ibdata1dirnew+'/dolibarr');
  306. // if res then
  307. // begin
  308. // themessage := CustomMessage('OldVersionFoundAndMoveInNew');
  309. // MsgBox(themessage,mbInformation,MB_OK);
  310. // TODO Replace also mysql.ini and resintall service
  311. // end
  312. // else
  313. // begin
  314. // themessage := CustomMessage('OldVersionFoundButFailedToMoveInNew');
  315. // MsgBox(themessage,mbInformation,MB_OK);
  316. // end;
  317. //----------------------------------------------
  318. // Copie des dll de php vers apache
  319. //----------------------------------------------
  320. // TODO Update this list when changing PHP/Apache versions
  321. phpDllCopy := 'fdftk.dll';
  322. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  323. phpDllCopy := 'fribidi.dll';
  324. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  325. phpDllCopy := 'gds32.dll';
  326. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  327. phpDllCopy := 'libeay32.dll';
  328. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  329. phpDllCopy := 'libmhash.dll';
  330. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  331. phpDllCopy := 'libmysql.dll';
  332. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  333. phpDllCopy := 'libpq.dll';
  334. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  335. phpDllCopy := 'msql.dll';
  336. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  337. phpDllCopy := 'libmcrypt.dll';
  338. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  339. phpDllCopy := 'libmysqli.dll';
  340. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  341. phpDllCopy := 'ntwdblib.dll';
  342. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  343. phpDllCopy := 'php5activescript.dll';
  344. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  345. phpDllCopy := 'php5nsapi.dll';
  346. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  347. phpDllCopy := 'php5ts.dll';
  348. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  349. phpDllCopy := 'ssleay32.dll';
  350. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  351. phpDllCopy := 'yaz.dll';
  352. filecopy (pathWithSlashes+'/bin/php/php'+phpVersion+'/'+phpDllCopy, pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/'+phpDllCopy, False);
  353. // Remove lock file
  354. lockfile := pathWithSlashes+'/dolibarr_documents/install.lock';
  355. if FileExists (lockfile) and not DeleteFile(lockfile) then
  356. begin
  357. themessage := FmtMessage(CustomMessage('FailedToDeleteLock'),[pathWithSlashes]);
  358. MsgBox(themessage,mbInformation,MB_OK);
  359. end
  360. // Check if parameters already defined in conf.php file
  361. srcFile := pathWithSlashes+'/www/dolibarr/htdocs/conf/conf.php';
  362. if not FileExists (srcFile) then
  363. begin
  364. firstinstall := true;
  365. // Values from wizard
  366. mysmtp := Page.Values[0];
  367. myporta := Page.Values[1];
  368. myportas:= '443';
  369. myport := Page.Values[2];
  370. mypass := Page.Values[3];
  371. end
  372. else
  373. begin
  374. firstinstall := false;
  375. // Values from registry
  376. mysmtp := smtpServer;
  377. myporta := apachePort;
  378. myportas:= '443';
  379. myport := mysqlPort;
  380. mypass := newPassword;
  381. end;
  382. paramok := True;
  383. // TODO Test if choice of param is ok if firstinstall
  384. if (firstinstall) then
  385. begin
  386. // Test serveur SMTP
  387. // if paramok then
  388. // begin
  389. // batFile := pathWithSlashes+'/UsedPort.exe';
  390. // MsgBox('batFile = '+batFile,mbConfirmation,MB_YESNO)
  391. // Exec(batFile, '-s '+smtpServer+' -p 25', path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  392. //themessage := 'Le serveur '+smtpServer+' semble ne pas etre joignable pour l envoi de mail SMTP (port 25). Si vous avez un firewall, verifiez sa configuration. Sinon, revenez en arriere pour choisir une autre valeur pour le serveur SMTP sortant d envoi de mail (Cette information est doit etre fournie par votre fournisseur d acces Internet).';
  393. // themessage := 'The server '+smtpServer+' seems to be unreachable to send outgoing SMTP emails (port 25). If you have a firewall, check its setup. Otherwise, go back to choose another value for the SMTP server (This information shoud be given by your Internet Service Provider) or click "No" to ignore error. Cancel choice to choose another value ?';
  394. // if ((IntToStr(myResult) <> '0') and (MsgBox(themessage,mbConfirmation,MB_YESNO) = IDYES)) then
  395. // begin
  396. // paramok := False;
  397. // end;
  398. // end;
  399. if paramok then
  400. begin
  401. // Test port Apache
  402. batFile := pathWithSlashes+'/UsedPort.exe';
  403. //MsgBox('batFile = '+batFile,mbConfirmation,MB_YESNO)
  404. Exec(batFile, '-s localhost -p '+myporta, path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  405. //themessage := 'Le port '+myporta+' semble deja pris. Revenez en arriere pour choisir une autre valeur pour le port Apache.';
  406. themessage := FmtMessage(CustomMessage('PortAlreadyInUse'),[myporta,'Apache']);
  407. if ((IntToStr(myResult) = '0') and (MsgBox(themessage,mbConfirmation,MB_YESNO) = IDYES)) then
  408. begin
  409. paramok := False;
  410. end;
  411. end;
  412. if paramok then
  413. begin
  414. // Test port Mysql
  415. batFile := pathWithSlashes+'/UsedPort.exe';
  416. //MsgBox('batFile = '+batFile,mbConfirmation,MB_YESNO)
  417. Exec(batFile, '-s localhost -p '+myport, path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  418. //themessage := 'Le port '+myport+' semble deja pris. Revenez en arriere pour choisir une autre valeur pour le port MySQL.';
  419. themessage := FmtMessage(CustomMessage('PortAlreadyInUse'),[myport,'MySql']);
  420. if ((IntToStr(myResult) = '0') and (MsgBox(themessage,mbConfirmation,MB_YESNO) = IDYES)) then
  421. begin
  422. paramok := False;
  423. end;
  424. end;
  425. end;
  426. if paramok
  427. then
  428. begin
  429. //----------------------------------------------
  430. // Rename file c:/windows/php.ini (we don't want it)
  431. //----------------------------------------------
  432. if FileExists ('c:/windows/php.ini') then
  433. begin
  434. if MsgBox('A previous c:/windows/php.ini file has been detected in your Windows directory. Do you want DoliWamp to rename it to php_old.ini to avoid conflicts ?',mbConfirmation,MB_YESNO) = IDYES then
  435. begin
  436. RenameFile('c:/windows/php.ini','c:/windows/php_old.ini');
  437. end;
  438. end;
  439. if FileExists ('c:/winnt/php.ini') then
  440. begin
  441. if MsgBox('A previous c:/winnt/php.ini file has been detected in your Windows directory. Do you want DoliWamp to rename it to php_old.ini to avoid conflicts ?',mbConfirmation,MB_YESNO) = IDYES then
  442. begin
  443. RenameFile('c:/winnt/php.ini','c:/winnt/php_old.ini');
  444. end;
  445. end;
  446. //----------------------------------------------
  447. // Create rundoliwamp.bat, rundolihelp.bat and rundoliadmin.bat (if not exists)
  448. //----------------------------------------------
  449. destFile := pathWithSlashes+'/rundoliwamp.bat';
  450. srcFile := pathWithSlashes+'/rundoliwamp.bat.install';
  451. destFileH := pathWithSlashes+'/rundolihelp.bat';
  452. srcFileH := pathWithSlashes+'/rundolihelp.bat.install';
  453. destFileA := pathWithSlashes+'/rundoliadmin.bat';
  454. srcFileA := pathWithSlashes+'/rundoliadmin.bat.install';
  455. if (not FileExists (destFile) or not FileExists (destFileH) or not FileExists (destFileA))
  456. and (FileExists(srcFile) and FileExists(srcFileH) and FileExists(srcFileA)) then
  457. begin
  458. //navigateur
  459. browser := 'iexplore.exe';
  460. if FileExists (pfPath+'/Mozilla Firefox/firefox.exe') then
  461. begin
  462. if MsgBox(CustomMessage('FirefoxDetected'),mbConfirmation,MB_YESNO) = IDYES then
  463. begin
  464. browser := pfPath+'/Mozilla Firefox/firefox.exe';
  465. end;
  466. end;
  467. if browser = 'iexplore.exe' then
  468. begin
  469. if FileExists (pfPath+'/Internet Explorer/iexplore.exe') then
  470. begin
  471. GetOpenFileName(CustomMessage('ChooseDefaultBrowser'), browser, pfPath+'/Internet Explorer','exe files (*.exe)|*.exe|All files (*.*)|*.*' ,'exe');
  472. end
  473. else
  474. begin
  475. GetOpenFileName(CustomMessage('ChooseDefaultBrowser'), browser, winPath,'exe files (*.exe)|*.exe|All files (*.*)|*.*' ,'exe');
  476. end;
  477. end;
  478. LoadStringFromFile (srcFile, srcContents);
  479. StringChangeEx (srcContents, 'WAMPBROWSER', browser, True);
  480. StringChangeEx (srcContents, 'WAMPAPACHEPORT', myporta, True);
  481. StringChangeEx (srcContents, 'WAMPAPACHEPSSL', myportas, True);
  482. SaveStringToFile(destFile,srcContents, False);
  483. LoadStringFromFile (srcFileH, srcContents);
  484. StringChangeEx (srcContents, 'WAMPBROWSER', browser, True);
  485. StringChangeEx (srcContents, 'WAMPAPACHEPORT', myporta, True);
  486. StringChangeEx (srcContents, 'WAMPAPACHEPSSL', myportas, True);
  487. SaveStringToFile(destFileH,srcContents, False);
  488. LoadStringFromFile (srcFileA, srcContents);
  489. StringChangeEx (srcContents, 'WAMPBROWSER', browser, True);
  490. StringChangeEx (srcContents, 'WAMPAPACHEPORT', myporta, True);
  491. StringChangeEx (srcContents, 'WAMPAPACHEPSSL', myportas, True);
  492. SaveStringToFile(destFileA,srcContents, False);
  493. end
  494. if MsgBox(CustomMessage('DoliWampWillStartApacheMysql'),mbConfirmation,MB_YESNO) = IDYES then
  495. begin
  496. //----------------------------------------------
  497. // Create file alias phpmyadmin (always)
  498. //----------------------------------------------
  499. destFile := pathWithSlashes+'/alias/phpmyadmin.conf';
  500. srcFile := pathWithSlashes+'/alias/phpmyadmin.conf.install';
  501. if FileExists(srcFile) then
  502. begin
  503. LoadStringFromFile (srcFile, srcContents);
  504. //installDir et version de phpmyadmin
  505. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  506. StringChangeEx (srcContents, 'WAMPPHPMYADMINVERSION', phpmyadminVersion, True);
  507. SaveStringToFile(destFile,srcContents, False);
  508. end
  509. DeleteFile(srcFile);
  510. //----------------------------------------------
  511. // Create file alias dolibarr (if not exists)
  512. //----------------------------------------------
  513. destFile := pathWithSlashes+'/alias/dolibarr.conf';
  514. srcFile := pathWithSlashes+'/alias/dolibarr.conf.install';
  515. if not FileExists (destFile) and FileExists(srcFile) then
  516. begin
  517. LoadStringFromFile (srcFile, srcContents);
  518. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  519. StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True);
  520. SaveStringToFile(destFile, srcContents, False);
  521. end
  522. DeleteFile(srcFile);
  523. //----------------------------------------------
  524. // Create file configuration for phpmyadmin (if not exists)
  525. //----------------------------------------------
  526. destFile := pathWithSlashes+'/apps/phpmyadmin'+phpmyadminVersion+'/config.inc.php';
  527. srcFile := pathWithSlashes+'/apps/phpmyadmin'+phpmyadminVersion+'/config.inc.php.install';
  528. if not FileExists (destFile) and FileExists (srcFile) then
  529. begin
  530. // sinon on prends le fichier par defaut
  531. LoadStringFromFile (srcFile, srcContents);
  532. StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True);
  533. StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True);
  534. SaveStringToFile(destFile,srcContents, False);
  535. end
  536. //----------------------------------------------
  537. // Create file httpd.conf (if not exists)
  538. //----------------------------------------------
  539. destFile := pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/conf/httpd.conf';
  540. srcFile := pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/conf/httpd.conf.install';
  541. if not FileExists (destFile) and FileExists (srcFile) then
  542. begin
  543. LoadStringFromFile (srcFile, srcContents);
  544. //installDir et version de php
  545. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  546. StringChangeEx (srcContents, 'WAMPPHPVERSION', phpVersion, True);
  547. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  548. StringChangeEx (srcContents, 'WAMPAPACHEPORT', myporta, True);
  549. StringChangeEx (srcContents, 'WAMPAPACHEPSSL', myportas, True);
  550. SaveStringToFile(destFile,srcContents, False);
  551. end
  552. //----------------------------------------------
  553. // Create file my.ini (if not exists)
  554. //----------------------------------------------
  555. destFile := pathWithSlashes+'/bin/mysql/mysql'+mysqlVersion+'/my.ini';
  556. srcFile := pathWithSlashes+'/bin/mysql/mysql'+mysqlVersion+'/my.ini.install';
  557. if not FileExists (destFile) then
  558. begin
  559. LoadStringFromFile (srcFile, srcContents);
  560. //installDir et version de php
  561. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  562. StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True);
  563. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', myport, True);
  564. SaveStringToFile(destFile,srcContents, False);
  565. end
  566. //----------------------------------------------
  567. // Create file index.php (always but archive if exists)
  568. //----------------------------------------------
  569. destFile := pathWithSlashes+'/www/index.php';
  570. srcFile := pathWithSlashes+'/www/index.php.install';
  571. if not FileExists (destFile) then
  572. begin
  573. LoadStringFromFile (srcFile, srcContents);
  574. StringChangeEx (srcContents, 'WAMPPHPVERSION', phpVersion, True);
  575. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  576. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  577. StringChangeEx (srcContents, 'WAMPAPACHEPORT', myporta, True);
  578. StringChangeEx (srcContents, 'WAMPAPACHEPSSL', myportas, True);
  579. SaveStringToFile(destFile, srcContents, False);
  580. end
  581. else
  582. begin
  583. RenameFile(destFile, destFile+'.old');
  584. LoadStringFromFile (srcFile, srcContents);
  585. StringChangeEx (srcContents, 'WAMPPHPVERSION', phpVersion, True);
  586. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  587. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  588. StringChangeEx (srcContents, 'WAMPAPACHEPORT', myporta, True);
  589. StringChangeEx (srcContents, 'WAMPAPACHEPSSL', myportas, True);
  590. SaveStringToFile(destFile, srcContents, False);
  591. end
  592. //----------------------------------------------
  593. // Create file dolibarr parametres predefinis install web (if not exists)
  594. //----------------------------------------------
  595. destFile := pathWithSlashes+'/www/dolibarr/htdocs/install/install.forced.php';
  596. srcFile := pathWithSlashes+'/www/dolibarr/htdocs/install/install.forced.php.install';
  597. if not FileExists (destFile) and FileExists (srcFile) then
  598. begin
  599. LoadStringFromFile (srcFile, srcContents);
  600. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  601. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  602. StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True);
  603. StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True);
  604. SaveStringToFile(destFile,srcContents, False);
  605. end
  606. //----------------------------------------------
  607. // Create file install_services.bat (always)
  608. //----------------------------------------------
  609. destFile := pathWithSlashes+'/install_services.bat';
  610. srcFile := pathWithSlashes+'/install_services.bat.install';
  611. if FileExists(srcFile) then
  612. begin
  613. LoadStringFromFile (srcFile, srcContents);
  614. //version de apache et mysql
  615. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  616. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  617. SaveStringToFile(destFile,srcContents, False);
  618. end
  619. //----------------------------------------------
  620. // Create file install_services_auto.bat (always)
  621. //----------------------------------------------
  622. destFile := pathWithSlashes+'/install_services_auto.bat';
  623. srcFile := pathWithSlashes+'/install_services_auto.bat.install';
  624. if FileExists (srcFile) then
  625. begin
  626. LoadStringFromFile (srcFile, srcContents);
  627. //version de apache et mysql
  628. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  629. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  630. SaveStringToFile(destFile,srcContents, False);
  631. end
  632. //----------------------------------------------
  633. // Create file uninstall_services.bat (always)
  634. //----------------------------------------------
  635. destFile := pathWithSlashes+'/uninstall_services.bat';
  636. srcFile := pathWithSlashes+'/uninstall_services.bat.install';
  637. if FileExists (srcFile) then
  638. begin
  639. LoadStringFromFile (srcFile, srcContents);
  640. //version de apache et mysql
  641. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  642. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  643. SaveStringToFile(destFile,srcContents, False);
  644. end
  645. //----------------------------------------------
  646. // Create file mysqlinitpassword.bat (always)
  647. //----------------------------------------------
  648. destFile := pathWithSlashes+'/mysqlinitpassword.bat';
  649. srcFile := pathWithSlashes+'/mysqlinitpassword.bat.install';
  650. if FileExists (srcFile) then
  651. begin
  652. LoadStringFromFile (srcFile, srcContents);
  653. //version de apache et mysql
  654. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  655. StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True);
  656. StringChangeEx (srcContents, 'WAMPMYSQLNEWPASSWORD', mypass, True);
  657. SaveStringToFile(destFile,srcContents, False);
  658. end
  659. //----------------------------------------------
  660. // Create file mysqltestinstall.bat (always)
  661. //----------------------------------------------
  662. destFile := pathWithSlashes+'/mysqltestinstall.bat';
  663. srcFile := pathWithSlashes+'/mysqltestinstall.bat.install';
  664. if FileExists (srcFile) then
  665. begin
  666. LoadStringFromFile (srcFile, srcContents);
  667. //version de apache et mysql
  668. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  669. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  670. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  671. StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True);
  672. SaveStringToFile(destFile,srcContents, False);
  673. end
  674. //----------------------------------------------
  675. // Create file startdoliwamp_manual_donotuse.bat (always)
  676. //----------------------------------------------
  677. destFile := pathWithSlashes+'/startdoliwamp_manual_donotuse.bat';
  678. srcFile := pathWithSlashes+'/startdoliwamp_manual_donotuse.bat.install';
  679. if FileExists (srcFile) then
  680. begin
  681. LoadStringFromFile (srcFile, srcContents);
  682. //version de apache et mysql
  683. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  684. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  685. StringChangeEx (srcContents, 'WAMPMYSQLVERSION', mysqlVersion, True);
  686. StringChangeEx (srcContents, 'WAMPMYSQLPORT', myport, True);
  687. SaveStringToFile(destFile,srcContents, False);
  688. end
  689. //----------------------------------------------
  690. // Create file builddemosslfiles.bat (always)
  691. //----------------------------------------------
  692. destFile := pathWithSlashes+'/builddemosslfiles.bat';
  693. srcFile := pathWithSlashes+'/builddemosslfiles.bat.install';
  694. if FileExists (srcFile) then
  695. begin
  696. LoadStringFromFile (srcFile, srcContents);
  697. //version de apache et mysql
  698. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  699. StringChangeEx (srcContents, 'WAMPAPACHEVERSION', apacheVersion, True);
  700. SaveStringToFile(destFile,srcContents, False);
  701. end
  702. //----------------------------------------------
  703. // Create file php.ini in php (if not exists)
  704. //----------------------------------------------
  705. destFile := pathWithSlashes+'/bin/php/php'+phpVersion+'/php.ini';
  706. srcFile := pathWithSlashes+'/bin/php/php'+phpVersion+'/php.ini.install';
  707. if not FileExists (destFile) and FileExists(srcFile) then
  708. begin
  709. LoadStringFromFile (srcFile, srcContents);
  710. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  711. StringChangeEx (srcContents, 'WAMPSMTP', mysmtp, True);
  712. StringChangeEx (srcContents, 'WAMPPHPVERSION', phpVersion, True);
  713. SaveStringToFile(destFile,srcContents, False);
  714. end
  715. //----------------------------------------------
  716. // Create file php.ini in apache (if not exists)
  717. //----------------------------------------------
  718. destFile := pathWithSlashes+'/bin/apache/apache'+apacheVersion+'/bin/php.ini';
  719. srcFile := pathWithSlashes+'/bin/php/php'+phpVersion+'/php.ini.install';
  720. if not FileExists (destFile) and FileExists(srcFile) then
  721. begin
  722. LoadStringFromFile (srcFile, srcContents);
  723. StringChangeEx (srcContents, 'WAMPROOT', pathWithSlashes, True);
  724. StringChangeEx (srcContents, 'WAMPSMTP', mysmtp, True);
  725. StringChangeEx (srcContents, 'WAMPPHPVERSION', phpVersion, True);
  726. SaveStringToFile(destFile,srcContents, False);
  727. end
  728. // Uninstall and Install services
  729. batFile := path+'\uninstall_services.bat';
  730. Exec(batFile, '',path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  731. batFile := path+'\install_services.bat';
  732. Exec(batFile, '',path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  733. // Start services
  734. batFile := path+'\startdoliwamp.bat';
  735. Exec(batFile, '',path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  736. //MsgBox(myResult,mbInformation,MB_OK);
  737. // Change mysql password (works only if not yet defined)
  738. batFile := path+'\mysqlinitpassword.bat';
  739. Exec(batFile, '',path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  740. // Remove dangerous files
  741. batFile := path+'\removefiles.bat';
  742. Exec(batFile, '',path+'\', SW_HIDE, ewWaitUntilTerminated, myResult);
  743. // Save parameters to registry
  744. RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp', 'smtpServer', mysmtp);
  745. RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp', 'apachePort', myporta);
  746. RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp', 'apachePSSL', myportas);
  747. RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp', 'mysqlPort', myport);
  748. RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp', 'newPassword', mypass);
  749. res := True;
  750. end
  751. else
  752. begin
  753. // MsgBox('Apache and Mysql installation has been canceled. Please select parameters to start their installation.',mbInformation,MB_OK)
  754. res := False;
  755. end
  756. end
  757. else
  758. begin
  759. //MsgBox('Selected values seems to be already used. Please choose other values.',mbInformation,MB_OK);
  760. res := False;
  761. end
  762. end
  763. Result := res;
  764. end;
  765. //-----------------------------------------------
  766. //procedure launched by the end of the installation, it deletes the installation files
  767. procedure DeinitializeSetup();
  768. begin
  769. // DeleteFile(path+'\install_services.bat');
  770. // DeleteFile(path+'\install_services_auto.bat');
  771. end;
  772. //-----------------------------------------------
  773. //procedure launched at beginning of the uninstallation
  774. function InitializeUninstall(): Boolean;
  775. begin
  776. Result := RegDeleteValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp','smtpServer');
  777. Result := RegDeleteValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp','apachePort');
  778. Result := RegDeleteValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp','mysqlPort');
  779. Result := RegDeleteValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp','newPassword');
  780. Result := RegDeleteKeyIncludingSubkeys(HKEY_LOCAL_MACHINE, 'SOFTWARE\NLTechno\DoliWamp');
  781. Result := True;
  782. end;
  783. //-----------------------------------------------
  784. //procedure launched by the end of the uninstallation
  785. procedure DeinitializeUninstall();
  786. begin
  787. path := ExpandConstant('{app}');
  788. winPath := ExpandConstant('{win}');
  789. pathWithSlashes := path;
  790. StringChange (pathWithSlashes, '\','/');
  791. MsgBox(FmtMessage(CustomMessage('ProgramHasBeenRemoved'),[path]),mbInformation,MB_OK);
  792. end;
  793. [Run]
  794. ; Launch Dolibarr in browser. This is run after Wizard because of postinstall flag
  795. Filename: "{app}\rundoliwamp.bat"; Description: {cm:LaunchNow}; Flags: shellexec postinstall skipifsilent runhidden
  796. [UninstallDelete]
  797. Type: files; Name: "{app}\*.*"
  798. Type: files; Name: "{app}\bin\mysql\mysql5.6.17\*.*"
  799. Type: filesandordirs; Name: "{app}\alias"
  800. Type: filesandordirs; Name: "{app}\apps"
  801. Type: filesandordirs; Name: "{app}\bin\apache"
  802. Type: filesandordirs; Name: "{app}\bin\php"
  803. Type: filesandordirs; Name: "{app}\help"
  804. Type: filesandordirs; Name: "{app}\lang"
  805. Type: filesandordirs; Name: "{app}\logs"
  806. Type: filesandordirs; Name: "{app}\scripts"
  807. Type: filesandordirs; Name: "{app}\tmp"
  808. Type: filesandordirs; Name: "{app}\www\dolibarr"
  809. [UninstallRun]
  810. Filename: "{app}\uninstall_services.bat"; Flags: runhidden