53 if (isset($args[0]) && !empty($args[0]) && isset($args[1]) && !empty($args[1])) {
54 $this->pathsToScan = array();
55 $this->version = $args[1];
61 $this->changePort =
true;
63 foreach ($folderList as $folder) {
64 $this->pathsToScan[] = array(
65 'path' =>
$bearsamppBins->getApache()->getRootPath() .
'/' . $folder,
66 'includes' => array(
'.ini',
'.conf'),
74 $this->changePort =
false;
76 foreach ($folderList as $folder) {
77 $this->pathsToScan[] = array(
79 'includes' => array(
'.php',
'.bat',
'.ini',
'.reg',
'.inc'),
87 $this->changePort =
true;
89 foreach ($folderList as $folder) {
90 $this->pathsToScan[] = array(
91 'path' =>
$bearsamppBins->getMysql()->getRootPath() .
'/' . $folder,
92 'includes' => array(
'my.ini'),
98 $this->currentVersion =
$bearsamppBins->getMariadb()->getVersion();
100 $this->changePort =
true;
102 foreach ($folderList as $folder) {
103 $this->pathsToScan[] = array(
104 'path' =>
$bearsamppBins->getMariadb()->getRootPath() .
'/' . $folder,
105 'includes' => array(
'my.ini'),
109 } elseif ($args[0] ==
$bearsamppBins->getPostgresql()->getName()) {
111 $this->currentVersion =
$bearsamppBins->getPostgresql()->getVersion();
113 $this->changePort =
true;
115 foreach ($folderList as $folder) {
116 $this->pathsToScan[] = array(
117 'path' =>
$bearsamppBins->getPostgresql()->getRootPath() .
'/' . $folder,
118 'includes' => array(
'.conf',
'.bat'),
124 $this->currentVersion =
$bearsamppBins->getNodejs()->getVersion();
125 $this->service =
null;
126 $this->changePort =
false;
128 foreach ($folderList as $folder) {
129 $this->pathsToScan[] = array(
130 'path' =>
$bearsamppBins->getNodejs()->getRootPath() .
'/' . $folder .
'/etc',
131 'includes' => array(
'npmrc'),
134 $this->pathsToScan[] = array(
135 'path' =>
$bearsamppBins->getNodejs()->getRootPath() .
'/' . $folder .
'/node_modules/npm',
136 'includes' => array(
'npmrc'),
140 } elseif ($args[0] ==
$bearsamppBins->getMemcached()->getName()) {
142 $this->currentVersion =
$bearsamppBins->getMemcached()->getVersion();
144 $this->changePort =
true;
147 $this->currentVersion =
$bearsamppBins->getMailpit()->getVersion();
149 $this->changePort =
false;
151 foreach ($folderList as $folder) {
152 $this->pathsToScan[] = array(
153 'path' =>
$bearsamppBins->getMailpit()->getRootPath() .
'/' . $folder,
154 'includes' => array(
'.conf'),
160 $this->currentVersion =
$bearsamppBins->getXlight()->getVersion();
162 $this->changePort =
true;
164 foreach ($folderList as $folder) {
165 $this->pathsToScan[] = array(
166 'path' =>
$bearsamppBins->getXlight()->getRootPath() .
'/' . $folder,
167 'includes' => array(
'.conf, ftpd.hosts, ftpd.option, ftpd.password, ftpd.rules, ftpd.users, .ini'),
176 $this->bearsamppSplash =
new Splash();
177 $this->bearsamppSplash->init(
179 self::GAUGE_SERVICES * count(
$bearsamppBins->getServices()) + self::GAUGE_OTHERS,
183 $bearsamppWinbinder->setHandler($this->bearsamppSplash->getWbWindow(), $this,
'processWindow', 1000);
184 $bearsamppWinbinder->mainLoop();
185 $bearsamppWinbinder->reset();
202 if ($this->version == $this->currentVersion) {
204 $bearsamppWinbinder->destroyWindow($window);
208 $this->bearsamppSplash->incrProgressBar();
209 if (!empty($this->pathsToScan)) {
214 $this->bearsamppSplash->incrProgressBar();
215 if ($this->bin->switchVersion($this->version,
true) ===
false) {
216 $this->bearsamppSplash->incrProgressBar(self::GAUGE_SERVICES * count(
$bearsamppBins->getServices()) + self::GAUGE_OTHERS);
217 $bearsamppWinbinder->destroyWindow($window);
221 if ($this->service !=
null) {
224 $this->bearsamppSplash->incrProgressBar();
225 $this->service->stop();
229 $this->bearsamppSplash->incrProgressBar();
234 $this->bearsamppSplash->incrProgressBar();
239 $this->bearsamppSplash->incrProgressBar();
244 if ($this->service !=
null) {
246 if ($this->bin->getName() ==
$bearsamppBins->getPhp()->getName()) {
248 Log::trace(
"Refreshed service reference from reloaded Apache bin (for PHP)");
251 if ($freshBin !==
null) {
252 $this->service = $freshBin->getService();
253 Log::trace(
"Refreshed service reference from reloaded " . $this->bin->getName() .
" bin");
259 if ($this->changePort) {
260 $this->bin->reload();
261 $this->bin->changePort($this->bin->getPort());
265 if ($this->service !=
null) {
268 $this->bearsamppSplash->incrProgressBar();
269 $this->service->start();
271 $this->bearsamppSplash->incrProgressBar();
274 $this->bearsamppSplash->incrProgressBar(self::GAUGE_SERVICES * count(
$bearsamppBins->getServices()) + 1);
285 'Starting registry adjustment for key: %s | Current value: %s',
290 $this->bearsamppSplash->setTextLoading(sprintf(
295 $this->bearsamppSplash->incrProgressBar(2);
300 'Registry update completed | Key: %s | New value: %s | Previous value: %s',
311 Log::trace(
'Version switch complete - service restarted with new version');
312 $this->bearsamppSplash->incrProgressBar();
316 if ($remainingServicesCount > 0) {
317 $this->bearsamppSplash->incrProgressBar($remainingServicesCount);
320 Log::trace(
'Version switch process completed successfully');
323 $bearsamppWinbinder->messageBoxInfo(
329 $bearsamppWinbinder->destroyWindow($window);
343 if ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getApache()->getName()) {
344 $configSection = self::CONFIG_SECTION_APACHE;
346 } elseif ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getPhp()->getName()) {
347 $configSection = self::CONFIG_SECTION_PHP;
349 } elseif ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getMysql()->getName()) {
350 $configSection = self::CONFIG_SECTION_MYSQL;
352 } elseif ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getMariadb()->getName()) {
353 $configSection = self::CONFIG_SECTION_MARIADB;
355 } elseif ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getPostgresql()->getName()) {
356 $configSection = self::CONFIG_SECTION_POSTGRESQL;
358 } elseif ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getNodejs()->getName()) {
359 $configSection = self::CONFIG_SECTION_NODEJS;
361 } elseif ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getMemcached()->getName()) {
362 $configSection = self::CONFIG_SECTION_MEMCACHED;
364 } elseif ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getMailpit()->getName()) {
365 $configSection = self::CONFIG_SECTION_MAILPIT;
367 } elseif ($this->bin->getName() == $GLOBALS[
'bearsamppBins']->getXlight()->getName()) {
368 $configSection = self::CONFIG_SECTION_XLIGHT;
373 if (!empty($configSection)) {
379 if (class_exists(
'TrayMenu')) {
380 $trayMenu = TrayMenu::getInstance();
381 if (method_exists($trayMenu,
'updateSectionVersion')) {
382 $trayMenu->updateSectionVersion(
383 strtoupper($configSection),