Skip to content

Commit 214a71c

Browse files
authored
Merge pull request #88 from lbr38/devel
6.0.1
2 parents 625f73b + cf7e7dd commit 214a71c

File tree

19 files changed

+193
-848
lines changed

19 files changed

+193
-848
lines changed

.github/workflows/test-database-update.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@ jobs:
5454
5555
echo -e "\nPulling image for release $release\n"
5656
57-
docker run -d --restart always --name motionui \
57+
docker run -d --restart always --name motionui --network=host \
5858
-e FQDN=motionui.test.com \
59-
-p 8080:8080 \
60-
-p 8555:8555 \
6159
-v /etc/localtime:/etc/localtime:ro \
6260
-v /var/lib/docker/volumes/motionui-data:/var/lib/motionui \
6361
-v /var/lib/docker/volumes/motionui-captures:/var/lib/motion \

docker/Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ RUN if [ "$env" = "devel" ]; then \
5454
RUN mkdir -p /etc/nginx/sites-enabled
5555
RUN cp /tmp/motionui/docker/config/nginx/nginx.conf /etc/nginx/nginx.conf
5656
RUN cp /tmp/motionui/docker/config/nginx/motionui.conf /etc/nginx/sites-enabled/motionui.conf
57-
RUN rm -rf /etc/nginx/sites-enabled/default /var/www/html
57+
RUN rm -rf /etc/nginx/sites-enabled/default /etc/nginx/conf.d/default.conf /var/www/html
5858

5959
# Configure PHP
6060
RUN cp /tmp/motionui/docker/config/php/www.conf /etc/php/8.3/fpm/pool.d/www.conf
@@ -65,6 +65,8 @@ RUN echo ".mode column" >> /root/.sqliterc
6565

6666
# Configure Postfix
6767
RUN \cp /tmp/motionui/docker/config/postfix/main.cf /etc/postfix/main.cf
68+
# Copy master.cf with custom listening port 2525 (to avoid conflict with other mail services on the host)
69+
RUN \cp /tmp/motionui/docker/config/postfix/master.cf /etc/postfix/master.cf
6870
RUN sed -i "s/__FQDN__/$fqdn/g" /etc/postfix/main.cf
6971
RUN echo $fqdn > /etc/mailname
7072

@@ -126,7 +128,6 @@ RUN chmod 750 /usr/local/bin/go2rtc
126128
RUN if [ ! -f "${DATA_DIR}/go2rtc/go2rtc.yml" ]; then \
127129
mkdir -p ${DATA_DIR}/go2rtc; \
128130
cp ${WWW_DIR}/templates/go2rtc/go2rtc.yml ${DATA_DIR}/go2rtc/go2rtc.yml; \
129-
sed -i "s/__FQDN__/$fqdn/g" ${DATA_DIR}/go2rtc/go2rtc.yml; \
130131
chown www-data:motionui ${DATA_DIR}/go2rtc/go2rtc.yml; \
131132
fi
132133

docker/config/postfix/master.cf

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
#
2+
# Postfix master process configuration file. For details on the format
3+
# of the file, see the master(5) manual page (command: "man 5 master" or
4+
# on-line: http://www.postfix.org/master.5.html).
5+
#
6+
# Do not forget to execute "postfix reload" after editing this file.
7+
#
8+
# ==========================================================================
9+
# service type private unpriv chroot wakeup maxproc command + args
10+
# (yes) (yes) (no) (never) (100)
11+
# ==========================================================================
12+
#smtp inet n - y - - smtpd
13+
2525 inet n - y - - smtpd
14+
#smtp inet n - y - 1 postscreen
15+
#smtpd pass - - y - - smtpd
16+
#dnsblog unix - - y - 0 dnsblog
17+
#tlsproxy unix - - y - 0 tlsproxy
18+
# Choose one: enable submission for loopback clients only, or for any client.
19+
#127.0.0.1:submission inet n - y - - smtpd
20+
#submission inet n - y - - smtpd
21+
# -o syslog_name=postfix/submission
22+
# -o smtpd_tls_security_level=encrypt
23+
# -o smtpd_sasl_auth_enable=yes
24+
# -o smtpd_tls_auth_only=yes
25+
# -o smtpd_reject_unlisted_recipient=no
26+
# Instead of specifying complex smtpd_<xxx>_restrictions here,
27+
# specify "smtpd_<xxx>_restrictions=$mua_<xxx>_restrictions"
28+
# here, and specify mua_<xxx>_restrictions in main.cf (where
29+
# "<xxx>" is "client", "helo", "sender", "relay", or "recipient").
30+
# -o smtpd_client_restrictions=
31+
# -o smtpd_helo_restrictions=
32+
# -o smtpd_sender_restrictions=
33+
# -o smtpd_relay_restrictions=
34+
# -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
35+
# -o milter_macro_daemon_name=ORIGINATING
36+
# Choose one: enable submissions for loopback clients only, or for any client.
37+
#127.0.0.1:submissions inet n - y - - smtpd
38+
#submissions inet n - y - - smtpd
39+
# -o syslog_name=postfix/submissions
40+
# -o smtpd_tls_wrappermode=yes
41+
# -o smtpd_sasl_auth_enable=yes
42+
# -o smtpd_reject_unlisted_recipient=no
43+
# Instead of specifying complex smtpd_<xxx>_restrictions here,
44+
# specify "smtpd_<xxx>_restrictions=$mua_<xxx>_restrictions"
45+
# here, and specify mua_<xxx>_restrictions in main.cf (where
46+
# "<xxx>" is "client", "helo", "sender", "relay", or "recipient").
47+
# -o smtpd_client_restrictions=
48+
# -o smtpd_helo_restrictions=
49+
# -o smtpd_sender_restrictions=
50+
# -o smtpd_relay_restrictions=
51+
# -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
52+
# -o milter_macro_daemon_name=ORIGINATING
53+
#628 inet n - y - - qmqpd
54+
pickup unix n - y 60 1 pickup
55+
cleanup unix n - y - 0 cleanup
56+
qmgr unix n - n 300 1 qmgr
57+
#qmgr unix n - n 300 1 oqmgr
58+
tlsmgr unix - - y 1000? 1 tlsmgr
59+
rewrite unix - - y - - trivial-rewrite
60+
bounce unix - - y - 0 bounce
61+
defer unix - - y - 0 bounce
62+
trace unix - - y - 0 bounce
63+
verify unix - - y - 1 verify
64+
flush unix n - y 1000? 0 flush
65+
proxymap unix - - n - - proxymap
66+
proxywrite unix - - n - 1 proxymap
67+
smtp unix - - y - - smtp
68+
relay unix - - y - - smtp
69+
-o syslog_name=postfix/$service_name
70+
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
71+
showq unix n - y - - showq
72+
error unix - - y - - error
73+
retry unix - - y - - error
74+
discard unix - - y - - discard
75+
local unix - n n - - local
76+
virtual unix - n n - - virtual
77+
lmtp unix - - y - - lmtp
78+
anvil unix - - y - 1 anvil
79+
scache unix - - y - 1 scache
80+
postlog unix-dgram n - n - 1 postlogd
81+
#
82+
# ====================================================================
83+
# Interfaces to non-Postfix software. Be sure to examine the manual
84+
# pages of the non-Postfix software to find out what options it wants.
85+
#
86+
# Many of the following services use the Postfix pipe(8) delivery
87+
# agent. See the pipe(8) man page for information about ${recipient}
88+
# and other message envelope options.
89+
# ====================================================================
90+
#
91+
# maildrop. See the Postfix MAILDROP_README file for details.
92+
# Also specify in main.cf: maildrop_destination_recipient_limit=1
93+
#
94+
maildrop unix - n n - - pipe
95+
flags=DRXhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
96+
#
97+
# ====================================================================
98+
#
99+
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
100+
#
101+
# Specify in cyrus.conf:
102+
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
103+
#
104+
# Specify in main.cf one or more of the following:
105+
# mailbox_transport = lmtp:inet:localhost
106+
# virtual_transport = lmtp:inet:localhost
107+
#
108+
# ====================================================================
109+
#
110+
# Cyrus 2.1.5 (Amos Gouaux)
111+
# Also specify in main.cf: cyrus_destination_recipient_limit=1
112+
#
113+
#cyrus unix - n n - - pipe
114+
# flags=DRX user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
115+
#
116+
# ====================================================================
117+
# Old example of delivery via Cyrus.
118+
#
119+
#old-cyrus unix - n n - - pipe
120+
# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
121+
#
122+
# ====================================================================
123+
#
124+
# See the Postfix UUCP_README file for configuration details.
125+
#
126+
uucp unix - n n - - pipe
127+
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
128+
#
129+
# Other external delivery methods.
130+
#
131+
ifmail unix - n n - - pipe
132+
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
133+
bsmtp unix - n n - - pipe
134+
flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
135+
scalemail-backend unix - n n - 2 pipe
136+
flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
137+
mailman unix - n n - - pipe
138+
flags=FRX user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py ${nexthop} ${user}

docker/docker-compose-dev.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ services:
66
container_name: motionui-dev
77
image: motionui-image
88
privileged: true
9+
network_mode: host
910
build:
1011
context: .
1112
dockerfile: Dockerfile
1213
args:
1314
env: devel
1415
fqdn: motionui-dev.localhost
1516
restart: unless-stopped
16-
ports:
17-
- "8888:8080"
18-
- "8555:8555"
19-
- "1984:1984" # To access go2rtc web interface
2017
volumes:
2118
- /etc/localtime:/etc/localtime:ro
2219
- /var/lib/docker/volumes/motionui-dev-data:/var/lib/motionui

docker/docker-compose.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ services:
55
container_name: motionui
66
image: motionui-image
77
privileged: true
8+
network_mode: host
89
build:
910
context: .
1011
dockerfile: Dockerfile
1112
args:
1213
env: prod
1314
fqdn: motionui.example.com
1415
restart: unless-stopped
15-
ports:
16-
- "8080:8080"
17-
- "8555:8555"
1816
volumes:
1917
- /etc/localtime:/etc/localtime:ro
2018
- /var/lib/docker/volumes/motionui-data:/var/lib/motionui

docker/init

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ fi
4242
/bin/su -s /bin/bash -c "php $WWW_DIR/tools/database/initialize.php" www-data
4343
/bin/su -s /bin/bash -c "php $WWW_DIR/tools/database/update.php" www-data
4444

45-
# Start go2rtc in background
46-
/bin/su -s /bin/bash -c "/usr/local/bin/go2rtc -c $GO2RTC_DIR/go2rtc.yml >/var/lib/motionui/go2rtc/go2rtc.log &" www-data
45+
# Start go2rtc in background, if not already running (database update may haved started it)
46+
if ! ps aux | grep "/usr/local/bin/go2rtc" | grep -v -q "grep"; then
47+
/bin/su -s /bin/bash -c "/usr/local/bin/go2rtc -c $GO2RTC_DIR/go2rtc.yml >/var/lib/motionui/go2rtc/go2rtc.log &" www-data
48+
fi
4749

4850
# Start shell service in background
4951
/bin/bash "$WWW_DIR/bin/service.sh" &

www/controllers/Motion/Event.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,27 @@ public function attachFile(string $motionEventId, string $file, int $width, int
102102
$date = date('Y-m-d');
103103
$time = date('H:i');
104104

105+
/**
106+
* Check that provided file is valid (must be in captures directory)
107+
*/
108+
if (!preg_match('#^' . CAPTURES_DIR . '#', realpath($file))) {
109+
throw new Exception('The specified file is invalid.');
110+
}
111+
112+
/**
113+
* File must be a picture or a movie
114+
*/
115+
if (!preg_match('/\.(jpg|jpeg|mp4|)$/', $file)) {
116+
throw new Exception('The specified file extension is not allowed.');
117+
}
118+
119+
/**
120+
* Check that MIME type is valid
121+
*/
122+
if (!in_array(mime_content_type($file), ['image/jpeg', 'video/mp4'])) {
123+
throw new Exception('The specified file MIME type is not allowed.');
124+
}
125+
105126
/**
106127
* Attach file to event
107128
*/
@@ -110,7 +131,7 @@ public function attachFile(string $motionEventId, string $file, int $width, int
110131
/**
111132
* If the file is a movie, then create a thumbnail image for it
112133
*/
113-
if (preg_match('/\.(mp4|mkv|mov)$/', $file)) {
134+
if (preg_match('/\.mp4$/', $file)) {
114135
/**
115136
* Get file directory location
116137
*/

www/public/resources/js/camera.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ async function loadStream()
1818
await loadCameras();
1919
reloadTimestamp();
2020
}
21+
2122
async function loadCameras()
2223
{
2324
/**
@@ -39,29 +40,16 @@ async function loadCameras()
3940
return;
4041
}
4142

42-
/**
43-
* Retrieve camera loading div and camera image div
44-
*/
45-
const cameraLoadingDiv = $(container).find('div.camera-loading');
46-
const cameraImageDiv = $(container).find('div.camera-image');
47-
4843
/**
4944
* Retrieve camera Id
5045
*/
51-
const cameraId = $(cameraImageDiv).attr('camera-id');
46+
const cameraId = $(container).find('div.camera-image').attr('camera-id');
5247

5348
/**
5449
* Connect to the camera using WebRTC
5550
* See js/webrtc/webrtc.js
5651
*/
57-
const media = 'video+audio';
58-
connect(media, cameraId);
59-
60-
/**
61-
* Remove the loading div and show the camera image div
62-
*/
63-
cameraLoadingDiv.remove();
64-
cameraImageDiv.show();
52+
connect(cameraId);
6553
}));
6654
}
6755

0 commit comments

Comments
 (0)