[mythtv] Hostname change broke mythtv, yet alittle more complicated than sed can fix...

Michael T. Dean mtdean at thirdcontact.com
Wed Oct 18 08:29:15 UTC 2006

On 10/18/06 02:47, Kenneth Padgett wrote:

>So it wasn't until after a change in hostname did I realize mythtv was
>going to break everything and loose track of my settings, recordings,
>everything basically, but even worse, it created new junk hostname
>settings and such I need to get rid of!!!
>The problem actually was caused by a swap out of routers and change in
>reverse DNS (which is how my box has been getting it's names). Anyway,
>the problem I have now is, through various router swaps/reconfigures,
>the box has taken on 3 different names over the past year (3 different
>routers w/ different DNS names wouldn't you know), and there's three
>sets of settings. The ones I want is mythtv.local, the others are
>pvr.lan and localhost.localdomain. The box is now named
>localhost.localdomain as I realized naming the box on the router's DNS
>is what was causing all this, so I give up with that. Also, I can't
>easily go back to mythtv.local on my router, I know, that would be too
>If I do the sed trick documented here:
>I'm going to end up duplicating settings table entries, and possibly
>other things, since I need to go to a host name that mythbackend
>apparently took it upon itself to start creating the moment the box
>booted up with the new name.
Is there any text-based problem that's more complicated than sed can 
fix?  Assuming you haven't recorded any programs with the bad hostnames:

$ cat mythtv_backup.sql |
sed /\'localhost.localdomain\'/d > mythtv_restore1.sql

$ cat mythtv_restore1.sql |
sed /\'pvr.lan\'/d > mythtv_restore2.sql

$ cat mythtv_restore2.sql |
sed s/\'mythtv.local\'/\'localhost.localdomain\'/g > mythtv_restore.sql

Or, you could just use the mysql client.  The sed approach has the 
benefit that it works across the whole database.

And, for a nice pretty, single command:

cat mythtv_backup.sql |
sed -e "/'localhost.localdomain'/d" \
    -e "/'pvr.lan'/d" \
    -e "s/'mythtv.local'/'localhost.localdomain'/g" > mythtv_restore.sql

Or, if you have recorded some shows with the bad hostnames:

cat mythtv_backup.sql |
sed -e "/recorded.*'pvr.lan'/ s/'pvr.lan'/'mythtv.local'/" \
    -e "/recorded.*'localhost.localdomain'/ 
s/'localhost.localdomain'/'mythtv.local'/" \
    -e "/'localhost.localdomain'/d" \
    -e "/'pvr.lan'/d" \
    -e "s/'mythtv.local'/'localhost.localdomain'/g" > mythtv_restore.sql

(Note that e-mail will probably break the 
"/recorded.*'localhost.localdomain'/..." line illegally.  All 
double-quoted expressions must be started and ended on a single line.)

In truth, the extra settings won't hurt anything (other than the fact 
that one of the bad hostnames is the hostname you wish to use now), so 
they wouldn't need to be deleted, but it doesn't hurt to clean them up.


More information about the mythtv-dev mailing list