generated from NethServer/ns8-kickstart
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add migration from NV on 7 and srtp stored on res_devices_phones
- Loading branch information
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
macroform-cold_day.wav filter=lfs diff=lfs merge=lfs -text | ||
macroform-robot_dity.wav filter=lfs diff=lfs merge=lfs -text | ||
macroform-the_simplicity.wav filter=lfs diff=lfs merge=lfs -text | ||
manolo_camp-morning_coffee.wav filter=lfs diff=lfs merge=lfs -text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
# | ||
# Copyright (C) 2023 Nethesis S.r.l. | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
|
||
include_once '/etc/freepbx_db.conf'; | ||
|
||
# TODO check if migration is needed. Exit 0 if not | ||
|
||
# Add srtp column to rest_devices_phones | ||
$db->query("ALTER TABLE `asterisk`.`rest_devices_phones` ADD COLUMN `srtp` BOOLEAN DEFAULT NULL AFTER `type`"); | ||
|
||
|
||
|
||
/* Convert existing srtp extensions to be used with proxy */ | ||
|
||
# get all NethVoice extensions with srtp enabled | ||
$sql = "SELECT extension | ||
FROM `asterisk`.`rest_devices_phones` | ||
JOIN `asterisk`.`sip` | ||
ON `asterisk`.`rest_devices_phones`.`extension` = `asterisk`.`sip`.`id` | ||
WHERE `type` = 'physical' | ||
AND `srtp` IS NULL | ||
AND `keyword`='media_encryption' | ||
AND `data`='sdes'"; | ||
|
||
$stmt = $db->prepare($sql); | ||
$stmt->execute(); | ||
$res = $stmt->fetchAll(\PDO::FETCH_ASSOC); | ||
$extensions = array_column($res, 'extension'); | ||
|
||
# set media_encryption to no in freepbx sip table | ||
$sql = "UPDATE `asterisk`.`sip` SET `data` = 'no' WHERE `keyword` = 'media_encryption' AND `id` IN ('".str_repeat('?, ', count($extensions) - 1) . '?'."')"; | ||
$stmt = $db->prepare($sql); | ||
$stmt->execute($extensions); | ||
|
||
# set srtp to true in rest_devices_phones table | ||
$sql = "UPDATE `asterisk`.`rest_devices_phones` SET `srtp` = 1 WHERE `extension` IN ('".str_repeat('?, ', count($extensions) - 1) . '?'."')"; | ||
$stmt = $db->prepare($sql); | ||
$stmt->execute($extensions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters