Skip to content

Commit 9a7ca71

Browse files
authored
Merge pull request #82 from lbr38/devel
5.3.0
2 parents 51c2a3c + a35dcd5 commit 9a7ca71

File tree

582 files changed

+74154
-468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

582 files changed

+74154
-468
lines changed

.github/archives/workflows/build-deb.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ jobs:
8282

8383
- name: Install motionui repo to grant access to most recent motion packages
8484
run: |
85-
curl -sS https://packages.bespin.ovh/repo/gpgkeys/packages.bespin.ovh.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.bespin.ovh_deb.gpg
86-
echo "deb https://packages.bespin.ovh/repo/motionui/buster/main_prod buster main" > /etc/apt/sources.list.d/motionui.list
85+
curl -sS https://packages.repomanager.net/repo/gpgkeys/packages.repomanager.net.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.repomanager.net_deb.gpg
86+
echo "deb https://packages.repomanager.net/repo/motionui/buster/main_prod buster main" > /etc/apt/sources.list.d/motionui.list
8787
8888
# Download builded deb package artifact
8989
- name: Download artifact
@@ -117,8 +117,8 @@ jobs:
117117

118118
- name: Install motionui repo to grant access to most recent motion packages
119119
run: |
120-
curl -sS https://packages.bespin.ovh/repo/gpgkeys/packages.bespin.ovh.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.bespin.ovh_deb.gpg
121-
echo "deb https://packages.bespin.ovh/repo/motionui/bullseye/main_prod bullseye main" > /etc/apt/sources.list.d/motionui.list
120+
curl -sS https://packages.repomanager.net/repo/gpgkeys/packages.repomanager.net.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.repomanager.net_deb.gpg
121+
echo "deb https://packages.repomanager.net/repo/motionui/bullseye/main_prod bullseye main" > /etc/apt/sources.list.d/motionui.list
122122
123123
# Download builded deb package artifact
124124
- name: Download artifact

.github/workflows/phpcs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
php phpcs.phar --version
2727
2828
- name: Detect coding standard violations
29-
run: php phpcs.phar --standard=$GITHUB_WORKSPACE/lint/phpcs.xml --colors -n $GITHUB_WORKSPACE --ignore=libs/PHPMailer
29+
run: php phpcs.phar --standard=$GITHUB_WORKSPACE/lint/phpcs.xml --colors -n $GITHUB_WORKSPACE --ignore=libs/

docker/Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ RUN apt-get update -y
2020
RUN apt-get install findutils iputils-ping git curl ca-certificates apt-transport-https dnsutils vim gnupg2 ffmpeg postfix -y
2121

2222
# Add motion 4.5.x repository
23-
RUN curl -sS https://packages.bespin.ovh/repo/gpgkeys/packages.bespin.ovh.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.bespin.ovh.gpg
24-
RUN echo "deb https://packages.bespin.ovh/repo/motion/bookworm/main_prod bookworm main" > /etc/apt/sources.list.d/motion.list
23+
RUN curl -sS https://packages.repomanager.net/repo/gpgkeys/packages.repomanager.net.pub | gpg --dearmor > /etc/apt/trusted.gpg.d/packages.repomanager.net.gpg
24+
RUN echo "deb https://packages.repomanager.net/repo/motion/bookworm/main_prod bookworm main" > /etc/apt/sources.list.d/motion.list
2525

2626
# Add nginx and PHP repositories
27-
RUN echo "deb https://packages.bespin.ovh/repo/motionui-nginx/bookworm/nginx_prod bookworm nginx" > /etc/apt/sources.list.d/nginx.list
28-
RUN echo "deb https://packages.bespin.ovh/repo/motionui-php/bookworm/main_prod bookworm main" > /etc/apt/sources.list.d/php.list
27+
RUN echo "deb https://packages.repomanager.net/repo/motionui-nginx/bookworm/nginx_prod bookworm nginx" > /etc/apt/sources.list.d/nginx.list
28+
RUN echo "deb https://packages.repomanager.net/repo/motionui-php/bookworm/main_prod bookworm main" > /etc/apt/sources.list.d/php.list
2929
RUN apt-get update -y
3030

3131
# Install nginx and PHP 8.3

docker/config/nginx/motionui.conf

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ server {
8383
fastcgi_request_buffering off;
8484
}
8585

86-
location ~ /api/stream.mjpeg {
86+
# Go2rtc stream access
87+
location /api/stream.mjpeg {
8788
proxy_pass http://127.0.0.1:1984;
88-
proxy_http_version 1.1;
89+
proxy_http_version 1.1;
8990
proxy_set_header Upgrade $http_upgrade;
9091
proxy_set_header Connection "Upgrade";
9192
proxy_set_header Host $host;
@@ -122,4 +123,14 @@ server {
122123
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
123124
access_log off;
124125
}
126+
127+
# Websocket server
128+
location /ws {
129+
proxy_pass http://127.0.0.1:8085;
130+
proxy_http_version 1.1;
131+
proxy_set_header Upgrade $http_upgrade;
132+
proxy_set_header Connection "Upgrade";
133+
proxy_set_header Host $host;
134+
proxy_read_timeout 86400;
135+
}
125136
}

docker/init

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
WWW_DIR="/var/www/motionui"
44
DATA_DIR="/var/lib/motionui"
55
GO2RTC_DIR="/var/lib/motionui/go2rtc"
6+
GO2RTC_LOG=""
67

78
# Make sure motion service is stopped
89
/usr/sbin/service motion stop
@@ -42,7 +43,7 @@ fi
4243
/bin/su -s /bin/bash -c "php $WWW_DIR/tools/update-database.php" www-data
4344

4445
# Start go2rtc in background
45-
/bin/su -s /bin/bash -c "/usr/local/bin/go2rtc -c $GO2RTC_DIR/go2rtc.yml >/dev/null 2>/dev/null &" www-data
46+
/bin/su -s /bin/bash -c "/usr/local/bin/go2rtc -c $GO2RTC_DIR/go2rtc.yml >/var/lib/motionui/go2rtc/go2rtc.log &" www-data
4647

4748
# Start shell service in background
4849
/bin/bash "$WWW_DIR/bin/service.sh" &

www/controllers/App/Config/Main.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Main
99
public static function get()
1010
{
1111
if (!defined('ROOT')) {
12-
define('ROOT', dirname(__FILE__, 4));
12+
define('ROOT', '/var/www/motionui');
1313
}
1414
if (!defined('DATA_DIR')) {
1515
define('DATA_DIR', '/var/lib/motionui');
@@ -20,9 +20,17 @@ public static function get()
2020
if (!defined('DB')) {
2121
define('DB', DB_DIR . '/motionui.sqlite');
2222
}
23+
// Websocket server database
24+
if (!defined('WS_DB')) {
25+
define('WS_DB', DB_DIR . "/motionui-ws.sqlite");
26+
}
2327
if (!defined('LOGS_DIR')) {
2428
define('LOGS_DIR', DATA_DIR . '/logs');
2529
}
30+
// Websocket server logs dir
31+
if (!defined('WS_LOGS_DIR')) {
32+
define('WS_LOGS_DIR', LOGS_DIR . '/websocket');
33+
}
2634
if (!defined('CAMERAS_DIR')) {
2735
define('CAMERAS_DIR', DATA_DIR . '/cameras');
2836
}

www/controllers/App/Config/Notification.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ public static function get()
2222
* If an update is available, generate a new notification
2323
*/
2424
if (UPDATE_AVAILABLE) {
25-
$message = '<span class="yellowtext">A new release is available: <b>' . GIT_VERSION . '</b>.</span><br><br>Please update your docker image by following the steps documented <a href="' . PROJECT_UPDATE_DOC_URL . '">here</a></span>';
25+
$message = '<p>A new release is available: <a href="' . PROJECT_GIT_REPO . '/releases/latest" target="_blank" rel="noopener noreferrer" title="See changelog"><code>' . GIT_VERSION . '</code> <img src="/assets/icons/external-link.svg" class="icon" /></a></p>';
26+
$message .= '<p>Please update your docker image by following the steps documented <b><a href="' . PROJECT_UPDATE_DOC_URL . '" target="_blank" rel="noopener noreferrer"><code>here</code></b> <img src="/assets/icons/external-link.svg" class="icon" /></a></p>';
27+
2628
$NOTIFICATION_MESSAGES[] = array('Title' => 'Update available', 'Message' => $message);
2729
$NOTIFICATION++;
2830
}

www/controllers/App/Structure/Directory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public static function create()
1717
mkdir(LOGS_DIR, 0770, true);
1818
}
1919

20+
if (!is_dir(WS_LOGS_DIR)) {
21+
mkdir(WS_LOGS_DIR, 0770, true);
22+
}
23+
2024
if (!is_dir(CAMERAS_DIR)) {
2125
mkdir(CAMERAS_DIR, 0770, true);
2226

www/controllers/Autoloader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function __construct(string $level = 'all')
1212
$__LOAD_ERROR_MESSAGES = array();
1313

1414
if (!defined('ROOT')) {
15-
define('ROOT', dirname(__FILE__, 2));
15+
define('ROOT', '/var/www/motionui');
1616
}
1717

1818
$this->register();

www/controllers/Camera/Timelapse.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,32 +121,23 @@ public function timelapse()
121121
/**
122122
* Capture image
123123
*/
124+
$content = file_get_contents('http://127.0.0.1:1984/api/frame.jpeg?src=camera_' . $camera['Id'], false, stream_context_create([
125+
'http' => [
126+
'timeout' => 3
127+
]
128+
]));
124129

125130
/**
126-
* Define ffmpeg command
127-
* Timeout is set to 3 seconds, kill after 5 seconds if it does not exit
131+
* Ignore if it fails to capture image because the camera may not be running 24/7
128132
*/
129-
$ffmpeg = '/usr/bin/timeout --kill-after=5 3 /usr/bin/ffmpeg';
130-
131-
/**
132-
* Add input stream
133-
*/
134-
$ffmpeg .= ' -i ' . 'http://127.0.0.1:1984/api/stream.mjpeg?src=camera_' . $camera['Id'];
135-
136-
/**
137-
* Execute ffmpeg command and save to file
138-
*/
139-
$myprocess = new \Controllers\Process($ffmpeg . ' ' . $targetDir . '/timelapse_' . date('H-i-s') . '.jpg >/dev/null 2>/dev/null &');
140-
$myprocess->execute();
141-
$output = $myprocess->getOutput();
142-
$myprocess->close();
133+
if ($content === false or empty($content)) {
134+
continue;
135+
}
143136

144137
/**
145-
* Ignore error if ffmpeg fails to capture image because the camera may not be running 24/7
138+
* Save image to file
146139
*/
147-
// if ($myprocess->getExitCode() != 0) {
148-
// throw new Exception('Failed to capture timelapse image for camera "' . $camera['Name'] . '" (ffmpeg error)');
149-
// }
140+
file_put_contents($targetDir . '/timelapse_' . date('H-i-s') . '.jpg', $content);
150141
} catch (Exception $e) {
151142
$this->logController->log('error', 'Camera timelapse', 'Errow while executing timelapse capture: ' . $e->getMessage());
152143
}

0 commit comments

Comments
 (0)