system hangs while powering off when using shutdown.sh

  • Hi all,

    I know that it is a "misusage" by me, but would be grateful for any help.

    What I'm trying to achieve is this. I installed LibreELEC 8.2.0 / 8.2.0.1 on two systems:
    1. Intel HTPC (x86_64), acting as a TVheadend server (DVB-C adpater, ...)
    2. Raspberry Pi 2b as client in another room where I am watching TV

    When I switch the power off using a remote control with the rasbpi I want the HTPC to shutdown too. For this I tried to use a ssh forced command. Authentication is done using public keys without passphrase (see Config connect ssh wo password).

    What I found out until now is that this mechanism works perfectly if I am logged in interactively in my client. But when it is executed from KODI - using shutdown.sh - the raspbi hangs in ssh (my guess) and the server runs still.

    Please find attached my current approach. I tried several options to ssh including "-n". Any suggestions / comments would be appriciated.

    THX

  • How how your ssh command need to complete? You can't run long running commands in shutdown.sh. Also there is a problem with network which can also be shutdown in the middle of your command.

    Proper way is using new service for shutdown. I made this sometime back and should be on forum. But can't find it right now.

    Update: found it.

    shutdown.sh is executed after network is down

    External Content pastebin.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

  • Hi mglae. I tried the logging, but gave nothing (probably for the reasons given by vpeter).

    OK, vpeter. I hoped that this could be avoided.

    What I came up with yesterday evening is a simple TCP-Server (my first Python script ;-), see appended code, which is run on the server in autostart.sh. In shutdown.sh then this service gets called:

    Code
    poweroff | reboot)
          telnet track 2017 <<EOF
    $1
    EOF
          ;;
  • Many thanks for investigating the network topic vpeter!

    I am not sure if I correctly understand your service experiment. But the TCP-Server "farewell.py" appended to post #4 works like a charm. So there must be network service when I telnet to port 2017 on my server (track is the DNS name) in shutdown.sh.

    I added some log messages which yields (192.168.8.97 being the IP address of the rasbpi):

    Code
    ('192.168.8.97', 52814) connected at: 2017-11-09 14:13:49.724839
    Requesting poweroff