User repetierserver has insufficient rights for executing a script

Hi together,

i am trying to execute a script as a printer command.
The script "Webcam.sh" is for focussing the webcam and contains:
sudo v4l2-ctl --set-ctrl=focus_auto=0
sudo v4l2-ctl --set-ctrl=focus_absolute=55

As the user "raspberry" i can execute it with:

bash /home/pi/Webcam.sh
When i try it with:
sudo -u repetierserver bash /home/pi/Webcam.sh
i get the following response:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.
[sudo] password for repetierserver:
I have already tried to follow the instructions from the manual on how to add the user to sudoers, but didn't get it to work.
Do you have any solutions for me

(PS:Other scrips are working, so i don't think it's a mistake in my extcommands.xml file)

Thanks  ;)

Comments

  • You must add v4l2-ctl to the sudoer list for user repetierserver to be allowed to do that. Easier/better is to add /home/pi/Webcam.sh to sudoer list and then call v4l2-ctl without sudo instead since script is already run as root. That execute it as 
    sudo /home/pi/Webcam.sh

    assuming first line in script is
    #!/bin/bash
    and permissions 755. To start it with bash is again breaking sudoer since you are calling bash for sudo and not the script and you do not want bash in that list since that allows executing everything as root.

    Simplest solution is to add this to /usr/local/Repetier-Setup/bin/mjpgStart at the end which starts the webcam in our image. It is run as root already. 

    In the long run I want it to automatically call a extra script for configuration depending on the port number so configs could be stored there as mjpgStart might get overwritten in future updates to add that function.
  • I used the solution with the mjpgStart file and its working fine.

    Thank you  ;)
Sign In or Register to comment.