Skip to content

Commit

Permalink
Merge pull request #181 from mikopbx/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jorikfon authored Sep 24, 2021
2 parents 9cc9f4d + 62a0c12 commit 82c3177
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 25 deletions.
2 changes: 2 additions & 0 deletions resources/rootfs/etc/inittab_base
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
::sysinit:/sbin/mikopbx_boot_init 2> /dev/null
tty1::respawn:/sbin/mikopbx_init 2> /dev/null
File renamed without changes.
9 changes: 8 additions & 1 deletion resources/rootfs/init
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ mount -t tmpfs -o size=90% tmpfs /mnt;

# Переключение root.
if tar -C / --exclude=mnt --exclude="./proc/*" --exclude="./sys/*" -cf - . | tar -C /mnt/ -xf - ; then
mv /mnt/etc/inittab_2 /mnt/etc/inittab
/bin/busybox busybox setserial -g /dev/ttyS0 2> /dev/null | /bin/grep unknown > /dev/null 2> /dev/null;
if [ "$?" = '0' ]; then
# Device ttys0 not found
mv /mnt/etc/inittab_base /mnt/etc/inittab
else
mv /mnt/etc/inittab_ttyS0 /mnt/etc/inittab
fi;

exec /sbin/switch_root /mnt /sbin/init "$@";
fi
8 changes: 4 additions & 4 deletions src/Common/Messages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@
'auth_ValidateLoginNotEmpty' => 'Enter the login',
'auth_SubmitButton' => 'Authorize',
'auth_WrongLoginPassword' => 'Authorization error',
'log_CaptureMessage' => '<div class=\'ui message \'>Start collecting logs and make a call or other action that causes a failure.
<br>The system will form a snapshot of the system state in the form of an archive.</div>',
'log_CaptureMessage' => '<div class = \'ui message\'> Start collecting network packets and initiate a call or other failure action.
<br> The system will save all packets passing through the network card at this moment for further analysis. </div>',
'dbg_NoDebugInformation' => 'No information',
'dbg_Header' => 'Debugging information',
'f2b_Reason' => 'Reason',
Expand Down Expand Up @@ -986,7 +986,7 @@
'sd_filter' => 'Filter',
'sd_lines' => 'Lines',
'sd_ShowLog' => 'Show log',
'sd_CapturePcap' => 'Capture pcap',
'sd_CapturePcap' => 'Capturing network packets',
'sd_DownloadPcapFileError' => 'An error occurred while creating a log archive',
'upd_UpgradeError' => 'Error while updating MikoPBX',
'cr_ValidateExtensionNumber' => 'Extension number must only consist of numbers',
Expand Down Expand Up @@ -1054,7 +1054,7 @@
'pr_EnterHostOrIpPlaceholder' => 'Enter IP address or subnet',
'pr_EnterHostOrIp' => 'Additional provider hosts or ip',
'auth_RememberMe' => 'Remember me',
'log_DownloadLogs' => 'Download logs',
'log_DownloadLogs' => 'Download all system logs',
'log_StopCapturePCAP' => 'Stop and download',
'log_StartCapturePCAP' => 'Start',
'gs_PBXRecordAnnouncementIn' => 'Select call recording alert for incoming calls',
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Asterisk/Configs/ExtensionsConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function generateConfigProtected(): void

Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/extensions.conf', $conf);
$confLua = '-- extensions["test-default"] = {'.PHP_EOL.
'-- ["100"] = function(context, extension);'.PHP_EOL.
'-- ["100"] = function(context, extension)'.PHP_EOL.
'-- app.playback("please-hold");'.PHP_EOL.
'-- end;'.PHP_EOL.
'-- -- Forbidden to describe contexts defined in extensions.conf. This will cause a crash asterisk.'.PHP_EOL.
Expand Down
11 changes: 9 additions & 2 deletions src/Core/Rc/connect.storage
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ namespace MikoPBX\Core\Rc;
use MikoPBX\Common\Providers\MainDatabaseProvider;
use MikoPBX\Core\Workers\WorkerAmiListener;
use MikoPBX\PBXCoreREST\Workers\WorkerApiCommands;
use MikoPBX\Core\System\{Configs\SyslogConf, Processes, System, Upgrade\UpdateDatabase, Util, Storage, PBX};
use MikoPBX\Core\System\{Configs\SyslogConf,
MikoPBXConfig,
Processes,
System,
Upgrade\UpdateDatabase,
Upgrade\UpdateSystemConfig,
Util,
Storage,
PBX};
use MikoPBX\Core\Asterisk\CdrDb;

require_once('Globals.php');
Expand Down Expand Up @@ -140,7 +148,6 @@ if(file_exists('/offload/livecd')) {
MainDatabaseProvider::recreateDBConnections(); //TODO:: может это сделать внутри стоража после монтирования нужной папки?
$storage->configure();
MainDatabaseProvider::recreateDBConnections(); //TODO:: может это сделать внутри стоража после монтирования нужной папки?

$success = Storage::isStorageDiskMounted();
if($success === true && $automatic === MODE_AUTO){
System::rebootSync();
Expand Down
35 changes: 35 additions & 0 deletions src/Core/System/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
use JsonException;
use MikoPBX\Common\Config\ClassLoader;
use MikoPBX\Common\Models\PbxExtensionModules;
use MikoPBX\Common\Models\SoundFiles;
use MikoPBX\Core\Config\RegisterDIServices;
use MikoPBX\Core\System\Configs\PHPConf;
use MikoPBX\Common\Models\Storage as StorageModel;
use MikoPBX\Common\Providers\ConfigProvider;
use MikoPBX\Modules\PbxExtensionUtils;
use MikoPBX\PBXCoreREST\Lib\SystemManagementProcessor;
use Phalcon\Di;

use function MikoPBX\Common\Config\appPath;
Expand Down Expand Up @@ -172,6 +174,39 @@ public function getFsType($device): string
return $format;
}
/**
* Moves predefined sound files to storage disk
* Changes SoundFiles records
*/
public static function moveReadOnlySoundsToStorage(): void
{
if(!self::isStorageDiskMounted()) {
return;
}
$di = Di::getDefault();
if ($di === null) {
return;
}
$currentMediaDir = $di->getConfig()->path('asterisk.customSoundDir') . '/';
if ( !file_exists($currentMediaDir)) {
Util::mwMkdir($currentMediaDir);
}
$soundFiles = SoundFiles::find();
foreach ($soundFiles as $soundFile) {
if (stripos($soundFile->path, '/offload/asterisk/sounds/other/') === 0) {
$newPath = $currentMediaDir.pathinfo($soundFile->path)['basename'];
if (copy($soundFile->path, $newPath)) {
SystemManagementProcessor::convertAudioFile($newPath);
$soundFile->path = Util::trimExtensionForFile($newPath) . ".mp3";
if(file_exists($soundFile->path)){
$soundFile->update();
}
}
}
}
unset($soundFiles);
}

/**
* Проверка, смонтирован ли диск - хранилище.
*
Expand Down
18 changes: 2 additions & 16 deletions src/Core/System/Upgrade/Releases/UpdateConfigsUpToVer20202754.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use MikoPBX\Common\Models\SoundFiles;
use MikoPBX\Core\System\MikoPBXConfig;
use MikoPBX\Core\System\Processes;
use MikoPBX\Core\System\Storage;
use MikoPBX\Core\System\Upgrade\UpgradeSystemConfigInterface;
use MikoPBX\Core\System\Util;
use Phalcon\Config as ConfigAlias;
Expand Down Expand Up @@ -326,21 +327,6 @@ private function updateExtensionsTable(): void
*/
private function moveReadOnlySoundsToStorage(): void
{
$currentMediaDir = $this->config->path('asterisk.customSoundDir') . '/';
if ( ! is_dir($currentMediaDir)) {
Util::mwMkdir($currentMediaDir);
}
$soundFiles = SoundFiles::find();
foreach ($soundFiles as $soundFile) {
if (stripos($soundFile->path, '/offload/asterisk/sounds/other/') === 0) {
$newPath = $currentMediaDir . pathinfo($soundFile->path)['basename'];
if (copy($soundFile->path, $newPath)) {
$soundFile->path = $newPath;
$soundFile->update();
}
}
}
Storage::moveReadOnlySoundsToStorage();
}


}
2 changes: 1 addition & 1 deletion src/Core/System/Upgrade/UpdateSystemConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function updateConfigs(): bool
$this->updateConfigEveryNewRelease();
$this->mikoPBXConfig->setGeneralSettings('PBXVersion', trim(file_get_contents('/etc/version')));
}

Storage::moveReadOnlySoundsToStorage();
return true;
}

Expand Down

0 comments on commit 82c3177

Please sign in to comment.