Module dashboard can't detected value SSH port during installation

After Install FreePbx-2.10 I got this error ‘SSH Server is not running, you will not be able to connect to the system console remotely’ in dashboard.
I tried to find where changing the SSH port value in freepbx web interface. And could not find
can be easily corrected by mysql
like this
UPDATE freepbx_settings SET value = ‘222’ WHERE keyword=‘SSHPORT’;
select keyword, value from freepbx_settings where keyword=‘SSHPORT’;
but I think
the installer itself should determine the value of SSH port
and I wrote a small patch
This patch selects SSH port value during installation of the module and stores it in the database.

path to download patch

https://sites.google.com/site/evrinoma/linux-dstgc-8/centosasteriskfreepbx/freepbx-2.10.0-dashboard.patch?attredirects=0&d=1

with best regards
strictly do not judge 8)

You change the setting in the advanced settings module. You can’t just change the database.

Thanks for the help
can be useful

now module dashboard can detect value SSH port automatic 8)

#######################################begin patch###################################
Submitted by: 3ABXO3 ([email protected])
Date: 2012-04-02
Initial Package Version:
Upstream Status:
Origin:
Description:
diff -Naur dashboard/class.procinfo.php dashboard/class.procinfo.php
— dashboard/class.procinfo.php 2011-12-18 01:02:34.000000000 +0400
+++ dashboard-new/class.procinfo.php 2012-04-02 12:59:07.000000000 +0400
@@ -1,5 +1,5 @@

<?php -if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } +//if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } class procinfo { var $distro; @@ -17,6 +17,49 @@ return false; } + function get_SSH_port($server = "localhost"){ + $cont = file("/proc/net/tcp"); + $search = "SSH"; + $array_port=""; + $max = count($cont); + for ($i=0;$i<$max;$i++){ + $str=explode(" ", $cont[$i]); + if (preg_match('/[a-fA-F0-9:]$/', $str[4])) { + $data=explode(":", $str[4]); + $array_port.=hexdec($data[1]).":"; + } + } + $array_port=array_diff(array_unique(explode(":", $array_port)),array(''));; + $max = count($array_port); + for ($i=0;$i<$max;$i++){ + if ($sock = @fsockopen($server, $array_port[$i], $errno, $errstr, $timeout)) { + stream_set_timeout($sock, 0, 100000); + $tmp = strtoupper(fread($sock, 127)); + if (strpos($tmp,$search)!==false) + return $array_port[$i]; + fclose($sock); + } + } + return -1; + } + + function save_SSH_port($ssh_value){ + global $db; + $sql=""; + $freepbx_conf =& freepbx_conf::create(); + if ($freepbx_conf->conf_setting_exists('SSHPORT')){ + $old_val = $full_settings['SSHPORT']['value']; + if ($old_val != $ssh_value){ + $sql = "UPDATE asterisk.freepbx_settings SET value = ".sql_formattext($ssh_value)."WHERE freepbx_settings.keyword = 'SSHPORT'"; + $result = $db->query($sql); + if(DB::IsError($result)) { + die_freepbx($result->getMessage().$sql); + } + } + unset($full_settings); + } + } + /* FOP has been removed, currenlty unsupported optional module function check_fop_server() { global $amp_conf; diff -Naur dashboard/page.index.php dashboard-new/page.index.php --- dashboard/page.index.php 2012-02-15 00:28:55.000000000 +0400 +++ dashboard-new/page.index.php 2012-04-02 12:59:37.000000000 +0400 @@ -330,6 +330,7 @@ global $astinfo; global $amp_conf; $out = ''; + $port = ''; $out .= "

"._("Server Status")."

"; // asterisk @@ -384,7 +385,13 @@ if ($procinfo->check_port($ssh_port)) { $out .= draw_status_box(_("SSH Server"), "ok", _('SSH Server is running')); } else { + $port=$procinfo->get_SSH_port(); + if ($port!=-1){ + // $procinfo->save_SSH_port($port); + $out .= draw_status_box(_("SSH Server"), "warn", _('SSH Server is running but value SSH port failed')); + }else{ $out .= draw_status_box(_("SSH Server"), "error", _('SSH Server is not running, you will not be able to connect to the system console remotely')); + } } return $out; } #######################################end patch###################################