OSS Endpoint Manager Grandstream Phone Reboot

I am using FreePBX and the OSS Endpoint Manager. My phones are Grandstream GXP 2124’s

The reboot is not working for these phones. It appears to be logging into the web interface then issue an http://xxx.xxx.xxx.xxx/cgi-bin/rs

This is from the phone.php file the reboot() function in this file.

If i browse to the cgi-bin/rs url after logging into the phone it does not issue a reboot. It issues a 301 but does not redirect to any other URL. And the phone does not reboot.

Has anyone gotten the grandstream gpxhd line of phones to reboot via the UI?

thanks
Mark

I’ve only ever been able to get mine to reboot by issuing a sip notify command. I’m going to keep an eye on this thread to see if there’s a way to do it from the endpoint manager. I have the commercial endpoint installed, but there is also a “phone reboot” module, which I suspect also uses the sip notify command, because if a phone isn’t registered, it doesn’t show in that menu. I used to manage old Linksys/Cisco phones that had a URL you could send to the phone to cause it to reboot. (assuming you were authenticated.) I could never find such a URL for the Grandstream phones, although I’m pretty sure such a URL exists.

In the PHP code it appears to login to the phone then issue the reboot URL. I suppose you could put somekind of network monitor software up and see what the browser is sending the phone when you press the reboot button. I think it is a confirmation popup… “Are you sure you want to reboot this phone” something like that.

EDIT:
I found the URL that does the reboot:
/cgi-bin/api-sys_operation?request=REBOOT&sid=9c1543c2a95

The problem is getting the sid, this is the session id from the login. Should be from the response to the login. I will mess around with this and see what I can find.

EDIT 2:
I have a hard coded version working. I am getting everything but the admin password for the phone. the original reboot() method in phone.php for the gxphd phones gets the admin password from $this->options[‘admin_pass’] if this is blank then it defaults to ‘admin’ Well it is blank for me despite having set it to something else in the template. Any direction with this would be helpful. I will post my reboot() function after I figure this last piece out.

-Mark

Here is the reboot function that is rebooting my grandstream gxp2124

It is in phone.php in /var/www/html/admin/modules/_ep_phone_modules/endpoint/grandstream/gxphd

I could not figure out where the phone password was coming from. It is blank and defaults to admin.

-Mark

function reboot() {
if (($this->engine == “asterisk”) AND ($this->system == “unix”)) {
exec($this->engine_location . " -rx ‘sip show peers like " . $this->settings[‘line’][0][‘username’] . "’", $output);

        if (preg_match("/\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/", $output[1], $matches)) {
            $ip = $matches[0];
            $pass = (isset($this->options['admin_pass']) ? $this->options['admin_pass'] : 'admin');

            if (function_exists('curl_init')) {
                $ckfile = tempnam($this->sys_get_temp_dir(), "GSCURLCOOKIE");
                $ch = curl_init('http://' . $ip . '/cgi-bin/dologin');
                curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_POST, true);

                $data = array(
                    'P2' => $pass,
                    'Login' => 'Login',
                    'gnkey' => '0b82'
                );


                $data = array(
                    'password' => 'admin'
                );

                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                $output = curl_exec($ch);
                $login_result = json_decode($output, true);
                $info = curl_getinfo($ch);
                curl_close($ch);

                //$ch = curl_init("http://" . $ip . "/cgi-bin/rs");
                $ch = curl_init("http://" . $ip . "/cgi-bin/api-sys_operation?request=REBOOT&sid=" . $login_result['body']['sid']);
                curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                $output = curl_exec($ch);
                curl_close($ch);
            }
        }
    }

To make this truly useful to everyone you should submit a pull request on github

I have never submitted a pull request. Looks complicated.

This change has only been tested in my environment. Now granted there is no way the current reboot method for this phone type is working and this at least has a chance of working if the password is still the default password for the phone. I have not been able to figure out that last piece… where the admin password is coming from.

I have also made some changes specific to the gxp2124 to allow for setting of all the multipurpose keys and line keys. This could also be useful I would guess.

-Mark

http://oss-watch.ac.uk/resources/pullrequest

I know this is almost a year old, but I am still having a problem rebooting Grandstream GSX280 and GXP2010.
While searching I located a perl script here http://www.pkts.ca/gsutil.shtml which helped me and I hope will help anyone reading this wishing to remote reboot Grandstream phones.
This works and will work on several phones from one command line.

Can this be incorporated into the OSS Endpoint Manager to reboot these phones?

hi, i am having this problem with my grandstream 2130…has there been any fix on this issue?

in sip_notify_custom.conf add the lines:
[gsreboot]
Event=>check-sync

APPLY CONFIG and go to the Asterisk CLI (asterisk -r)
then type: sip notify gsreboot 'device MAC address’
e.g. sip notify gsreboot 000B8210000
wait about 60 seconds before rebooting another device.
You should see it in the CLI i.e. device becomes unreachable / reachable.

also, this sip notify gsreboot 'device MAC address’
works with sip notify gsreboot extension_number
if the phone registered in asterisk.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.