Confirm if "version" corresponds with output of "pgpool_command" in config.php
authorNozomi Anzai <anzai@sraoss.co.jp>
Mon, 7 Dec 2015 10:25:12 +0000 (19:25 +0900)
committerNozomi Anzai <anzai@sraoss.co.jp>
Mon, 7 Dec 2015 10:25:12 +0000 (19:25 +0900)
command.php
config.php
lang/en.lang.php
lang/ja.lang.php
libs/plugins/function.custom_select.php
templates/config.tpl

index 42313c4c55b316b6d9dab2dbdddc4136aee367c6..fa884326b72b8cbc7bde19156705ffbdce585a30 100644 (file)
@@ -112,7 +112,6 @@ function execPcp($command, $extra_args = array())
         case 'PCP_START_PGPOOL':
             $args = _setStartArgs();
             $cmd = _PGPOOL2_COMMAND . $args;
-            pr($cmd);
             $ret = exec($cmd, $output, $return_var);
             if ($return_var == 0) {
                 return array($pcpStatus[$return_var] => $output);
index bd8dfd7b4746f02b99d57b771d0f4be9599b3d2c..9f484b76b9fd7f09a3bcb0b9f5d01d7ecd3b62ae 100644 (file)
@@ -147,10 +147,23 @@ switch ( $action ) {
             }
         }
 
+        /*
+         * Confirm pgpool_version corresponds with pgpool_command's output in stderr
+         * like "pgpool-II version 3.5alpha1 (ekieboshi)"
+         */
+        $cmd = "{$params['pgpool_command']} --version 2>&1";
+        $ret = exec($cmd, $output, $return_var);
+        if ($return_var == 0) {
+            $output_arr = explode(" ", $output[0]);
+            if (strpos($output_arr[2], $params['version']) !== 0) {
+                $errors['version'] = $message['errWrongVersion'];
+            }
+        }
+
         /*
          * If no error, write conf/pgmgt.conf.php.
          */
-        if (count($errors) == 0 ) {
+        if (count($errors) == 0) {
             $pgmgtConfigFile = dirname(__FILE__) . '/conf/pgmgt.conf.php';
 
             if (! is_writable($pgmgtConfigFile)) { errorPage('e5003'); }
index e0b237734722e7ef98ad5abc9a8d6cad2b0b97ea..1ed79a8d5b41d894eb5cc8815b3fa97af62f202c 100644 (file)
@@ -210,6 +210,7 @@ $message = array(
     'errShouldBeInteger' => 'This should be an integer',
     'errShouldBeZeroOrMore' => 'This should be 0 or more',
     'errSingleQuotation' => 'Please enclose the array element with a single quotation.',
+    'errWrongVersion' => 'pgpool command shows another version',
 
     'msgAddBackend' => 'Do you really add this node as a new backend?',
     'msgAddBackendNg' => 'Invalid.',
index 31475b93ab5d9a7e12eca6cb89e885d0e2cf5aea..7ed7daacdb860eec2f28bc5b7cbf9c844886563e 100644 (file)
@@ -194,6 +194,7 @@ $message = array(
     'errShouldBeInteger' => '0以上の整数を入力してください',
     'errShouldBeZeroOrMore' => '0以上である必要があります',
     'errSingleQuotation' => '配列要素をシングルクォーテーションで囲んでください。',
+    'errWrongVersion' => 'pgpool コマンドと一致していません。',
 
     'msgAddBackend' => 'バックエンドノードとして追加してよろしいですか?',
     'msgAddBackendNg' => 'バックエンドノード情報に不備があります。',
index 868c0d68addf0fc48d9d4dfe0bff623ca2ac76a8..95a76a63ec57312c63b6338f3bcba35eb54bfcb6 100644 (file)
@@ -19,7 +19,9 @@ function smarty_function_custom_select($args)
     $rtn .= '</select>';
 
     if ($errors[$param]) {
-        $rtn .='<br>'. $errors[$param];
+        $rtn .= '<p class="check_error">'.
+                '<span class="error">Error</span> '. $errors[$param].
+                '</p>';
     }
 
     echo $rtn;
index 4896b57c0b8563b928133cefbd52eb2f46ab101b..2af1a14fd72d1cd0039e358a59aba0d94466ffc2 100644 (file)
@@ -39,8 +39,7 @@
       <tbody>
         <tr>
           <th><label>{$message.strLanguage|escape}</label> (string)</th>
-          <td>{custom_select param='lang' echo=true}
-          </td>
+          <td>{custom_select param='lang' echo=true}</td>
         </tr>
         <tr>
           <th><label>{$message.strVersion|escape}</label> (float)</th>