[mythtv-users] mythfilldatabase run manually

Jim Abernathy jfabernathy at gmail.com
Thu Jan 9 14:47:49 UTC 2020


On 1/9/20 9:18 AM, Stephen Worthington wrote:
> On Thu, 9 Jan 2020 06:32:39 -0500, you wrote:
>
>> On 1/8/20 9:27 PM, Stephen Worthington wrote:
>>> On Wed, 8 Jan 2020 14:30:03 -0500, you wrote:
>>>
>>>> I have a mobile combo mythtv FE/BE on a RPi4 in my RV.  So it only have an internet connection when I turn my phone into a hotspot and the wireless AP/router bridge reestablishes a connection to the hotspot. As a result when mythfilldatabase runs it usually doesn’t succeed.
>>>>
>>>> So  what I do now is:
>>>> 1.  Turn on phone hotspot.
>>>> 2.  Open terminal and ‘sudo su mythtv’ then ‘mythfilldatabase’
>>>> 3.  Turn off phone hotspot.
>>>>
>>>> Anyone have a more automated way of doing this or is this the best I can hope for??
>>>>
>>>> Jim A
>>> It is possible to get a script to run when a network connection comes
>>> up - see /etc/network/if.up.  The system uses this, but it is possible
>>> to add your own scripts also.  I presume an RPi also works this way -
>>> it is a Debian and Debian based thing.  So you could have
>>> mythfilldatabase run when a network connection comes up the first time
>>> each day after the time it would normally be run.
>> After more research I see that maybe setting a systemd service is best
>> and have that service run after network-online.target. Now I just need
>> to see if I can make a service that:
>>
>> 1. runs everything the network comes up.
>>
>> 2. only runs mythfilldatabase once per day.
>>
>> Jim A
> Yes, systemd should be able to do it also.  But the
> network-online.target is not what you want.  It comes up as soon as
> one network interface is up, so that means it happens when localhost
> comes up.  You could use my wait-until-pingable.py program to ping the
> server that mythfilldatabase needs to talk to (if it is pingable).
> Create a systemd unit like my local-network-pingable.service:
>
> root at mypvr:/etc/systemd/system# cat local-network-pingable.service
> [Unit]
> Description=Wait for the local network to be pingable
> After=network.target
>
> [Service]
> Type=simple
> ExecStartPre=/bin/bash -c "/usr/local/bin/wait-until-pingable.py
> switch.jsw.gen.nz 30"
> ExecStart=/bin/true
>
> [Install]
> WantedBy=multi-user.target
>
> but change its name and the server it pings.
>
> Then you could create another systemd .service and .timer that runs
> mythfilldatabase on a timer daily but also runs shortly after startup
> if the time is already past the timer setting.  It would wait on your
> <epgserver up>.service to know that the Internet was available.
>
> You can download local-network-pingable.service and
> wait-until-pingable.py from my web server:
>
> http://www.jsw.gen.nz/mythtv/local-network-pingable.service
> http://www.jsw.gen.nz/mythtv/wait-until-pingable.py
>
> Here is an example of how I run a Python program twice a day (but also
> just after  booting) to take my noisy recording drives out of the
> storagegroup table at the times they would annoy me.
>
> root at mypvr:/etc/systemd/system# cat noisy-drives.service
> [Unit]
> Description=MythTV noisy drives service.
> Wants=mysql.service
> After=mysql.service
> Wants=mythtv-backend.service
> After=mythtv-backend.service
>
> [Service]
> ExecStart=/root/projects/mythsgu/noisy-drives.py 00:00:00 09:30:00
>
> [Install]
> WantedBy=multi-user.target
>
> root at mypvr:/etc/systemd/system# cat noisy-drives.timer
> [Unit]
> Description=MythTV noisy drives timer.
>
> [Timer]
> OnCalendar=02:30:00
> OnCalendar=14:30:00
> Persistent=true
>
> [Install]
> WantedBy=timers.target
>
> The noisy-drives.py program is also available for download:
>
> http://www.jsw.gen.nz/mythtv/noisy-drives.py

Thanks, Stephen, I have used your wait-until-pingable script before for 
something. Might work in this case as well.  I see a number of possible 
solutions. The RPi4 forces some issues though.

1. When I get to a new location with my RV and have A/C power connected, 
I then have to have the Hotspot connected and reboot the RPi4 so it can 
get the right internet time via NTP.

2. I then have to use tv_grab_zz_sdjson_sqlite to setup the EPG for my 
new zipcode location.

3. I then need to run mythtv-setup to delete the old channels and rescan.

4. Start the backend and run mythfilldatabase.

At this point I'm good to go until I move locations in a week or so.  
However, daily running of mythfilldatabase needs to happen. This is 
where I need to sync the turning on of the Hotspot and the running of 
mythfilldatabase.

So maybe using an if.up script might work best as long as I can make use 
the script only runs mythfilldatabase once a day and not every time I 
turn on the hotspot for other reasons.

Jim A





More information about the mythtv-users mailing list