diff options
author | Nozomi Anzai | 2015-12-07 10:25:12 +0000 |
---|---|---|
committer | Nozomi Anzai | 2015-12-07 10:25:12 +0000 |
commit | d1ab40383a916cc53be5384c6872565d33261679 (patch) | |
tree | f51d11da8b52902bbc07e82683e7a938511e8967 | |
parent | bea081cd78b7dd220ac0093ad9573f717deff121 (diff) |
Confirm if "version" corresponds with output of "pgpool_command" in config.php
-rw-r--r-- | command.php | 1 | ||||
-rw-r--r-- | config.php | 15 | ||||
-rw-r--r-- | lang/en.lang.php | 1 | ||||
-rw-r--r-- | lang/ja.lang.php | 1 | ||||
-rw-r--r-- | libs/plugins/function.custom_select.php | 4 | ||||
-rw-r--r-- | templates/config.tpl | 3 |
6 files changed, 20 insertions, 5 deletions
diff --git a/command.php b/command.php index 42313c4..fa88432 100644 --- a/command.php +++ b/command.php @@ -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); @@ -148,9 +148,22 @@ 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'); } diff --git a/lang/en.lang.php b/lang/en.lang.php index e0b2377..1ed79a8 100644 --- a/lang/en.lang.php +++ b/lang/en.lang.php @@ -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.', diff --git a/lang/ja.lang.php b/lang/ja.lang.php index 31475b9..7ed7daa 100644 --- a/lang/ja.lang.php +++ b/lang/ja.lang.php @@ -194,6 +194,7 @@ $message = array( 'errShouldBeInteger' => '0以上の整数を入力してください', 'errShouldBeZeroOrMore' => '0以上である必要があります', 'errSingleQuotation' => '配列要素をシングルクォーテーションで囲んでください。', + 'errWrongVersion' => 'pgpool コマンドと一致していません。', 'msgAddBackend' => 'バックエンドノードとして追加してよろしいですか?', 'msgAddBackendNg' => 'バックエンドノード情報に不備があります。', diff --git a/libs/plugins/function.custom_select.php b/libs/plugins/function.custom_select.php index 868c0d6..95a76a6 100644 --- a/libs/plugins/function.custom_select.php +++ b/libs/plugins/function.custom_select.php @@ -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; diff --git a/templates/config.tpl b/templates/config.tpl index 4896b57..2af1a14 100644 --- a/templates/config.tpl +++ b/templates/config.tpl @@ -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> |