Auto Reboot

rasplex

#1

I have my Rasplex Pi plugged into my avr with hdmi which is the connected to the tv with hdmi.

The problem is that on power on the avr and tv start on the wrong inputs and even if I change to the correct inputs I'm unable to control Rasplex with the remote.

If I login and reboot the Pi everything works normally after that.

What I'm hoping is that I can make a script to reboot the Pi about 30 seconds after first boot.

Kevin.


#2

Your problem its to differentiate a normal power on to a restart, because if not yor pi will be rebooting constantly
So you cant save that variable to memory, you need to save it to a file and compare both dates on boot.

So if the last check of the script to that file was less than 2 minutes ago dont reboot the pi, if it has been more than that then reboot

you can probably do it with a bash script that touches a file and you compare dates but you can still have problems if the pi doesnt have internet to check the correct time online


#3

I have the logic worked out but my problem is where to insert a call to my script in the bootup sequence.

Kevin


#4

in the autostart.sh you need to create inside /.config

but if I were you what I would do is restarting the CEC service in some way from that script, that would be a more elegant way of handling it


#5

Try this, but to be fair there must be a way to restart just that service or maybe without the & we could add a sleep and freeze the entire system the time you need before the boot system continues

#!/bin/sh
(sleep 30s;
systemctl restart kodi;) &

Im sure there are more elegant ways to do it but I really dont know how the cec service works and I dont have a compatible tv to test it


#6

Thank you for pointing me in the right direction. Working fine now.

Kevin


#7

You can also add

boot_delay=x

in the config.txt to halt the entire system when it boots, thats probably an even better way


#8

I tried the boot_delay first but there was no cec until PHT had started.

A 20 second sleep then reboot solved it.

Kevin