[mythtv-users] easiest way to rename a myth host

Craig Sanders cas at taz.net.au
Tue Jan 6 00:19:00 UTC 2009


On Mon, Jan 05, 2009 at 10:23:57AM -0500, Michael T. Dean wrote:
> > is there any real need to do a complete dump
> 
> To make sure you have a fallback for when things go wrong...  (Though 
> this is completely optional as...)

well, yes, a backup is necessary. just in case. i do regular nighly
backups (using mysqldump) of all my mysql databases anyway.

now that i know about mythconverg_backup.pl, i'll start running it as
well. a quick look at the script shows that it does more than just a
plain mysqldump.

i was questioning the need to do a complete dump and restore just to
change a hostname, not the need to run a backup before changing the db.
the other URL mentioned in the thread talked about running a dump, using
sed to edit the dump, and restoring it. which seemed like overkill.

> >  and restore
> 
> You don't do a restore to change hostname.  The script changes it 
> (correctly) on the "live" database, as you can see in the referenced 
> instructions on the wiki page:
> 
> http://www.mythtv.org/wiki/index.php/Database_Backup_and_Restore#Change_the_hostname_of_a_MythTV_frontend_or_backend
> 
> "Note that changing the hostname is performed on an existing database 
> and does not restore a database."

i started reading that URL yesterday but stopped about a third of the
way through because it didn't occur to me that a script to rename a
hostname would be hidden in a script to restore the database. i wasn't
interested in backup & restore, i was interested in renaming a host.

so i wrote my own.

> There's a bit more to it than what's in your script, but if you look at 
> the mythconverg_restore.pl script you'll see it uses a very similar 
> process then does the rest.  

looks good. i'll use this. it does what my script would do and a
little more. the most important improvement is that instead of having
a hard-coded list of tables (i got my list by grepping for my hostname
in my latest mysqldump of mythconverg), it searches for tables with a
'hostname' field. it also fixes up tvchain and the 'value' field of the
settings table.

(interestingly, my myth installation has absolutely nothing in the
tvchain table, and no SGweightPerDir entries in the settings table,
which is why i missed them. so my script would have done the job for my
installation but wasn't correct for all situations)


> The /whole/ reason for putting the host rename into
> mythconverg_restore.pl is because we have too many contrib scripts
> that don't get maintained, so we didn't want another single-purpose
> script.

you say that as if single-purpose scripts are a bad thing.

i get your point about unmaintained scripts but putting too many
unrelated things into one script also has the unintended side-effect of
hiding the functionality.  which encourages re-invention of the wheel.

single-purpose scripts are the essence of the unix "small-tools"
approach where each tool does just one job extremely well rather than
trying to do everything.

IMO, a script called mythconverg_restore.pl should do nothing but
various kinds of restores of backups created by mythconverg_backup.pl

utility functions like renaming a hostname should either have
their own dedicated scripts or be rolled up into a script called
mythconverg_utils.pl




something relatively simple and short also provides an example for
others who want to report on or manipulate the mythconverg database.
being able to enhance or customise things to suit your own needs is one
of the huge benefits of using an open source program like myth rather
than whatever binary-only, undocumented, proprietary rubbish does a
similar job on windows.

e.g. i wrote another script which updates the record table to help make
sure that certain channels are recorded on certain tuners. i have
multiple DVB-T tuners, with varying levels of Rx sensitivity.  Two
channels in particular have a weak signal, so i like to make sure
they get recorded using particular cards in case i forget to set the
preferred input when setting up the recording. so i run a simple perl
script called 'myth-channel-affinity.pl' that does stuff like:

  UPDATE record set prefinput = 8 where prefinput = 0 AND chanid = 1002

it currently gets its list of channels and prefinputs from a hard-coded
hash in the script. which is good enough for a Q&D hack but really
should be in a config file or even a table in mythconverg.


craig

-- 
craig sanders <cas at taz.net.au>

Give me Librium or give me Meth.


More information about the mythtv-users mailing list