AlexGustafsson / homebridge-wol

A Wake on Lan plugin for Homebridge
MIT License
301 stars 30 forks source link

Can't turn off my PC #102

Closed mafyata closed 4 years ago

mafyata commented 4 years ago

Hi , I can turn on my PC , but can't turn off it. I was using same config.json on the same raspberry and was working perfect. This night my sd card had bricked and I made new sd card with homebridge. I use raspberry pi with raspbian buster 10. Homebridge: 1.0.4 WOL: 4.1.2

here is a log: [5/4/2020, 3:00:37 AM] [GAMDIAS] NetworkDevice "GAMDIAS" (10.0.1.200) went from status "Online" to "Shutting Down" [5/4/2020, 3:00:38 AM] [GAMDIAS] Attempting to shut down "GAMDIAS" (10.0.1.200) using "net" [5/4/2020, 3:00:38 AM] [GAMDIAS] An error occured while trying to shut down "GAMDIAS" (10.0.1.200): Error: Command failed: net rpc shutdown -I 10.0.1.200 -U Nikolay%PcPass /bin/sh: 1: net: not found

at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:310:20)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:443:11)
at Socket.emit (events.js:310:20)
at Pipe.<anonymous> (net.js:672:12) {

killed: false, code: 127, signal: null, cmd: 'net rpc shutdown -I 10.0.1.200 -U Nikolay%PcPass', stdout: '', stderr: '/bin/sh: 1: net: not found\n' } [5/4/2020, 3:00:38 AM] [GAMDIAS] Waiting for shutdown grace time (15000ms) for "GAMDIAS" (10.0.1.200) [5/4/2020, 3:00:53 AM] [GAMDIAS] NetworkDevice "GAMDIAS" (10.0.1.200) went from status "Shutting Down" to "Online"

tanmaster commented 4 years ago

Running this command on the raspberry pi should fix your problem: sudo apt-get install samba-common-bin

If you had to re-setup your pi you're most likely missing this package since it is not installed by default but it's required for remotely shutting down Windows computers.

iceddonut commented 4 years ago

@tan

Running this command on the raspberry pi should fix your problem: sudo apt-get install samba-common-bin

If you had to re-setup your pi you're most likely missing this package since it is not installed by default but it's required for remotely shutting down Windows computers.

Hi @tanmaster . what do you do if your running Homebridge in Docker on Synology NAS? Getting the same error when trying to turn off my Win10 computer. Thanks

tanmaster commented 4 years ago

Hi @tanmaster . what do you do if your running Homebridge in Docker on Synology NAS? Getting the same error when trying to turn off my Win10 computer. Thanks

@iceddonut I assume it's the same issue as the person before you. I am not familiar with the docker image, but if apt-get is available inside the container, you should be able to run the same command as above to install the package.

I don't know whats your setup like, but assuming that docker runs on the synology NAS, you most likely have to ssh into the NAS first, and then you should be able to run

docker ps

This will show you which containers are currently running along with the containers' IDs. Find your homebridge container's ID and run the following command:

docker exec -it CONTAINER_ID /bin/bash

This should create a new terminal for you where you can execute shell directly in the container. Afterwards, running sudo apt-get install samba-common-bin and restarting the container should do the work.

iceddonut commented 4 years ago

Hi @tanmaster . what do you do if your running Homebridge in Docker on Synology NAS? Getting the same error when trying to turn off my Win10 computer. Thanks

@iceddonut I assume it's the same issue as the person before you. I am not familiar with the docker image, but if apt-get is available inside the container, you should be able to run the same command as above to install the package.

I don't know whats your setup like, but assuming that docker runs on the synology NAS, you most likely have to ssh into the NAS first, and then you should be able to run

docker ps

This will show you which containers are currently running along with the containers' IDs. Find your homebridge container's ID and run the following command:

docker exec -it CONTAINER_ID /bin/bash

This should create a new terminal for you where you can execute shell directly in the container. Afterwards, running sudo apt-get install samba-common-bin and restarting the container should do the work.

Thanks @tanmaster for your reply! For some reason i was getting an "OCI runtime exec failed. /bin/bash no such file or directory" error. (I was logged in as ROOT) However I got working by running apk add samba-common-tools in the Homebridge Terminal GUI. Is that cool? Seems to work great. Thanks again

AlexGustafsson commented 4 years ago

This indeed seems to be an issue of lacking the samba tools. Great you were able to solve it! Is there anything I can do to help clarify this in the readme? Pull requests are always welcome if you have suggestions on how to improve documentation.

ericdhkim commented 4 years ago

Hi,

I'm having a similar issue and I have tried the samba install command you posted and terminal is telling me that I already have the latest version installed. I'm in the same boat where I can turn-on just fine, but cannot turn off. This is the result I see in Homebridge when I try to turn off:

An error occured while trying to shut down "Eric PC" (xxxxxxxxxx): Error: Command failed: sudo net rpc shutdown --ipaddress xxxxxxxxx --user xxxxx%xxxxxxxxxx

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

at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {

killed: false, code: 1, signal: null, cmd: 'sudo net rpc shutdown --ipaddress xxxxxxxxx --user xxxxx%xxxxxxxxxx', stdout: '', stderr: '\n' + 'We trust you have received the usual lecture from the local System\n' + 'Administrator. It usually boils down to these three things:\n' + '\n' + ' #1) Respect the privacy of others.\n' + ' #2) Think before you type.\n' + ' #3) With great power comes great responsibility.\n' + '\n' + 'sudo: no tty present and no askpass program specified\n' }

Any ideas what I'm doing wrong?

ericdhkim commented 4 years ago

Hi,

I'm having a similar issue and I have tried the samba install command you posted and terminal is telling me that I already have the latest version installed. I'm in the same boat where I can turn-on just fine, but cannot turn off. This is the result I see in Homebridge when I try to turn off:

An error occured while trying to shut down "Eric PC" (xxxxxxxxxx): Error: Command failed: sudo net rpc shutdown --ipaddress xxxxxxxxx --user xxxxx%xxxxxxxxxx

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

at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {

killed: false, code: 1, signal: null, cmd: 'sudo net rpc shutdown --ipaddress xxxxxxxxx --user xxxxx%xxxxxxxxxx', stdout: '', stderr: '\n' + 'We trust you have received the usual lecture from the local System\n' + 'Administrator. It usually boils down to these three things:\n' + '\n' + ' #1) Respect the privacy of others.\n' + ' #2) Think before you type.\n' + ' #3) With great power comes great responsibility.\n' + '\n' + 'sudo: no tty present and no askpass program specified\n' }

Any ideas what I'm doing wrong?

I was able to fix this! I had to: 1) Make sure the shutdown command wasn't running with sudo (weird that sudo was causing an issue). 2) I had to follow directions about creating a registry file on Windows on this site

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system] "LocalAccountTokenFilterPolicy"=dword:00000001

sc config RemoteRegistry start= auto sc start RemoteRegistry

iceddonut commented 4 years ago

Hi, I'm having a similar issue and I have tried the samba install command you posted and terminal is telling me that I already have the latest version installed. I'm in the same boat where I can turn-on just fine, but cannot turn off. This is the result I see in Homebridge when I try to turn off:

An error occured while trying to shut down "Eric PC" (xxxxxxxxxx): Error: Command failed: sudo net rpc shutdown --ipaddress xxxxxxxxx --user xxxxx%xxxxxxxxxx

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

at ChildProcess.exithandler (child_process.js:303:12)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) {

killed: false, code: 1, signal: null, cmd: 'sudo net rpc shutdown --ipaddress xxxxxxxxx --user xxxxx%xxxxxxxxxx', stdout: '', stderr: '\n' + 'We trust you have received the usual lecture from the local System\n' + 'Administrator. It usually boils down to these three things:\n' + '\n' + ' #1) Respect the privacy of others.\n' + ' #2) Think before you type.\n' + ' #3) With great power comes great responsibility.\n' + '\n' + 'sudo: no tty present and no askpass program specified\n' }

Any ideas what I'm doing wrong?

I was able to fix this! I had to:

  1. Make sure the shutdown command wasn't running with sudo (weird that sudo was causing an issue).
  2. I had to follow directions about creating a registry file on Windows on this site

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system] "LocalAccountTokenFilterPolicy"=dword:00000001

sc config RemoteRegistry start= auto sc start RemoteRegistry

Hi @ericdhkim . Try this instead. I forgot the extra samba needed. Run this at the terminal inside Homebridge GUI. apk add samba samba-common-tools

ericdhkim commented 4 years ago

Hi, I'm a relative noob to terminal. What do you mean inside Homebridge GUI? Do you mean I should navigate to my homebridge install location?

AlexGustafsson commented 4 years ago

Would any of you be interested in summing this up in a wiki post here on GitHub? There's been a lot of users facing issues with Linux and Samba to interact with a Windows machine, but you've seem to have solved it. I think you should be able to create a post here: https://github.com/AlexGustafsson/homebridge-wol/wiki.

AlexGustafsson commented 4 years ago

Closing as this seems to be solved. Feel free to reopen if that’s not the case.