Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Socket XMR and PWA routes #2839

Merged
merged 14 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ RUN LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y &
iputils-ping \
php8.2 \
libapache2-mod-php8.2 \
php8.2-zmq \
php8.2-gd \
php8.2-dom \
php8.2-pdo \
Expand Down Expand Up @@ -103,7 +102,10 @@ RUN update-alternatives --set php /usr/bin/php8.2

# Enable Apache module
RUN a2enmod rewrite \
&& a2enmod headers
&& a2enmod headers \
&& a2enmod proxy \
&& a2enmod proxy_http \
&& a2enmod proxy_wstunnel

# Add all necessary config files in one layer
ADD docker/ /
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ RUN LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y &
iputils-ping \
php8.2 \
libapache2-mod-php8.2 \
php8.2-zmq \
php8.2-gd \
php8.2-dom \
php8.2-pdo \
Expand Down Expand Up @@ -88,7 +87,10 @@ RUN update-alternatives --set php /usr/bin/php8.2

# Enable Apache module
RUN a2enmod rewrite \
&& a2enmod headers
&& a2enmod headers \
&& a2enmod proxy \
&& a2enmod proxy_http \
&& a2enmod proxy_wstunnel

# Add all necessary config files in one layer
ADD docker/ /
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ RUN LC_ALL=C.UTF-8 DEBIAN_FRONTEND=noninteractive apt update && apt upgrade -y &
iputils-ping \
php8.2 \
libapache2-mod-php8.2 \
php8.2-zmq \
php8.2-gd \
php8.2-dom \
php8.2-pdo \
Expand Down Expand Up @@ -55,7 +54,10 @@ RUN update-alternatives --set php /usr/bin/php8.2

# Enable Apache module
RUN a2enmod rewrite \
&& a2enmod headers
&& a2enmod headers \
&& a2enmod proxy \
&& a2enmod proxy_http \
&& a2enmod proxy_wstunnel

# Add all necessary config files in one layer
ADD docker/ /
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"config": {
"platform": {
"php": "8.1",
"ext-zmq": "1",
"ext-mongodb": "1.15.0",
"ext-gd": "1",
"ext-dom": "1",
"ext-pdo": "1",
"ext-json": "1",
"ext-soap": "1",
"ext-zip": "1"
"ext-zip": "1",
"ext-fileinfo": "*"
}
},
"minimum-stability": "dev",
Expand All @@ -48,6 +48,7 @@
"ext-soap": "*",
"ext-zip": "*",
"ext-openssl": "*",
"ext-fileinfo": "*",
"slim/slim": "^4.3",
"slim/http": "^1.2",
"slim/flash": "^0.4",
Expand Down
25 changes: 22 additions & 3 deletions db/migrations/20180131114002_old_upgrade_step121_migration.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?php

/*
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

use Phinx\Migration\AbstractMigration;

Expand Down Expand Up @@ -32,15 +51,15 @@ public function up()
'setting' => 'XMR_ADDRESS',
'title' => 'XMR Private Address',
'helptext' => 'Please enter the private address for XMR.',
'value' => 'tcp:://localhost:5555',
'value' => 'http:://localhost:8081',
'fieldType' => 'checkbox',
'options' => '',
'cat' => 'displays',
'userChange' => '1',
'type' => 'string',
'validation' => '',
'ordering' => '5',
'default' => 'tcp:://localhost:5555',
'default' => 'http:://localhost:8081',
'userSee' => '1',
],
[
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/*
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

use Phinx\Migration\AbstractMigration;

/**
* @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace
*/
class AddDefaultChromeOSDisplayProfileMigration extends AbstractMigration
{
public function change(): void
{
// add default display profile for tizen
if (!$this->fetchRow('SELECT * FROM displayprofile WHERE type = \'chromeOS\' AND isDefault = 1')) {
// Get system user
$user = $this->fetchRow('SELECT userId FROM `user` WHERE userTypeId = 1');

$this->table('displayprofile')->insert([
'name' => 'ChromeOS',
'type' => 'chromeOS',
'config' => '[]',
'userId' => $user['userId'],
'isDefault' => 1
])->save();
}
}
}
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ services:
db:
image: mysql:8.0
ports:
- 3315:3306
- "3315:3306"
volumes:
- ./containers/db:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: "root"
MYSQL_DATABASE: "cms"

xmr:
image: ghcr.io/xibosignage/xibo-xmr:latest
image: ghcr.io/xibosignage/xibo-xmr:develop
ports:
- "9505:9505"
environment:
XMR_DEBUG: "true"
IPV6RESPSUPPORT: "false"
IPV6PUBSUPPORT: "false"

web:
Expand Down
7 changes: 3 additions & 4 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

#
# Copyright (C) 2023 Xibo Signage Ltd
# Copyright (C) 2024 Xibo Signage Ltd
#
# Xibo - Digital Signage - https://xibosignage.com
#
Expand Down Expand Up @@ -32,7 +32,6 @@ then
echo ""
echo "XMR Connection Details:"
echo "Host: $XMR_HOST"
echo "CMS Port: 50001"
echo "Player Port: 9505"
echo ""
echo "Starting Webserver"
Expand Down Expand Up @@ -120,7 +119,7 @@ then
mysql -D $MYSQL_DATABASE -e "UPDATE \`setting\` SET \`value\`='Apache', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='SENDFILE_MODE' LIMIT 1"

# Set XMR public/private address
mysql -D $MYSQL_DATABASE -e "UPDATE \`setting\` SET \`value\`='tcp://$XMR_HOST:50001', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='XMR_ADDRESS' LIMIT 1"
mysql -D $MYSQL_DATABASE -e "UPDATE \`setting\` SET \`value\`='http://$XMR_HOST:8081', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='XMR_ADDRESS' LIMIT 1"

# Configure Maintenance
echo "Setting up Maintenance"
Expand Down Expand Up @@ -194,7 +193,7 @@ then
mysql -D $MYSQL_DATABASE -e "UPDATE \`user\` SET \`UserName\`='xibo_admin', \`UserPassword\`='5f4dcc3b5aa765d61d8327deb882cf99' WHERE \`UserID\` = 1 LIMIT 1"

# Set XMR public/private address
mysql -D $MYSQL_DATABASE -e "UPDATE \`setting\` SET \`value\`='tcp://$XMR_HOST:50001', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='XMR_ADDRESS' LIMIT 1"
mysql -D $MYSQL_DATABASE -e "UPDATE \`setting\` SET \`value\`='http://$XMR_HOST:8081', \`userChange\`=0, \`userSee\`=0 WHERE \`setting\`='XMR_ADDRESS' LIMIT 1"
mysql -D $MYSQL_DATABASE -e "UPDATE \`setting\` SET \`value\`='tcp://cms.example.org:9505' WHERE \`setting\`='XMR_PUB_ADDRESS' LIMIT 1"

# Set CMS Key
Expand Down
14 changes: 14 additions & 0 deletions docker/etc/apache2/sites-available/000-default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ServerTokens OS
PassEnv CMS_USE_MEMCACHED
PassEnv MEMCACHED_HOST
PassEnv MEMCACHED_PORT
PassEnv XMR_HOST

ServerName ${CMS_SERVER_NAME}

Expand All @@ -36,6 +37,19 @@ ServerTokens OS
Require all granted
</Directory>

Alias /chromeos /var/www/cms/library/playersoftware/chromeos/latest
<Directory /var/www/cms/library/playersoftware/chromeos/latest>
php_admin_value engine Off
DirectoryIndex index.html
Options -Indexes -FollowSymLinks -MultiViews
AllowOverride None
Require all granted
</Directory>

<Location /xmr>
ProxyPass ws://${XMR_HOST}:8080
</Location>

ErrorLog /dev/stderr

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" *%Ts* *%Dus*" requesttime
Expand Down
8 changes: 3 additions & 5 deletions lib/Controller/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ public function grid(Request $request, Response $response)
];
}

if (in_array($display->clientType, ['android', 'lg', 'sssp'])) {
if (in_array($display->clientType, ['android', 'lg', 'sssp', 'chromeOS'])) {
$display->buttons[] = array(
'id' => 'display_button_checkLicence',
'url' => $this->urlFor($request, 'display.licencecheck.form', ['id' => $display->displayId]),
Expand Down Expand Up @@ -2317,7 +2317,7 @@ public function requestScreenShotForm(Request $request, Response $response, $id)
* )
* )
*/
public function requestScreenShot(Request $request, Response $response, $id)
public function requestScreenShot(Request $request, Response $response, $id): Response
{
$display = $this->displayFactory->getById($id);

Expand All @@ -2329,9 +2329,7 @@ public function requestScreenShot(Request $request, Response $response, $id)
$display->screenShotRequested = 1;
$display->save(['validate' => false, 'audit' => false]);

$xmrPubAddress = $this->getConfig()->getSetting('XMR_PUB_ADDRESS');

if (!empty($display->xmrChannel) && !empty($xmrPubAddress) && $xmrPubAddress !== 'DISABLED') {
if (!empty($display->xmrChannel)) {
$this->playerAction->sendAction($display, new ScreenShotAction());
}

Expand Down
30 changes: 26 additions & 4 deletions lib/Controller/DisplayProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,10 @@ public function editForm(Request $request, Response $response, $id)
}

// Player Version Setting
$versionId = $displayProfile->getSetting('versionMediaId');
$versionId = $displayProfile->type === 'chromeOS'
? $displayProfile->getSetting('playerVersionId')
: $displayProfile->getSetting('versionMediaId');

$playerVersions = [];

// Daypart - Operating Hours
Expand All @@ -358,8 +361,9 @@ public function editForm(Request $request, Response $response, $id)
if ($versionId !== null) {
try {
$playerVersions[] = $this->playerVersionFactory->getById($versionId);
} catch (NotFoundException $e) {
$this->getLog()->debug('Unknown versionId set on Display Profile. ' . $displayProfile->displayProfileId);
} catch (NotFoundException) {
$this->getLog()->debug('Unknown versionId set on Display Profile. '
. $displayProfile->displayProfileId);
}
}

Expand Down Expand Up @@ -456,12 +460,14 @@ public function edit(Request $request, Response $response, $id)
$displayProfile->name = $parsedParams->getString('name');
$displayProfile->isDefault = $parsedParams->getCheckbox('isDefault');

// Track changes to versionMediaId
$originalPlayerVersionId = $displayProfile->getSetting('playerVersionId');

// Different fields for each client type
$this->editConfigFields($displayProfile, $parsedParams);

// Capture and update commands
foreach ($this->commandFactory->query() as $command) {
/* @var \Xibo\Entity\Command $command */
if ($parsedParams->getString('commandString_' . $command->commandId) != null) {
// Set and assign the command
$command->commandString = $parsedParams->getString('commandString_' . $command->commandId);
Expand All @@ -474,6 +480,22 @@ public function edit(Request $request, Response $response, $id)
}
}

// If we are chromeOS and the default profile, has the player version changed?
if ($displayProfile->type === 'chromeOS'
&& ($displayProfile->isDefault || $displayProfile->hasPropertyChanged('isDefault'))
&& ($originalPlayerVersionId !== $displayProfile->getSetting('playerVersionId'))
) {
$this->getLog()->debug('edit: updating symlink to the latest chromeOS version');

// Update a symlink to the new player version.
try {
$version = $this->playerVersionFactory->getById($displayProfile->getSetting('playerVersionId'));
$version->setActive();
} catch (NotFoundException) {
$this->getLog()->error('edit: Player version does not exist');
}
}

// Save the changes
$displayProfile->save();

Expand Down
Loading
Loading