Changing settings ExecStart on mjpg-streamer service?

Hey all, in trying to make MJPG-Streamer work with my cam, some of the startup settings need changing and I’m running into trouble. Hoping someone could clue me into the hierarchy of the ecosystem here and what I may be doing wronglike:

Required Information

  • DietPi version | G_DIETPI_VERSION_CORE=8
    G_DIETPI_VERSION_SUB=13
    G_DIETPI_VERSION_RC=2
    G_GITBRANCH=‘master’
    G_GITOWNER=‘MichaIng’
    G_LIVE_PATCH_STATUS[0]=‘applied’
    G_LIVE_PATCH_STATUS[1]=‘not applicable’
  • Distro version | bullseye
  • Kernel version | Linux DietPi 5.15.80-sunxi #22.11.1 SMP Wed Nov 30 11:13:48 UTC 2022 armv7l GNU/Linux
  • SBC model | NanoPi NEO (armv7l)
  • Power supply used | 5V 2A OnePlus brick over USB mini B
  • SD card used | Kingston 16GB Class 10

Additional Information (if applicable)

  • Software title | MJPG-Streamer
  • Was the software title installed freshly or updated/migrated? Fresh install
  • Can this issue be replicated on a fresh installation of DietPi? Probably?
    ← If you sent a “dietpi-bugreport”, please paste the ID here →
  • Bug report ID | (see spoiler below)

Steps to reproduce

  1. Install MJPG-Streamer, in my case it fails to launch by default due to bad video device/settings, so:
  2. Run dietpi-services
  3. Choose MJPG-Streamer
  4. Choose Edit (/etc/systemd/system/mjpg-streamer.service)
  5. Uncomment ExecStart and change the startup command settings here??

Expected behaviour

  • Editing the service’s config thru the dietpi-services menu should affect the service?

Actual behaviour

  • Service fails to start with “Loaded: bad-setting (Reason: Unit mjpg-streamer.service has a bad unit file setting.)”

Extra details

Looks like editing as explained above results in two ExecStart commands, as there appears to be two config files loaded that are conflicting?

/etc/systemd/system/mjpg-streamer.service
/etc/systemd/system/mjpg-streamer.service.d/dietpi-services_edit.conf

systemctl cat mjpg-streamer shows both of these files:

cat

root@DietPi:~# systemctl cat mjpg-streamer
# /etc/systemd/system/mjpg-streamer.service
[Unit]
Description=mjpg-streamer (DietPi)
Documentation=mjpg-streamer/mjpg-streamer-experimental at master · jacksonliam/mjpg-streamer · GitHub
Wants=network-online.target
After=network-online.target

[Service]
User=mjpg-streamer
WorkingDirectory=/opt/mjpg-streamer
ExecStart=/opt/mjpg-streamer/mjpg_streamer -i ‘input_uvc.so -d /dev/video0’ -o ‘output_http.so -p 8082 -n’

# Hardening
ProtectSystem=strict
PrivateTmp=true
ProtectHome=true
ProtectKernelTunables=true
ProtectControlGroups=true

[Install]
WantedBy=multi-user.target

# /etc/systemd/system/mjpg-streamer.service.d/dietpi-services_edit.conf
[Unit]
#Description=mjpg-streamer (DietPi)
#Documentation=mjpg-streamer/mjpg-streamer-experimental at master · jacksonliam/mjpg-streamer · GitHub
#Wants=network-online.target
#After=network-online.target

[Service]
#User=mjpg-streamer
#WorkingDirectory=/opt/mjpg-streamer
ExecStart=/opt/mjpg-streamer/mjpg_streamer -i ‘input_uvc.so -d /dev/video1 -r 1280x720 -f 30’ -o ‘output_http.so -p 8082 -n’

# Hardening
#ProtectSystem=strict
#PrivateTmp=true
#ProtectHome=true
#ProtectKernelTunables=true
#ProtectControlGroups=true

[Install]
#WantedBy=multi-user.target
root@DietPi:~#

systemctl edit mjpg-streamer
/etc/systemd/system/mjpg-streamer.service.d/.#override.conf0e20fa67dddddddd
### Editing /etc/systemd/system/mjpg-streamer.service.d/override.conf
### Anything between here and the comment below will become the new contents of the file

(then shows both of these config files)

systemctl start mjpg-streamer.service
Failed to start mjpg-streamer.service: Unit mjpg-streamer.service has a bad unit file setting.
See system logs and ‘systemctl status mjpg-streamer.service’ for details.

Options needed, nothing too wild:
/opt/mjpg-streamer/mjpg_streamer -i ‘input_uvc.so -d /dev/video1 -r 1280x720 -f 30’ -o ‘output_http.so -p 8082 -n’

Upon exiting DietPi-Services trying to restart MJPG-Streamer

Details:

  • Date | Thu Jan 19 18:11:16 GMT 2023
  • DietPi version | v8.12.1 (MichaIng/master)
  • Image creator | DietPi Core Team
  • Pre-image | Armbian
  • Hardware | NanoPi NEO (armv7l) (ID=60)
  • Kernel version | Linux DietPi 5.15.80-sunxi #22.11.1 SMP Wed Nov 30 11:13:48 UTC 2022 armv7l GNU/Linux
  • Distro | bullseye (ID=6)
  • Command | systemctl restart mjpg-streamer
  • Exit code | 1
  • Software title | DietPi-Services

Additional logs:

Failed to restart mjpg-streamer.service: Unit mjpg-streamer.service has a bad unit file setting.
See system logs and 'systemctl status mjpg-streamer.service' for details.

Edit the service again with dietpi-services and add a line ExecStart= before your tweak to clear the original setting.
Same problem with different service

Thanks, that did the trick. Not super intuitive, was about to start messing with systemctl editing the conf, and the PR linked in the other thread for PagerMC doesn’t address this for other apps, so might open an issue…