[mythtv] Patch for changing hostname problems
James Y. Knight
foom at fuhm.net
Tue Jul 22 17:49:48 EDT 2003
The following tiny patch allows you to override the machine's hostname
with a setting in mysql.txt called "LocalHostName". If you don't set
that, it uses the normal hostname, as before. If you do set that, it
ignores the normal hostname and uses whatever you put.
Index: programs/mythfrontend/mysql.txt
===================================================================
RCS file: /var/lib/mythcvs/mythtv/programs/mythfrontend/mysql.txt,v
retrieving revision 1.2
diff -u -p -r1.2 mysql.txt
--- programs/mythfrontend/mysql.txt 5 Feb 2003 19:46:51 -0000
1.2
+++ programs/mythfrontend/mysql.txt 22 Jul 2003 20:47:35 -0000
@@ -2,3 +2,11 @@ DBHostName=localhost
DBUserName=mythtv
DBPassword=mythtv
DBName=mythconverg
+
+# Set the following if you want to use something other than the
+# machine's real hostname for identifying settings in the database.
+# This is useful if your hostname changes often, as otherwise
+# you'll need to reconfigure mythtv (or futz with the DB) every time.
+# TWO HOSTS MUST NOT USE THE SAME VALUE
+
+#LocalHostName=my-unique-identifier-goes-here
Index: libs/libmyth/mythcontext.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmyth/mythcontext.cpp,v
retrieving revision 1.76
diff -u -p -r1.76 mythcontext.cpp
--- libs/libmyth/mythcontext.cpp 20 Jul 2003 02:29:41 -0000
1.76
+++ libs/libmyth/mythcontext.cpp 22 Jul 2003 20:47:36 -0000
@@ -41,16 +41,20 @@ MythContext::MythContext(const QString &
m_db = QSqlDatabase::addDatabase("QMYSQL3", "MythContext");
- char localhostname[1024];
- if (gethostname(localhostname, 1024))
- {
- cerr << "Error getting local hostname\n";
- exit(0);
- }
- m_localhostname = localhostname;
-
if (!LoadSettingsFiles("mysql.txt"))
cerr << "Unable to read configuration file mysql.txt" << endl;
+
+ m_localhostname = m_settings->GetSetting("LocalHostName", NULL);
+ if(m_localhostname == NULL)
+ {
+ char localhostname[1024];
+ if (gethostname(localhostname, 1024))
+ {
+ cerr << "Error getting local hostname\n";
+ exit(0);
+ }
+ m_localhostname = localhostname;
+ }
if (gui)
{
More information about the mythtv-dev
mailing list