Open Rolleroo opened 3 years ago
What about sudo ? My file /etc/sudoers.d/10-user
:
odroid ALL=(ALL) NOPASSWD:ALL
Just replace odroid
with user under which your OctoPrint was started, pi
for e.g. and reboot, then sudo pkill mjpg_streamer
starts working
Thanks for the response.
Not sure it is very elegant but ended up using this
echo "PWD" | sudo -S pkill mjpg_streamer
Where PWD is the password for pi user
OFFTOPIC: I prefered to have more structured setup of this things: systemd servise + environment generator
/etc/systemd/system/webcam.service
:
[Unit]
Description=Webcam
After=network.target
Requires=network.target
[Service]
Restart=always
WorkingDirectory=/root/mjpg-streamer/mjpg-streamer-experimental
EnvironmentFile=/root/mjpg-streamer/mjpg-streamer-experimental/environment
ExecStartPre=-/root/mjpg-streamer/mjpg-streamer-experimental/webcam-pre.sh
ExecStart=\
/root/mjpg-streamer/mjpg-streamer-experimental/_build/mjpg_streamer \
-i "input_uvc.so --resolution 1280x720 -d ${DEVICE} -y" \
-o "output_http.so -p 8090 -w ./www"
[Install]
WantedBy=multi-user.target
/root/mjpg-streamer/mjpg-streamer-experimental/webcam-pre.sh
:
#!/usr/bin/env sh
echo "DEVICE=$(/usr/bin/v4l2-ctl --media-bus-info usb-12110000.usb-1 --list-devices | grep video | head -n 1)" > /root/mjpg-streamer/mjpg-streamer-experimental/environment
Some additional preparations (from root):
apt install -y - v4l-utils cmake libjpeg8-dev
chmod +x /root/mjpg-streamer/mjpg-streamer-experimental/webcam-pre.sh
systemctl enable webcam
systemctl start webcam
I am trying to run the command below using a function call Reset Webcam:
sudo pkill mjpg_streamer
I am getting an error code thus:
I am guessing this is because of a lack of admin privledges. Please can you help out how I can make this work?
Apologies if this is a trivial fix as a bit of a Linus noob.
Roller