Auto Reboot



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.



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


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



in the 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


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

(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


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



You can also add


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


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

A 20 second sleep then reboot solved it.