|
621 | 621 | } |
622 | 622 | } |
623 | 623 | } |
624 | | -print "--- Set end date of trial on new contract to the same value than the old contract.\n"; |
625 | | -$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat_extrafields set date_endfreeperiod = '".$db->idate($oldobject->array_options['options_date_endfreeperiod'])."'"; |
| 624 | +print "--- Update fields on new contract to the same value than the old contract (end date of trial, timezone).\n"; |
| 625 | +$sql = 'UPDATE '.MAIN_DB_PREFIX."contrat_extrafields"; |
| 626 | +$sql .= " SET date_endfreeperiod = '".$db->idate($oldobject->array_options['options_date_endfreeperiod'])."',"; |
| 627 | +$sql .= " timezone = '".$db->escape($oldobject->array_options['options_timezone'])."'"; |
626 | 628 | $sql .= " WHERE fk_object = ".((int) $newobject->id); |
627 | 629 | print $sql."\n"; |
628 | 630 | if ($mode == 'confirm' || $mode == 'confirmredirect' || $mode == 'confirmmaintenance') { |
629 | 631 | $resql = $db->query($sql); |
630 | 632 | if (!$resql) { |
631 | | - print 'Failed to set end date of trial period'."\n"; |
| 633 | + print 'Failed to set end date of trial period or timezone'."\n"; |
632 | 634 | exit(-1); |
633 | 635 | } |
634 | 636 | } |
|
722 | 724 | $param[] = "--exclude .settings"; |
723 | 725 | $param[] = "--exclude .project"; |
724 | 726 | $param[] = "--exclude *.pdf_preview.png"; |
725 | | -$param[] = "--exclude htdocs/conf/conf.php"; |
| 727 | +//$param[] = "--exclude htdocs/conf/conf.php"; // We want the conf file so we can also update param from this files later |
726 | 728 | $param[] = "--exclude glpi_config/config_db.php"; |
727 | 729 | $param[] = "--exclude htdocs/inc/downstream.php"; |
728 | 730 |
|
|
843 | 845 | // STEP 3 of synchro - We should update the value of $dolibarr_main_instance_unique_id if |
844 | 846 | // it was not done during creation of instance. |
845 | 847 | $value_of_dolibarr_main_instance_unique_id = ''; |
| 848 | +$value_of_dolibarr_main_cookie_cryptkey = ''; |
846 | 849 | if (file_exists($sourcedir.'/htdocs/conf/conf.php')) { |
847 | | - $tmpfilecontent = file_get_contents($sourcedir.'/htdocs/conf/conf.php'); |
| 850 | + chmod($sourcedir.'/htdocs/conf', 0700); |
| 851 | + dol_move($sourcedir.'/htdocs/conf/conf.php', $sourcedir.'/htdocs/conf/conf.php.mastermove', '0', 1, 0, 0); |
| 852 | + |
| 853 | + $tmpfilecontent = file_get_contents($sourcedir.'/htdocs/conf/conf.php.mastermove'); |
848 | 854 | foreach (explode("\n", $tmpfilecontent) as $line) { |
849 | 855 | if (strpos($line, '=') === false) continue; |
850 | 856 | if (preg_match('/^#/', $line)) continue; |
851 | 857 | if (preg_match('/^\//', $line)) continue; |
| 858 | + if (preg_match('/;/', $line)) continue; |
852 | 859 | [$key, $val] = explode('=', $line, 2); |
853 | | - if (trim($key) === $param) { |
| 860 | + if (trim($key) === '$dolibarr_main_instance_unique_id') { |
854 | 861 | $value_of_dolibarr_main_instance_unique_id = str_replace("'", "", trim($val)); |
855 | | - break; |
| 862 | + break; |
856 | 863 | } |
| 864 | + if (trim($key) === '$dolibarr_main_cookie_cryptkey') { |
| 865 | + $value_of_dolibarr_main_cookie_cryptkey = str_replace("'", "", trim($val)); |
| 866 | + } |
| 867 | + } |
| 868 | + |
| 869 | + if (empty($value_of_dolibarr_main_instance_unique_id)) { |
| 870 | + $value_of_dolibarr_main_instance_unique_id = $value_of_dolibarr_main_cookie_cryptkey; |
857 | 871 | } |
858 | 872 |
|
859 | 873 | if (empty($nointeractive)) { |
860 | 874 | print "Press ENTER to continue by running the ssh command to update the dolibarr_main_instance_unique_id on remote target host...\n"; |
861 | 875 | $input = trim(fgets(STDIN)); |
862 | 876 | } |
863 | 877 |
|
864 | | - $fullcommand = 'ssh '.$newlogin.'@'.$newserver.' "sed -i \'s/^param=.*/param='.$value_of_dolibarr_main_instance_unique_id.'/\' '.$targetdir.'/htdocs/conf/conf.php"'; |
| 878 | + $fullcommand = 'ssh -o StrictHostKeyChecking=accept-new '.$newlogin.'@'.$newserver; |
| 879 | + $fullcommand .= ' "'; |
| 880 | + $fullcommand .= 'chmod u+w '.$targetdir.'/htdocs/conf; '; |
| 881 | + if ($value_of_dolibarr_main_instance_unique_id) { |
| 882 | + $fullcommand .= 'sed -i \'s/^\$dolibarr_main_instance_unique_id=.*/\$dolibarr_main_instance_unique_id=\"'.$value_of_dolibarr_main_instance_unique_id.'\";/\' '.$targetdir.'/htdocs/conf/conf.php; '; |
| 883 | + } |
| 884 | + $fullcommand .= 'chmod u-w '.$targetdir.'/htdocs/conf; '; |
| 885 | + $fullcommand .= '"'; |
865 | 886 |
|
866 | 887 | print $fullcommand."\n"; |
867 | 888 |
|
868 | 889 | $outputfile = $conf->admin->dir_temp.'/outsshsed.tmp'; |
869 | | - $resultarray = $utils->executeCLI($fullcommand, $outputfile, 0); |
| 890 | + $resultarray = $utils->executeCLI($fullcommand, $outputfile, 0, null, 1); |
| 891 | + |
| 892 | + var_dump($resultarray); |
870 | 893 | } |
871 | 894 |
|
872 | 895 |
|
|
0 commit comments