From 0e3202155ebcb3e08da90cf9660881b23ff158e4 Mon Sep 17 00:00:00 2001 From: Jan-Pascal van Best Date: Sat, 23 Jun 2018 16:40:52 +0200 Subject: [PATCH] Create motioneye user in postinst and run motioneye as that user --- debian/control | 15 ++++-- debian/init | 11 +++-- debian/patches/add_private_log_and_run_dirs | 34 +++++++++++++ debian/patches/series | 1 + debian/postinst | 54 +++++++++++++++++++++ 5 files changed, 108 insertions(+), 7 deletions(-) create mode 100644 debian/patches/add_private_log_and_run_dirs create mode 100644 debian/patches/series create mode 100644 debian/postinst diff --git a/debian/control b/debian/control index 37d8523..660139c 100644 --- a/debian/control +++ b/debian/control @@ -5,13 +5,20 @@ Maintainer: Christian Marillat Bugs: mailto:marillat@deb-multimedia.org Homepage: https://github.com/ccrisan/motioneye X-Python-Version: >= 2.7 -Standards-Version: 4.1.4 +Standards-Version: 3.9.8 Build-Depends: debhelper (>= 11), python | python-all | python-dev | python-all-dev, - dh-python + dh-python, python-jsmin, python-cssmin, fontmake, fontforge-nox, gmsl Package: motioneye Architecture: all -Depends: ${python:Depends}, ${misc:Depends}, libjs-jquery, libjs-jquery-mousewheel, python-tornado, python-jinja2, python-pil, python-pycurl, python-pkg-resources, lsb-base +Depends: ${python:Depends}, ${misc:Depends}, adduser, libjs-jquery, libjs-jquery-mousewheel, python-tornado, python-jinja2, python-pil, python-pycurl, python-pkg-resources, lsb-base Suggests: motion, ffmpeg, v4l-utils Description: web-based frontend for motion - A web frontend for the motion daemon, written in Python. + A web frontend for the motion daemon, written in Python: + - web-based, mobile/tablet-friendly user interface + - compatible with most USB cameras and the Raspberry PI camera module + - support for IP (network) cameras + - motion detection with email notifications and working schedule + - JPEG files for still images, AVI files for videos + - timelapse movies + - uploading media files to Google Drive and Dropbox diff --git a/debian/init b/debian/init index c9f7f3a..fed3d78 100755 --- a/debian/init +++ b/debian/init @@ -14,10 +14,11 @@ NAME="motioneye" PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin" -DAEMON="/usr/local/bin/meyectl" -PIDFILE="/var/run/$NAME.pid" +DAEMON="/usr/bin/meyectl" +RUNDIR="/var/run/$NAME" +PIDFILE="$RUNDIR/$NAME.pid" DESC="motionEye server" -USER="root" +USER="motioneye" OPTIONS="startserver -c /etc/motioneye/motioneye.conf -l -b" . /lib/lsb/init-functions @@ -28,6 +29,10 @@ RET=0 case "$1" in start) + if [ ! -d "$RUNDIR" ]; then + mkdir -p "$RUNDIR" + fi + chown $USER "$RUNDIR" log_daemon_msg "Starting $DESC" if start-stop-daemon --start --oknodo --exec $DAEMON --chuid $USER -- $OPTIONS; then log_end_msg 0 diff --git a/debian/patches/add_private_log_and_run_dirs b/debian/patches/add_private_log_and_run_dirs new file mode 100644 index 0000000..49cef13 --- /dev/null +++ b/debian/patches/add_private_log_and_run_dirs @@ -0,0 +1,34 @@ +Description: Use private log and run directories +Last-Update: 2018-06-04 +--- +This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ +Index: motioneye-dmo-0.39/extra/motioneye.conf.sample +=================================================================== +--- motioneye-dmo-0.39.orig/extra/motioneye.conf.sample 2018-06-04 10:20:43.710359615 +0200 ++++ motioneye-dmo-0.39/extra/motioneye.conf.sample 2018-06-04 10:20:43.706359602 +0200 +@@ -3,10 +3,10 @@ + conf_path /etc/motioneye + + # path to the directory where pid files go (must be writable by motionEye) +-run_path /var/run ++run_path /var/run/motioneye + + # path to the directory where log files go (must be writable by motionEye) +-log_path /var/log ++log_path /var/log/motioneye + + # default output path for media files (must be writable by motionEye) + media_path /var/lib/motioneye +Index: motioneye-dmo-0.39/extra/motioneye.systemd-unit +=================================================================== +--- motioneye-dmo-0.39.orig/extra/motioneye.systemd-unit 2018-03-31 22:21:38.000000000 +0200 ++++ motioneye-dmo-0.39/extra/motioneye.systemd-unit 2018-06-04 10:22:57.514714185 +0200 +@@ -3,6 +3,8 @@ + + [Service] + ExecStart=/usr/bin/meyectl startserver -c /etc/motioneye/motioneye.conf ++User=motioneye ++RuntimeDirectory=motioneye + Restart=on-abort + + [Install] diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..ec367da --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +add_private_log_and_run_dirs diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..12743a8 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,54 @@ +#!/bin/sh +# postinst script for motioneye +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + +# source debconf library +. /usr/share/debconf/confmodule + +case "$1" in + + configure) + # Create motioneye account and add to 'video' group + adduser --system --home /var/lib/motioneye motioneye + usermod --append --groups video motioneye + + # Fix directory ownership + chown motioneye /var/lib/motioneye + chown motioneye /var/log/motioneye + chown motioneye /etc/motioneye + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + exit 0 + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; + +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +db_stop + +exit 0 -- 2.39.5