Raspberry and Reboot from fhem

Begonnen von HarryT, 13 Juli 2017, 23:06:03

Vorheriges Thema - Nächstes Thema

HarryT

Hi I am trying to start a reboot of the rapsberry from  fhem with:

  system("sudo reboot &");

I tried this:
  http://ueberueck.com/index.php/fhem-hausautomatisierung/fhem-how-to-s/raspberry-aus-fhem-neu-starten

In my password file I have:
  fhem:x:999:20::/opt/fhem:/bin/bash

In groups I have:
  sudo:x:27:pi,fhem

In the fhem logging I get:

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


Has anybody succeeded in getting this to work? If so, how?

Thanks

FHEM 6.3 auf Raspberry Pi3  (1,2 Ghz)
RFXTRX433XL, ZWave, KFL200 and ConBeeIII
Raspberry Pi1 (0,7 Ghz) and Raspberry Pi4 for testing
German reading skills are good.

amenomade

What do you have in /etc/sudoers ?
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

HarryT

Hi

my /etc/sudoers: ( it is the standard version. as far as I see, it is sufficient to add fhem to the group sudoers)

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
FHEM 6.3 auf Raspberry Pi3  (1,2 Ghz)
RFXTRX433XL, ZWave, KFL200 and ConBeeIII
Raspberry Pi1 (0,7 Ghz) and Raspberry Pi4 for testing
German reading skills are good.

Manul

Zitat von: HarryT am 14 Juli 2017, 15:56:21
%sudo   ALL=(ALL:ALL) ALL

That would need to be


%sudo   ALL=(ALL:ALL) NOPASSWD: ALL


or better still


fhem ALL=(root) NOPASSWD: /sbin/shutdown

HarryT

Cool

  fhem ALL=(root) NOPASSWD: /sbin/shutdown

worked.

BTW I guess adding fhem to the sudoers group is not necessary when this line is add to the sudoers file?

Thanks
FHEM 6.3 auf Raspberry Pi3  (1,2 Ghz)
RFXTRX433XL, ZWave, KFL200 and ConBeeIII
Raspberry Pi1 (0,7 Ghz) and Raspberry Pi4 for testing
German reading skills are good.

Manul

Zitat von: HarryT am 14 Juli 2017, 18:26:05
BTW I guess adding fhem to the sudoers group is not necessary when this line is add to the sudoers file?

Right.