View unanswered posts    View active topics

All times are UTC - 6 hours





Post new topic Reply to topic  [ 19 posts ] 
Go to page Previous  1, 2

Print view Previous topic   Next topic  
Author Message
Search for:
 Post subject:
PostPosted: Sat Nov 17, 2007 3:25 pm 
Offline
Joined: Sat Apr 24, 2004 9:43 pm
Posts: 11
I just tried the script and it seems to work fine. For my case anyway.
Running KnoppMyth R5F27. I had done an auto-upgrade over the same version to fix some video driver issues (that part worked). But in the process I had entered a different hostname. Everything seemed to work, except there were no upcoming recordings listed (because they were for the other hostname). I looked at the Mythtv docs, and I don't think the global replace of the old hostname with the new one would work in my case. My old hostname was actually 'mythtv'. So anywhere that appeared in a path (which is alot I think), it would has been replaced.


Thanks again to Everyone that works on Knoppmyth.

BTW- cesman- Great interview on the Geek and his Wife Podcast.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 16, 2008 5:04 pm 
Offline
Joined: Thu Jan 01, 2004 9:21 pm
Posts: 84
Location: Fort Collins, CO USA
TJC, could you elaborate on the instructions for using your script? I'm thinking the script replaces steps 3-6 of the Myth instructions (http://www.mythtv.org/docs/mythtv-HOWTO-23.html#ss23.15). Is that correct?

If so, and one accidentally renamed a box during an upgrade and wants to rename it back to what it was, would the procedure be to:

1. Stop all backends
2. Run mythbackup on the master backend and verify success
2. Change the hostname of the renamed box back to what it was before:
Code:
hostname originalname

3. Run your script on the master backend box
4. Restart all backends

With your caveats about the script being untested, is there anything that could go wrong assuming mythbackup/mythrestore can put it back the way it was?

And can I assume correctly that this should work on R5.5?

Thanks so much.

fyi... I didn't realize I had a capital letter as the first letter of one of my backends and made it all lower case when I upgraded. I knew very well not to rename, but didn't remember I had that capital letter. Now can't access recordings on that backend from other boxes.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 16, 2008 7:06 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
If you read the script you'll see that it actually has a usage message to tell you how to run it.
Code:
change_hostname.sh old_hostname new_hostname

It then tromps through all the DB tables it thinks contain a hostname column and updates any with "old_hostname" to "new_hostname". Basically it's a purpose built search and replace function.

What you proposed sounds sane (definitely make a backup!) with a few caveats.

1) The DB schema has changed since I wrote this, so there may be other tables you need to edit. I have a notion of how to find that automatically but don't have time to do it now.

2) You'll need to track down and change the other places in the file system that contain the wrong hostname. The mysql config (for listening) and the mythtv config (for connecting to the DB) among others. I'd start with a find | xargs grep command something like this:
Code:
find /etc /home /root -type f -print0 | xargs -0 grep -li BADHOSTNAME

You can ignore the .xsession-errors and kill the .Xauthority files. Any other files it finds may need to be corrected.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 08, 2008 5:56 pm 
Offline
Joined: Thu Mar 25, 2004 11:00 am
Posts: 9551
Location: Arlington, MA
Updated version for R5.5. I finally found a few minutes to check for new tables...
Code:
#!/bin/bash

old="$1"
new="$2"

fatal () {
    echo "Error! $*"
    exit 1
}
nl='
'
usage () {
    fatal "$*${nl}Usage: $0 old_hostname new_hostname"
}

[ $(id -u) -ne 0 ] && fatal "You must run this script as root!"
[ $# -ne 2 ] && usage "Bad argument count!"
[ -z "$old" ] && fatal "Old hostname can not be blank!"
[ -z "$new" ] && fatal "New hostname can not be blank!"

echo
echo "=============================== WARNING! =============================="
echo "This only changes the hostnames stored in the database. Also, if mysql"
echo "complains about uniqueness you'll need to resolve the issue manually."
echo "=============================== WARNING! =============================="
echo
read -p "Hit enter to continue, or Ctrl-C to abort."

# Tables which contain hostname
for table in capturecard displayprofilegroups inuseprograms jobqueue \
             jumppoints keybindings music_playlists musicplaylist \
             profilegroups recorded settings storagegroup \
             weatherscreens weathersourcesettings ; do
    mysql mythconverg -u root -e \
        "update $table set hostname = '$new' where hostname = '$old'"
done

# Tables which contain host
for table in mythlog ; do
    mysql mythconverg -u root -e \
        "update $table set host = '$new' where host = '$old'"
done

for table in inuseprograms ; do
    mysql mythconverg -u root -e \
        "update $table set rechost = '$new' where rechost = '$old'"
done

# No idea whether these need attention too...
# dbox2_host capturecard
# hostprefix tvchain


Top
 Profile  
 

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ] 
Go to page Previous  1, 2



All times are UTC - 6 hours




Who is online

Users browsing this forum: No registered users and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Theme Created By ceyhansuyu