Proper power off

  • So I understand it's not ideal to just pull the plug on an RPi so I'm trying to make sure that LibreELEC get's shutdown cleanly. I have been playing with getting a UPS working on it and setting it up to automatically shut down when power is removed (The unit I'm using is a LiFePO4wered/Pi3).

    Problem is when I remove the power and it shuts it down (after two minutes) I frequently see that when I plug power back in the unit doesn't ever get to the KODI boot screen just the first LibreELEC one. I then have to pull the power throughout the system, after which it reboots just fine.

    I have to be able to remove power from the system as it's going to live in a motorhome and may have it's power interuppted at anytime, I have the source for the daemon for the LiFePO4wered so I can mod it but I don't know what to call. It looks like from looking at the source it does this:

    Code
    void shutdown(void) { syslog(LOG_INFO, "LiFePO4wered/Pi triggered shutdown"); char *params[3] = {"init", "0", NULL}; execv("/sbin/init", params); }
  • Sounds like it's not shutting down properly.
    You'll need to provide a LOT more information. How are you running the daemon, what is the full code, can you confirm it has shut down completely.

    What do the logs say?

    Personally, I think you'd be better off just powering the RPi off of the motorhome's 12/24V battery power supply (With a converter). Should be able to power the RPi for weeks!

  • Okay I'll go grab logs, I think my real question is what command would I issue from a SSH prompt and expect a good clean shutdown it looks like thi sis using "init 0" I can link you to the full code for the dameon here: GitHub - xorbit/LiFePO4wered-Pi: Access library, command line tool and daemon for the LiFePO4wered/Pi module

    I've thought about running it off the 12V, but I don't want it just powering up randomly, I'm particularly sensitive about the use of any power in the rig as we boondock a lot (no external power). Also since there's a hard disk associated with it I don't want that spinning all the time. I also want this to be somewhat spouse proof. So it would be best if it just worked like another consumer component (i.e. the DVD player it's all replacing)

  • Thanks, again though will that signal kodi to do a clean shutdown, or is there some other thing I need to do to ensure that kodi comes down cleanly.


  • Thanks, again though will that signal kodi to do a clean shutdown, or is there some other thing I need to do to ensure that kodi comes down cleanly.

    I ave found this for LibreElec/kodi :

    - Edit the lifepo4wered-daemon.c file and change the shutdown function to this:

    void shutdown(void) {
    syslog(LOG_INFO, "LiFePO4wered/Pi triggered shutdown");
    char *params[6] = {"shutdown", "-h", "-t", "60", "now", NULL}; // shutdown halt in 10 seconds
    execv("/sbin/shutdown", params);
    }

    It's here : LiFePO4wered/Pi • Hackaday.io

  • I ave found this for LibreElec/kodi :

    - Edit the lifepo4wered-daemon.c file and change the shutdown function to this:

    void shutdown(void) {
    syslog(LOG_INFO, "LiFePO4wered/Pi triggered shutdown");
    char *params[6] = {"shutdown", "-h", "-t", "60", "now", NULL}; // shutdown halt in 10 seconds
    execv("/sbin/shutdown", params);
    }

    It's here : LiFePO4wered/Pi • Hackaday.io

    Thank you for posting I actually knew about that, it's exactly what I was asking about is that the correct way to clean shutdown Kodi...