Bug#849712: motion: Motion starts but immediately exits when run as a daemon using systemd

2024-03-05 Thread Sudip Mukherjee
Control: severity -1 important
Control: tags -1 patch
--

Marking this bug as important as the package is mostly unusable by a 
non-technical user.
The motion.service can only start if the user manually creates /var/log/motion 
folder.

Patch attached to fix this. The suggested change was already part of the
motion init script but was dropped when updating it to systemd service.
The old code can be seen at: 
https://sources.debian.org/src/motion/4.1.1-1.1/debian/motion.init/#L60

-- 
Regards
Sudip
diff -Nru motion-4.6.0/debian/changelog motion-4.6.0/debian/changelog
--- motion-4.6.0/debian/changelog   2023-11-12 19:17:59.0 +
+++ motion-4.6.0/debian/changelog   2024-03-05 22:24:01.0 +
@@ -1,3 +1,10 @@
+motion (4.6.0-1.1) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Create log folder if it does not exist. (Closes: #849712)
+
+ -- Sudip Mukherjee   Tue, 05 Mar 2024 22:24:01 
+
+
 motion (4.6.0-1) unstable; urgency=medium
 
   * New upstream release
diff -Nru motion-4.6.0/debian/motion.postinst 
motion-4.6.0/debian/motion.postinst
--- motion-4.6.0/debian/motion.postinst 2023-02-03 12:28:41.0 +
+++ motion-4.6.0/debian/motion.postinst 2024-03-05 22:24:01.0 +
@@ -24,8 +24,16 @@
 fi
 }
 
+add_log_if_missing() {
+if ! [ -d /var/log/motion ]; then
+ mkdir -m 02750 /var/log/motion
+ chown motion:adm /var/log/motion
+fi
+}
+
 add_group_if_missing
 add_user_if_missing
+add_log_if_missing
 
 db_stop
 


Bug#849712: motion: Motion starts but immediately exits when run as a daemon using systemd

2021-08-13 Thread Andreas Harth

With motion_4.3.2-1_arm64.deb I also get the error message on installation.

The project seems active on Github [1], maybe it is worthwhile to raise an 
issue there?

[1] https://github.com/Motion-Project/motion



Bug#849712: motion: Motion starts but immediately exits when run as a daemon using systemd

2020-11-16 Thread Tomas Janousek
Hello everyone,

today I got the 4.3.2-1 upgrade and got this error as well:

Tim Edwards @ Fri, Dec 30, 2016 at 02:06:46PM +1100:
> motion[26465]: [17281408] [EMG] [ALL] motion_startup: Exit motion, cannot 
> create log file /var/log/motion/motion.log: Permission denied

The big problem is, I didn't just get the error in systemd journal, I got it
splattered over all open terminals. That seems a bit unnecessary, especially
considering I never used motion as a system service, I kept the package
installed just to have the "motion" binary available. The recent update
enabled the service and wrote garbage to all open terminals. Not nice.

Perhaps worth raising the severity?

-- 
Tomáš Janoušek, a.k.a. Pivník, a.k.a. Liskni_si, https://work.lisk.in/



Bug#849712: motion: Motion starts but immediately exits when run as a daemon using systemd

2016-12-29 Thread Tim Edwards
Package: motion
Version: 3.2.12+git20140228-8build1
Severity: normal

Dear Maintainer,

I've tried using motion as a systemd service, the problem is that it seems to 
die as soon as I start it. I suspect this the following things are stopping it 
running correctly:

- the package doesn't set '/var/log/motion/' to be owned by 'motion', which 
means the daemon can't write to its log file and dies
motion[26465]: [17281408] [EMG] [ALL] motion_startup: Exit motion, cannot 
create log file /var/log/motion/motion.log: Permission denied

- the package doesn't set /var/run/motion to be owned by motion:
[1404] [ERR] [ALL] [Dec 30 09:40:33] myfopen: Error opening file 
/var/run/motion/motion.pid with mode w+: Permission denied
[1404] [EMG] [ALL] [Dec 30 09:40:33] become_daemon: Exit motion, cannot 
create process id file (pid file) /var/run/motion/motion.pid: Permission denied

- motion doesn't look for the configuration file /etc/motion/motion.conf, it 
actually looks for /etc/motion.conf - I could resolve this with a symlink sudo 
ln /etc/motion/motion.conf /etc/motion.conf


tim@localhost:~$ systemctl status motion
● motion.service - LSB: Start Motion detection
   Loaded: loaded (/etc/init.d/motion; bad; vendor preset: enabled)
   Active: active (exited) since Fri 2016-12-30 09:40:33 AEDT; 4h 21min ago
 Docs: man:systemd-sysv-generator(8)
  Process: 26496 ExecStop=/etc/init.d/motion stop (code=exited, 
status=0/SUCCESS)
  Process: 26504 ExecStart=/etc/init.d/motion start (code=exited, 
status=0/SUCCESS)
Tasks: 0
   Memory: 0B
  CPU: 0

Dec 30 09:40:32 localhost systemd[1]: Starting LSB: Start Motion detection...
Dec 30 09:40:33 localhost motion[26504]:  * Starting motion detection daemon 
motion
Dec 30 09:40:33 localhost motion[26504]:...done.
Dec 30 09:40:33 localhost systemd[1]: Started LSB: Start Motion detection.
Dec 30 09:40:33 localhost motion[26511]: [1404] [NTC] [ALL] conf_load: 
Processing thread 0 - co
Dec 30 09:40:33 localhost motion[26511]: [1404] [NTC] [ALL] motion_startup: 
Motion 3.2.12+git20
Dec 30 09:40:33 localhost motion[26511]: [1404] [NTC] [ALL] motion_startup: 
Logging to file (/v

-- System Information:
Debian Release: stretch/sid
  APT prefers xenial-updates
  APT policy: (500, 'xenial-updates'), (500, 'xenial-security'), (500, 
'xenial'), (100, 'xenial-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.4.0-57-generic (SMP w/2 CPU cores)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages motion depends on:
ii  adduser3.113+nmu3ubuntu4
ii  debconf [debconf-2.0]  1.5.58ubuntu1
ii  libavcodec-ffmpeg-extra56  7:2.8.10-0ubuntu0.16.04.1
ii  libavfilter-ffmpeg57:2.8.10-0ubuntu0.16.04.1
ii  libavformat-ffmpeg56   7:2.8.10-0ubuntu0.16.04.1
ii  libavutil-ffmpeg54 7:2.8.10-0ubuntu0.16.04.1
ii  libc6  2.23-0ubuntu5
ii  libjpeg8   8c-2ubuntu8
ii  libmysqlclient20   5.7.16-0ubuntu0.16.04.1
ii  libpq5 9.5.5-0ubuntu0.16.04
ii  libsdl1.2debian1.2.15+dfsg1-3
ii  libsqlite3-0   3.11.0-1ubuntu1

Versions of packages motion recommends:
ii  ffmpeg  7:2.8.10-0ubuntu0.16.04.1

Versions of packages motion suggests:
pn  mysql-client   
pn  postgresql-client  

-- Configuration Files:
/etc/default/motion changed:
start_motion_daemon=yes

/etc/motion/motion.conf changed:
daemon on
process_id_file /var/run/motion/motion.pid
setup_mode off
logfile /var/log/motion/motion.log
log_level 6
log_type all
videodevice /dev/video1
v4l2_palette 17
; tunerdevice /dev/tuner0
input -1
norm 0
frequency 0
rotate 0
width 1280
height 960
framerate 1
minimum_frame_time 3
; netcam_url value
; netcam_userpass value
netcam_keepalive off
; netcam_proxy value
netcam_tolerant_check off
auto_brightness off
brightness 100
contrast 0
saturation 0
hue 0
roundrobin_frames 1
roundrobin_skip 1
switchfilter off
threshold 1500
threshold_tune off
noise_level 32
noise_tune on
despeckle_filter EedDl
; area_detect value
; mask_file value
smart_mask_speed 0
lightswitch 0
minimum_motion_frames 1
pre_capture 0
post_capture 0
event_gap 60
max_movie_time 0
emulate_motion off
output_pictures on
output_debug_pictures off
quality 75
picture_type jpeg
ffmpeg_output_movies on
ffmpeg_output_debug_movies off
ffmpeg_timelapse 0
ffmpeg_timelapse_mode daily
ffmpeg_bps 50
ffmpeg_variable_bitrate 0
ffmpeg_video_codec mpeg4
ffmpeg_deinterlace off
sdl_threadnr 0
use_extpipe off
;extpipe mencoder -demuxer rawvideo -rawvideo w=320:h=240:i420 -ovc x264 
-x264encopts 
bframes=4:frameref=1:subq=1:scenecut=-1:nob_adapt:threads=1:keyint=1000:8x8dct:vbv_bufsize=4000:crf=24:partitions=i8x8,i4x4:vbv_maxrate=800:no-chroma-me
 -vf denoise3d=16:12:48:4,pp=lb -of   avi -o %f.avi - -fps %fps
snapshot_interval 0
locate_motion_mode off
locate_motion_style box
text_right