I try to reboot my Pi using a Switch on Openhab2.
I created a file /var/www/html/ResetPi.sh that contain the command 'reboot’
Then I used:
sudo chown root:root /var/www/html/ResetPi.sh
sudo chmod 700 /var/www/html/ResetPi.sh
Using Visudo I wrote the line: openhabian ALL=(ALL) NOPASSWD: /var/www/html/ResetPi.sh
I create a rule when a Switch is changed to ON then:
var String response3 = executeCommandLine(“sudo /var/www/html/ResetPi.sh”,1000)
And I receive the 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: no tty present and no askpass program specified*
If in that rule I try :
var String response3 = executeCommandLine(“sudo -u openhab ssh openhabian@192.168.XX.XX sudo /var/www/html/ResetPi.sh now”,1000)
then I receive the response:
Permission denied (publickey,password)
In Putty if I use the command “sudo /var/www/html/ResetPi.sh” or “sudo reboot”, the Raspberry Pi is rebooting.
What do I do wrong? Thanks!