motioneye-project / motioneye

A web frontend for the motion daemon.
GNU General Public License v3.0
3.94k stars 650 forks source link

Add freebsd_init to extras please #2610

Open paulprocacci opened 1 year ago

paulprocacci commented 1 year ago

Attached you'll find a freebsd_init.txt file. (Should be renamed to freebsd_init but github wanted a file extension)

freebsd_init.txt

Please include this to your extras directory.

Appreciate it!

MichaIng commented 1 year ago

I suggest to merge BSDish setup into the existing linux_init script (which can be renamed). Make the service a dedicated file and use the existing example config but adjust only the settings/lines which really must be different on BSD. That way we minimise doubled code.

paulprocacci commented 1 year ago

A good suggestion. That would mean linux_init would need to be rewritten to NOT depend on bash and instead lean on normal sh semantics.

MichaIng commented 1 year ago

Ah, no bash on BSD? However, shouldn't be a big deal and has other benefits to be bourne shell compatible. I wanted to add some info output to the script anyway, probably read -p dialogs to give users more control about which steps are done. I can make bash => sh migration in the same turn.

Btw, there is an old PR to add better FreeBSD support. Would be great if this was updated/recreated based on dev branch: https://github.com/motioneye-project/motioneye/pull/1616

paulprocacci commented 1 year ago

The default and available shells on BSD are /bin/sh, /bin/csh and /bin/tcsh. /bin/sh on BSD is an IEEE Std1003.1specification for the shell designed by POSIX many moons ago. /bin/sh is guaranteed to be on all operating systems (even if linux, et al symlink them elsewhere).

bash can be installed, but then you're looking at additional and in my humble opinion uneeded requirements. It installs under /usr/local/bin so in that case you'd actually have to ensure all scripts' shebang line read '#!/usr/bin/env bash' so as to PATH gets used.

To ensure it works everywhere, at least as many locations as humanly possible, a shebang line that reads '#!/bin/sh' and follows IEEE Std 1003.1 is a safe bet of working no matter where it runs.

MichaIng commented 1 year ago

I'd actually use #!/usr/bin/env sh shebang nowadays, but both should work very reliably. However, I agree on all points. Also I want to invoke the script via scripts in setup.cfg instead of console_scripts as part of a Python function wrapper.

paulprocacci commented 1 year ago

As for the other reference to #1616 I read through it and even though I understand it's trying to add support for FreeBSD I'm not actually effected by any of the problems it's trying to fix.

For example, sha1sum exists on FreeBSD and the command works as described without needing a patch. command -v \ \ won't work on FreeBSD. It allows only a single argument. In this case, your suggestion would fail.

The whole disk section of detecting disks, I have no idea why motioneye is doing disk detection at all. In the motioneye control panel, it's seeing the disk it's writing to and properly reporting on usage, but besides this I have no idea what its purpose is for. I'm using zfs instead of ufs and perhaps that's the reason why it's working for me? I'm not sure.

Baenwort commented 1 year ago

Have these FreeBSD improvements made it into the dev branch?