[SR-Users] How to add new user to Kamailio using PHP shell_exec?

Arun NV arunbalannv at gmail.com
Wed Dec 20 12:15:07 CET 2017


There is a requirement to add a new user to *Kamailio* programmatically
using *PHP*. I tried to add username and password to *subscriber* table
manually using *SQL* queries, but it won't works because *ha1* and
*ha1b* should
be added to the table. I don't know how Kamailio generate *ha1* and *ha1b*.
Following are the manually added entries using *kamctl* tool.

mysql> select * from subscriber limit 2;
+----+----------+---------------+--------------+---------------+----------------------------------+----------------------------------+------+
| id | username | domain        | password     | email_address | ha1
                           | ha1b                             | rpid |
+----+----------+---------------+--------------+---------------+----------------------------------+----------------------------------+------+
|  9 | 1010101  | 10.101.101.10 | aswwwwwwwsdf |               |
a37d1785953310c206481ca1a33f16b6 | 7e981130f05a547a738d3c29031e89d0 |
NULL |
| 10 | 1010102  | 10.101.101.10 | 6eeeeee8a72  |               |
6b574f9047206481ca1a33501d7dbdce | cd9a8b89d926f3cb1290311a8cb8a2a8 |
NULL |
+----+----------+---------------+--------------+---------------+----------------------------------+----------------------------------+------+

Then I tried with *shell_exec* function in *PHP* to use *kamctl*
command(*kamctl
add username password*). but it will prompt for *Kamailio* read-write
user's password. So following command cannot add new users to Kamailio

$res = shell_exec("sudo kamctl add new_username new_password);

so, please suggest a way to add new user's to *Kamailio* programmatically.

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20171220/560f466e/attachment.html>


More information about the sr-users mailing list