Browse Source

Commad line upgrade enhancements (#6955)

* Add new English language phrases for cli upgrade menu

* include a software name as a const for cli upgrade menu

* add it repos in app folder, internationalizations, and descriptions

* bug fix when response_source_update is empty change back to origin dir

* change original 'menu' to 'menus'. Allow calling menu from upgrade.php

* Update upgrade_menu.php
frytimo 1 năm trước cách đây
mục cha
commit
12f0d9b4a9

+ 125 - 0
core/upgrade/app_languages.php

@@ -1150,4 +1150,129 @@ $text['button-upgrade_execute']['zh-cn'] = "执行";
 $text['button-upgrade_execute']['ja-jp'] = "実行する";
 $text['button-upgrade_execute']['ko-kr'] = "실행하다";
 
+$text['label-all_of_the_above']['en-us'] = "All of the Above";
+$text['label-all_of_the_above']['en-gb'] = "All of the Above";
+$text['label-all_of_the_above']['ar-eg'] = "";
+$text['label-all_of_the_above']['de-at'] = "";
+$text['label-all_of_the_above']['de-ch'] = "";
+$text['label-all_of_the_above']['de-de'] = "";
+$text['label-all_of_the_above']['el-gr'] = "";
+$text['label-all_of_the_above']['es-cl'] = "";
+$text['label-all_of_the_above']['es-mx'] = "";
+$text['label-all_of_the_above']['fr-ca'] = "";
+$text['label-all_of_the_above']['fr-fr'] = "";
+$text['label-all_of_the_above']['he-il'] = "";
+$text['label-all_of_the_above']['it-it'] = "";
+$text['label-all_of_the_above']['nl-nl'] = "";
+$text['label-all_of_the_above']['pl-pl'] = "";
+$text['label-all_of_the_above']['pt-br'] = "";
+$text['label-all_of_the_above']['pt-pt'] = "";
+$text['label-all_of_the_above']['ro-ro'] = "";
+$text['label-all_of_the_above']['ru-ru'] = "";
+$text['label-all_of_the_above']['sv-se'] = "";
+$text['label-all_of_the_above']['uk-ua'] = "";
+$text['label-all_of_the_above']['zh-cn'] = "";
+$text['label-all_of_the_above']['ja-jp'] = "";
+$text['label-all_of_the_above']['ko-kr'] = "";
+
+$text['description-all_of_the_above']['en-us'] = "Performs an upgrade using options 1a, 2, 2b, 3, 4, and 5 in succession.";
+$text['description-all_of_the_above']['en-gb'] = "Performs an upgrade using options 1a, 2, 2b, 3, 4, and 5 in succession.";
+$text['description-all_of_the_above']['ar-eg'] = "";
+$text['description-all_of_the_above']['de-at'] = "";
+$text['description-all_of_the_above']['de-ch'] = "";
+$text['description-all_of_the_above']['de-de'] = "";
+$text['description-all_of_the_above']['el-gr'] = "";
+$text['description-all_of_the_above']['es-cl'] = "";
+$text['description-all_of_the_above']['es-mx'] = "";
+$text['description-all_of_the_above']['fr-ca'] = "";
+$text['description-all_of_the_above']['fr-fr'] = "";
+$text['description-all_of_the_above']['he-il'] = "";
+$text['description-all_of_the_above']['it-it'] = "";
+$text['description-all_of_the_above']['nl-nl'] = "";
+$text['description-all_of_the_above']['pl-pl'] = "";
+$text['description-all_of_the_above']['pt-br'] = "";
+$text['description-all_of_the_above']['pt-pt'] = "";
+$text['description-all_of_the_above']['ro-ro'] = "";
+$text['description-all_of_the_above']['ru-ru'] = "";
+$text['description-all_of_the_above']['sv-se'] = "";
+$text['description-all_of_the_above']['uk-ua'] = "";
+$text['description-all_of_the_above']['zh-cn'] = "";
+$text['description-all_of_the_above']['ja-jp'] = "";
+$text['description-all_of_the_above']['ko-kr'] = "";
+
+$text['label-update_external_repositories']['en-us'] = "Update External Repositories";
+$text['label-update_external_repositories']['en-gb'] = "Update External Repositories";
+$text['label-update_external_repositories']['ar-eg'] = "";
+$text['label-update_external_repositories']['de-at'] = "";
+$text['label-update_external_repositories']['de-ch'] = "";
+$text['label-update_external_repositories']['de-de'] = "";
+$text['label-update_external_repositories']['el-gr'] = "";
+$text['label-update_external_repositories']['es-cl'] = "";
+$text['label-update_external_repositories']['es-mx'] = "";
+$text['label-update_external_repositories']['fr-ca'] = "";
+$text['label-update_external_repositories']['fr-fr'] = "";
+$text['label-update_external_repositories']['he-il'] = "";
+$text['label-update_external_repositories']['it-it'] = "";
+$text['label-update_external_repositories']['nl-nl'] = "";
+$text['label-update_external_repositories']['pl-pl'] = "";
+$text['label-update_external_repositories']['pt-br'] = "";
+$text['label-update_external_repositories']['pt-pt'] = "";
+$text['label-update_external_repositories']['ro-ro'] = "";
+$text['label-update_external_repositories']['ru-ru'] = "";
+$text['label-update_external_repositories']['sv-se'] = "";
+$text['label-update_external_repositories']['uk-ua'] = "";
+$text['label-update_external_repositories']['zh-cn'] = "";
+$text['label-update_external_repositories']['ja-jp'] = "";
+$text['label-update_external_repositories']['ko-kr'] = "";
+
+$text['description-repositories']['en-us'] = "Updates all external repositories found in 'Apps' folder";
+$text['description-repositories']['en-gb'] = "Updates all external repositories found in 'Apps' folder";
+$text['description-repositories']['ar-eg'] = "";
+$text['description-repositories']['de-at'] = "";
+$text['description-repositories']['de-ch'] = "";
+$text['description-repositories']['de-de'] = "";
+$text['description-repositories']['el-gr'] = "";
+$text['description-repositories']['es-cl'] = "";
+$text['description-repositories']['es-mx'] = "";
+$text['description-repositories']['fr-ca'] = "";
+$text['description-repositories']['fr-fr'] = "";
+$text['description-repositories']['he-il'] = "";
+$text['description-repositories']['it-it'] = "";
+$text['description-repositories']['nl-nl'] = "";
+$text['description-repositories']['pl-pl'] = "";
+$text['description-repositories']['pt-br'] = "";
+$text['description-repositories']['pt-pt'] = "";
+$text['description-repositories']['ro-ro'] = "";
+$text['description-repositories']['ru-ru'] = "";
+$text['description-repositories']['sv-se'] = "";
+$text['description-repositories']['uk-ua'] = "";
+$text['description-repositories']['zh-cn'] = "";
+$text['description-repositories']['ja-jp'] = "";
+$text['description-repositories']['ko-kr'] = "";
+
+$text['title-cli_upgrade']['en-us'] = "UPGRADE MENU";
+$text['title-cli_upgrade']['en-gb'] = "UPGRADE MENU";
+$text['title-cli_upgrade']['ar-eg'] = "";
+$text['title-cli_upgrade']['de-at'] = "";
+$text['title-cli_upgrade']['de-ch'] = "";
+$text['title-cli_upgrade']['de-de'] = "";
+$text['title-cli_upgrade']['el-gr'] = "";
+$text['title-cli_upgrade']['es-cl'] = "";
+$text['title-cli_upgrade']['es-mx'] = "";
+$text['title-cli_upgrade']['fr-ca'] = "";
+$text['title-cli_upgrade']['fr-fr'] = "";
+$text['title-cli_upgrade']['he-il'] = "";
+$text['title-cli_upgrade']['it-it'] = "";
+$text['title-cli_upgrade']['nl-nl'] = "";
+$text['title-cli_upgrade']['pl-pl'] = "";
+$text['title-cli_upgrade']['pt-br'] = "";
+$text['title-cli_upgrade']['pt-pt'] = "";
+$text['title-cli_upgrade']['ro-ro'] = "";
+$text['title-cli_upgrade']['ru-ru'] = "";
+$text['title-cli_upgrade']['sv-se'] = "";
+$text['title-cli_upgrade']['uk-ua'] = "";
+$text['title-cli_upgrade']['zh-cn'] = "";
+$text['title-cli_upgrade']['ja-jp'] = "";
+$text['title-cli_upgrade']['ko-kr'] = "";
+
 ?>

+ 6 - 3
core/upgrade/upgrade.php

@@ -151,8 +151,11 @@
 		}
 	}
 
-//show the upgrade type
-	//echo $upgrade_type."\n";
+//check for upgrade menu option first
+	if ($upgrade_type == 'menu') {
+		require __DIR__ . '/upgrade_menu.php';
+		exit();
+	}
 
 //get the version of the software
 	if ($upgrade_type == 'version') {
@@ -180,7 +183,7 @@
 	}
 
 //restore the default menu
-	if ($upgrade_type == 'menu') {
+	if ($upgrade_type == 'menus') {
 
 		//get the menu uuid and language
 		$sql = "select menu_uuid, menu_language from v_menus ";

+ 75 - 18
core/upgrade/upgrade_menu.php

@@ -32,35 +32,72 @@ defined('STDIN') or die('Unauthorized');
 //include files
 require_once dirname(__DIR__, 2) . "/resources/require.php";
 
+//create a database connection using default config
+$database = new database();
+
+//load global defaults
+$settings = new settings(['database' => $database]);
+
+//get the language code from global defaults
+$language_code = $settings->get('domain', 'language');
+
+//get the software name
+$software_name = $settings->get('theme', 'title');
+
+//set the scope for text to be used in any function
+global $text, $display_type;
+
+//add multi-lingual support
+$language = new text;
+$text = $language->get($language_code, 'core/upgrade');
+
+//output to text type instead of html
+$display_type = 'text';
+
+//run
 show_upgrade_menu();
 
 function show_upgrade_menu() {
-//		error_reporting(E_ALL);
+	global $text;
+	//error_reporting(E_ALL);
+	$line = str_repeat('-', strlen($text['title-cli_upgrade']) + 2);
 	while (true) {
 		echo "\n";
-		echo "+------------------+\n";
-		echo "| Set Default Menu |\n";
-		echo "+------------------+\n";
+		echo "+{$line}+\n";
+		echo "| {$text['title-cli_upgrade']} |\n";
+		echo "+{$line}+\n";
+		echo "version: "; show_software_version();
 		echo "\n";
-		echo "1) Update FusionPBX\n";
-		echo "2) Schema\n";
-		echo "3) App Defaults\n";
-		echo "4) Menus\n";
-		echo "5) Permissions\n";
-		echo "6) All of the above\n";
-		echo "7) Validate schema data types\n";
-		echo "8) Show current version\n";
-		echo "9) Exit\n";
+		echo "1) {$text['label-upgrade_source']} - {$text['description-update_all_source_files']}\n";
+		echo "  1a) " . $software_name . " - Update Main Software Only \n";
+		echo "  1b) {$text['label-update_external_repositories']} - {$text['description-repositories']}\n";
+		echo "2) {$text['label-schema']} - {$text['description-upgrade_schema']}\n";
+		echo "  2b) {$text['label-upgrade_data_types']} - {$text['description-upgrade_data_types']}\n";
+		echo "3) {$text['label-upgrade_apps']} - {$text['description-upgrade_apps']}\n";
+		echo "4) {$text['label-upgrade_menu']} - {$text['description-upgrade_menu']}\n";
+		echo "5) {$text['label-upgrade_permissions']} - {$text['description-upgrade_permissions']}\n";
+		echo "6) {$text['label-all_of_the_above']} - {$text['description-all_of_the_above']}\n";
+		echo "0) Exit\n";
 		echo "\n";
 		echo "Choice: ";
 		$choice = readline();
 		switch ($choice) {
 			case 1:
+				do_upgrade_code();
+				do_upgrade_code_submodules();
+				break;
+			case '1a':
 				do_upgrade_code();
 				break;
+			case '1b':
+				do_upgrade_code_submodules();
+				break;
 			case 2:
 				do_upgrade_schema();
 				break;
+			case '2b':
+				do_upgrade_schema(true);
+				break;
 			case 3:
 				do_upgrade_domains();
 				break;
@@ -77,13 +114,9 @@ function show_upgrade_menu() {
 				do_upgrade_permissions();
 				do_upgrade_menu();
 				break;
-			case 7:
-				do_upgrade_schema(true);
-				break;
 			case 8:
-				show_software_version();
 				break;
-			case 9:
+			case 0:
 				exit();
 		}
 	}
@@ -104,6 +137,30 @@ function do_upgrade_code() {
 	return $result;
 }
 
+function do_upgrade_code_submodules() {
+	global $text;
+	$updateable_repos = git_find_repos(dirname(__DIR__, 2)."/app");
+
+	$messages = [];
+	foreach ($updateable_repos as $repo => $apps) {
+		$git_result = git_pull($repo);
+		if ($git_result['result']) {
+			$messages[$repo] = $text['message-optional_apps_upgrade_source'] . " " . $git_result['message'];
+		}
+		else {
+			if (is_array($git_result['message'])) {
+				$message = "ERROR:\n" . implode(' ', $git_result['message']);
+			} else {
+				$message = $git_result['message'];
+			}
+			$messages[$repo] = $text['message-optional_apps_upgrade_source_failed'] . " " . $message;
+		}
+	}
+	foreach ($messages as $repo => $message) {
+		echo "$repo: $message\n";
+	}
+}
+
 //run all app_defaults.php files
 function do_upgrade_domains() {
 	require_once dirname(__DIR__, 2) . "/resources/classes/config.php";

+ 1 - 0
resources/functions.php

@@ -2362,6 +2362,7 @@ if (!function_exists('git_pull')) {
 		$update_status = false;
 
 		if (sizeof($response_source_update) == 0) {
+			chdir($cwd);
 			return array('result' => false, 'message' => null);
 		}