Skip to content

Commit

Permalink
4.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lbr38 committed Oct 10, 2024
1 parent dd0488f commit 4920711
Show file tree
Hide file tree
Showing 82 changed files with 3,489 additions and 2,630 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
release:
types: [ published ]

# Debug only
# on:
# push:
# branches: [ devel ]
Expand All @@ -15,6 +16,9 @@ jobs:
steps:
- name: Check out the repo
uses: actions/checkout@v4
# Debug only
# with:
# ref: 'devel'

- name: Retrieve motion-UI version
run: |
Expand All @@ -38,7 +42,9 @@ jobs:
uses: docker/build-push-action@v2
with:
file: ./docker/Dockerfile
# Debug only
# push: false
push: true
tags: lbr38/motionui:latest, lbr38/motionui:${{ env.VERSION }}
platforms: linux/amd64,linux/arm64,linux/arm/v7
platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64

23 changes: 21 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ LABEL version="1.0" maintainer="lbr38 <[email protected]>"
ARG WWW_DIR="/var/www/motionui"
ARG DATA_DIR="/var/lib/motionui"
ARG DEBIAN_FRONTEND=noninteractive
ARG env
ARG fqdn
ARG env
# Debug only
# ARG env=devel

# Install dependencies, postfix
RUN apt-get update -y
Expand All @@ -27,7 +29,7 @@ RUN echo "deb https://packages.bespin.ovh/repo/motionui-php/bookworm/main_prod b
RUN apt-get update -y

# Install nginx and PHP 8.3
RUN apt-get install nginx php8.3-fpm php8.3-cli php8.3-sqlite3 php8.3-xml php8.3-curl sqlite3 -y
RUN apt-get install nginx php8.3-fpm php8.3-cli php8.3-sqlite3 php8.3-curl php8.3-yaml sqlite3 -y

# Install motion
RUN apt-get install motion -y
Expand Down Expand Up @@ -99,6 +101,23 @@ RUN echo "set mouse-=a" >> /root/.vimrc
RUN echo "syntax on" >> /root/.vimrc
RUN echo "set background=dark" >> /root/.vimrc

# Setup go2rtc
# First, check if a binary is available for the current architecture
RUN ARCH=$(dpkg --print-architecture); \
if [ ! -f "${WWW_DIR}/bin/go2rtc/go2rtc_linux_${ARCH}" ]; then \
echo "No go2rtc binary available for this architecture (${ARCH})"; \
exit 1; \
fi
# Then link go2rtc binary to /usr/local/bin/ and set permissions
RUN ln -s ${WWW_DIR}/bin/go2rtc/go2rtc_linux_$(dpkg --print-architecture) /usr/local/bin/go2rtc
RUN chmod 755 /usr/local/bin/go2rtc
# Copy go2rtc template config file if not exists
RUN if [ ! -f "${DATA_DIR}/go2rtc/go2rtc.yml" ]; then \
mkdir -p ${DATA_DIR}/go2rtc; \
cp ${WWW_DIR}/templates/go2rtc/go2rtc.yml ${DATA_DIR}/go2rtc/go2rtc.yml; \
chown www-data:motionui ${DATA_DIR}/go2rtc/go2rtc.yml; \
fi

# Copy entrypoint script
RUN cp /tmp/motionui/docker/init /init
RUN chmod 700 /init
Expand Down
9 changes: 9 additions & 0 deletions docker/config/nginx/motionui.conf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ server {
fastcgi_request_buffering off;
}

location ~ /api/stream.mjpeg {
proxy_pass http://127.0.0.1:1984;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 86400;
}

location ~ \.php$ {
root $WWW_DIR/public;
include fastcgi_params;
Expand Down
1 change: 1 addition & 0 deletions docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ services:
restart: always
ports:
- "8888:8080"
- "1984:1984" # To access go2rtc web interface
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/lib/docker/volumes/motionui-dev-data:/var/lib/motionui
Expand Down
9 changes: 9 additions & 0 deletions docker/init
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

WWW_DIR="/var/www/motionui"
DATA_DIR="/var/lib/motionui"
GO2RTC_DIR="/var/lib/motionui/go2rtc"

# Make sure motion service is stopped
/usr/sbin/service motion stop
Expand All @@ -13,6 +14,11 @@ if [ -f /run/motion/motion.pid ]; then
rm -f /run/motion/motion.pid
fi

# Set permissions for video devices, if any
if ls /dev/video* > /dev/null 2>&1; then
chown root:motionui /dev/video*
fi

# Docker run options
# when
# -e FQDN=server.example.com
Expand All @@ -35,6 +41,9 @@ fi
/bin/su -s /bin/bash -c "php $WWW_DIR/tools/initialize-database.php" www-data
/bin/su -s /bin/bash -c "php $WWW_DIR/tools/update-database.php" www-data

# Start go2rtc in background
/bin/su -s /bin/bash -c "/usr/local/bin/go2rtc -c $GO2RTC_DIR/go2rtc.yml >/dev/null 2>/dev/null &" www-data

# Start motionui service
/bin/su -s /bin/bash -c "php $WWW_DIR/tools/service.php" www-data

Expand Down
2 changes: 1 addition & 1 deletion notifications/notifications.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
},
"NT02" : {
"title" : "New! Android app",
"message" : "An Android app is now available for download <b><a href='https://github.com/lbr38/motion-UI/releases/tag/android-1.0'>here</a></b> (in the assets section).<br><br>This is a <b>beta version</b> which could need some improvements. Feel free to test it and send me your feedbacks or issues!"
"message" : "An Android app is now available for download <b><a href='https://github.com/lbr38/motion-UI/releases/tag/android-1.0'>here</a></b> (in the assets section)."
},
"NT03" : {
"title" : "New! Discord channel",
Expand Down
Binary file added www/bin/go2rtc/go2rtc_linux_amd64
Binary file not shown.
Binary file added www/bin/go2rtc/go2rtc_linux_arm64
Binary file not shown.
Binary file added www/bin/go2rtc/go2rtc_linux_armhf
Binary file not shown.
Binary file added www/bin/go2rtc/go2rtc_linux_i386
Binary file not shown.
6 changes: 5 additions & 1 deletion www/bin/motionui
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ function permissions
echo -e "\n${YELLOW} Setting permissions... ${RESET}"

# Permissions on web directory
find "$WWW_DIR" -type f -exec chmod 0660 {} \;
chmod 750 "$WWW_DIR/bin/motionui"
chmod 750 "$WWW_DIR/bin/on_event"*
chmod 750 "$WWW_DIR/bin/go2rtc/"*
# Set 660 permissions on all files and directories except scripts in bin:
find "$WWW_DIR" -type f -not -not \( -path bin -prune \) -exec chmod 0660 {} \;
find "$WWW_DIR" -type d -exec chmod 0770 {} \;
chown -R $WWW_USER "$WWW_DIR"
chgrp -R $WWW_USER "$WWW_DIR"
Expand Down
12 changes: 12 additions & 0 deletions www/controllers/App/Config/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,21 @@ public static function get()
if (!defined('CAMERAS_DIR')) {
define('CAMERAS_DIR', DATA_DIR . '/cameras');
}
if (!defined('CAMERAS_MOTION_CONF_AVAILABLE_DIR')) {
define('CAMERAS_MOTION_CONF_AVAILABLE_DIR', CAMERAS_DIR . '/motion/conf-available');
}
if (!defined('CAMERAS_MOTION_CONF_ENABLED_DIR')) {
define('CAMERAS_MOTION_CONF_ENABLED_DIR', CAMERAS_DIR . '/motion/conf-enabled');
}
if (!defined('CAMERAS_TIMELAPSE_DIR')) {
define('CAMERAS_TIMELAPSE_DIR', CAMERAS_DIR . '/timelapse');
}
if (!defined('CAPTURES_DIR')) {
define('CAPTURES_DIR', '/var/lib/motion');
}
if (!defined('GO2RTC_DIR')) {
define('GO2RTC_DIR', DATA_DIR . '/go2rtc');
}
if (!defined('DB_UPDATE_DONE_DIR')) {
define('DB_UPDATE_DONE_DIR', DATA_DIR . '/update');
}
Expand Down
24 changes: 0 additions & 24 deletions www/controllers/App/Config/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,6 @@ public static function get()
}
}

if (!defined('MOTION_EVENTS_VIDEOS_THUMBNAIL')) {
if (!empty($settings['Motion_events_videos_thumbnail']) and $settings['Motion_events_videos_thumbnail'] == 'true') {
define('MOTION_EVENTS_VIDEOS_THUMBNAIL', true);
} else {
define('MOTION_EVENTS_VIDEOS_THUMBNAIL', false);
}
}

if (!defined('MOTION_EVENTS_PICTURES_THUMBNAIL')) {
if (!empty($settings['Motion_events_pictures_thumbnail']) and $settings['Motion_events_pictures_thumbnail'] == 'true') {
define('MOTION_EVENTS_PICTURES_THUMBNAIL', true);
} else {
define('MOTION_EVENTS_PICTURES_THUMBNAIL', false);
}
}

if (!defined('MOTION_ADVANCED_EDITION_MODE')) {
if (!empty($settings['Motion_advanced_edition_mode']) and $settings['Motion_advanced_edition_mode'] == 'true') {
define('MOTION_ADVANCED_EDITION_MODE', true);
} else {
define('MOTION_ADVANCED_EDITION_MODE', false);
}
}

if (!defined('MOTION_EVENTS_RETENTION')) {
if (!empty($settings['Motion_events_retention']) and is_numeric($settings['Motion_events_retention'])) {
define('MOTION_EVENTS_RETENTION', $settings['Motion_events_retention']);
Expand Down
78 changes: 64 additions & 14 deletions www/controllers/App/Config/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static function get()
setlocale(LC_ALL, 'en_EN');

/**
* Protocol (http ou https)
* Protocol (http/https)
*/
if (!defined('__SERVER_PROTOCOL__')) {
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
Expand All @@ -23,28 +23,42 @@ public static function get()
}

/**
* Url du serveur
* Server url
*/
if (!empty($_SERVER['SERVER_NAME'])) {
if (!defined('__SERVER_URL__')) {
if (!defined('__SERVER_URL__')) {
if (!empty($_SERVER['HTTP_HOST'])) {
define('__SERVER_URL__', __SERVER_PROTOCOL__ . '://' . $_SERVER['HTTP_HOST']);
} else {
define('__SERVER_URL__', '');
}
}

/**
* Adresse IP du serveur
* Server IP
*/
if (!empty($_SERVER['SERVER_ADDR'])) {
if (!defined('__SERVER_IP__')) {
if (!defined('__SERVER_IP__')) {
if (!empty($_SERVER['SERVER_ADDR'])) {
define('__SERVER_IP__', $_SERVER['SERVER_ADDR']);
} else {
define('__SERVER_IP__', '');
}
}

/**
* URL + URI complètes
* URL + URI
*/
if (!empty($_SERVER['HTTP_HOST']) and !empty($_SERVER['REQUEST_URI'])) {
if (!defined('__ACTUAL_URL__')) {
define('__ACTUAL_URL__', __SERVER_PROTOCOL__ . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
if (!defined('__ACTUAL_URL__')) {
/**
* If sourceUrl is set (POST request from ajax) then we use it
*/
if (!empty($_POST['sourceUrl'])) {
define('__ACTUAL_URL__', $_POST['sourceUrl']);
} else {
if (!empty($_SERVER['HTTP_HOST']) and !empty($_SERVER['REQUEST_URI'])) {
define('__ACTUAL_URL__', __SERVER_PROTOCOL__ . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
} else {
define('__ACTUAL_URL__', '');
}
}
}

Expand All @@ -67,11 +81,47 @@ public static function get()
}

/**
* Paramètres
* If HTTP_X_REQUESTED_WITH is set to 'xmlhttprequest' we can assume that the request is an AJAX request
*/
if (!defined('AJAX')) {
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
define('AJAX', true);
} else {
define('AJAX', false);
}
}

/**
* Clear cookies starting with 'tables/' or 'temp/' when the page has been reloaded by the user (not AJAX)
*/
if (!empty($_SERVER['QUERY_STRING'])) {
if (!defined('__QUERY_STRING__')) {
if (AJAX === false) {
foreach ($_COOKIE as $key => $value) {
if (strpos($key, 'tables/') === 0 or strpos($key, 'tmp/') === 0) {
setcookie($key, '', time() - 3600, '/');
unset($_COOKIE[$key]);
}
}
}

/**
* GET Parameters
*/
if (!defined('__GET_PARAMETERS__')) {
if (!empty($_POST['sourceGetParameters'])) {
define('__GET_PARAMETERS__', $_POST['sourceGetParameters']);
} else {
define('__GET_PARAMETERS__', '');
}
}

/**
* Parameters
*/
if (!defined('__QUERY_STRING__')) {
if (!empty($_SERVER['QUERY_STRING'])) {
define('__QUERY_STRING__', parse_url($_SERVER["QUERY_STRING"], PHP_URL_PATH));
} else {
define('__QUERY_STRING__', '');
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions www/controllers/App/Structure/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,30 @@ public static function create()
chgrp(CAMERAS_DIR, 'motion');
chmod(CAMERAS_DIR, octdec('0770'));
}

if (!is_dir(CAMERAS_MOTION_CONF_AVAILABLE_DIR)) {
mkdir(CAMERAS_MOTION_CONF_AVAILABLE_DIR, 0770, true);
}

if (!is_dir(CAMERAS_MOTION_CONF_ENABLED_DIR)) {
mkdir(CAMERAS_MOTION_CONF_ENABLED_DIR, 0770, true);
}

if (!is_dir(CAMERAS_TIMELAPSE_DIR)) {
mkdir(CAMERAS_TIMELAPSE_DIR, 0770, true);
}

if (!is_dir(CAPTURES_DIR)) {
mkdir(CAPTURES_DIR, 0770, true);

chmod(CAPTURES_DIR, octdec('0770'));
chgrp(CAPTURES_DIR, 'motion');
}

if (!is_dir(GO2RTC_DIR)) {
mkdir(GO2RTC_DIR, 0770, true);
}

if (!is_dir(DB_UPDATE_DONE_DIR)) {
mkdir(DB_UPDATE_DONE_DIR, 0770, true);
}
Expand Down
Loading

0 comments on commit 4920711

Please sign in to comment.