summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/tweaker/bin/twk_general.pl
blob: 387920c7fb525529129d458c249b3c19d3b51375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
#!/usr/bin/perl -w

# Copyright 2007-2009 Robert ("Bob") Igo of StormLogic, LLC and mythic.tv.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

use Switch;
use Tweaker::Script;
package Tweaker::Script;

set_known_options( 'all' );

# Try to implement the given option.
sub implement_option {
    my($option) = @_;

    # KnoppMyth-centric file-level tweaks
    sub file_tweaks {
	my($option) = @_;

	my @commands = (
	    # keymap tweaks
	    "twk_keymap.sh"
	    );

	foreach my $command (@commands) {
	    if (my $error = execute_shell_command($command)) {
		my $logger = get_logger('tweaker.script');
		$logger->error("$error");
		$logger->error("Unable to implement option $option with command $command.");
	    }
	}
	return 1;
    }

    # Enhance the default MythTV SQL
    sub SQL_tweaks {
	my($option) = @_;

	$dbconnectionstring = get_mythtv_connection_string();

	if (connect_to_db("DBI:mysql:$dbconnectionstring")) {
	    # ??? This also exists in mkmythdir - it should be centralized
	    my $SQL_DirData="/myth";			# Top level dir. of structure,
	    my $SQL_DirTV="$SQL_DirData/tv";		# TV Recordings,
	    my $SQL_DirMusic="$SQL_DirData/music/";	# Music storage,
	    my $SQL_DirGames="$SQL_DirData/games";	# Games dir,
	    my $SQL_DirPics="$SQL_DirData/gallery";	# Pictures directory.
	    my $SQL_DirTmp="$SQL_DirData/tmp";		# DVD temp
	    my $SQL_DirVideo="$SQL_DirData/video";	# videos

	    # ??? Eventually, put these into a text file so that 1) people can contribute without having to code, and 2) the data
	    # stays separate from the code and can be re-used by other (non-Perl) implementations

	    #
	    # keybindings
	    #
	    change_or_make_entry("keybindings", [["keylist", "l"]], [["context", "Gallery"], ["action","PLAY"]]);
	    change_or_make_entry("keybindings", [["keylist", ">"]], [["context", "Music"], ["action","FFWD"]]);
	    change_or_make_entry("keybindings", [["keylist", "<"]], [["context", "Music"], ["action","RWND"]]);
	    change_or_make_entry("keybindings", [["keylist", "PgDown,.,Z,End"]], [["context", "Music"], ["action","NEXTTTRACK"]]);
	    change_or_make_entry("keybindings", [["keylist", "PgUp,Q,Home"]], [["context", "Music"], ["action","PREVTRACK"]]);
	    change_or_make_entry("keybindings", [["keylist", "P,l"]], [["context", "Music"], ["action","PAUSE"]]);

	    change_or_make_entry("keybindings", [["keylist", ">"]], [["context", "Stream"], ["action","FORWARD"]]);
	    change_or_make_entry("keybindings", [["keylist", "<"]], [["context", "Stream"], ["action","REWIND"]]);
	    change_or_make_entry("keybindings", [["keylist", "F"]], [["context", "Stream"], ["action","FULLSCREEN"]]);
	    change_or_make_entry("keybindings", [["keylist", "|,\\,F9,Volume Mute"]], [["context", "Stream"], ["action","MUTE"]]);
	    change_or_make_entry("keybindings", [["keylist", "Y"]], [["context", "Stream"], ["action","STOREMARKED"]]);

	    change_or_make_entry("keybindings", [["keylist", "l"]], [["context", "TV Frontend"], ["action","PLAYBACK"]]);

	    change_or_make_entry("keybindings", [["keylist", "l"]], [["context", "TV Playback"], ["action","PLAY"]]);
	    change_or_make_entry("keybindings", [["keylist", "P"]], [["context", "TV Playback"], ["action","PAUSE"]]); # default, but here for completeness

	    #
	    # better awareness of different video extensions
	    #
	    change_or_make_entry("videotypes", [["playcommand", "mplayer-resumer.pl -fs -zoom -vc theora,fftheora, -vo xv %s"]], [["extension", "ogg"]]);
	    change_or_make_entry("videotypes", [["playcommand", "mplayer-resumer.pl -fs -zoom -vc theora,fftheora, -vo xv %s"]], [["extension", "theora"]]);
	    foreach my $video_ext ("mp2", "tp", "ts", "m2p", "nuv", "mkv") {
		change_or_make_entry("videotypes", [["playcommand", "Internal"], ["f_ignore", "0"], ["use_default", "1"]], [["extension", $video_ext]]);
	    }
	    foreach my $non_video_ext ("jpg", "par2") {
		change_or_make_entry("videotypes", [["f_ignore", "1"]], [["extension", $non_video_ext]]);
	    }

	    #
	    # games, game players, and emulators
	    #
	    my @players = (
		 [ 'SDLMAME', '/myth/games/xmame/roms', '/myth/games/xmame/screenshots', '/usr/games/mame -rp /myth/games/xmame/roms %s', 'MAME' ],
		 [ 'ZSNES','/myth/games/snes/roms','/myth/games/snes/screens','/usr/bin/zsnes','SNES' ],
		 [ 'FCEU','/myth/games/nes/roms','/myth/games/nes/screens','/usr/games/fceu','NES' ],
		 [ 'Frozen Bubble', '', '', '/usr/games/frozen-bubble --fullscreen','PC' ]
		);

	    foreach my $player (@players) {
		# These INSERTs will fail if the playername is already present, but we don't error out if it happens.
		do_query("INSERT INTO gameplayers (playername, rompath, screenshots, commandline, gametype) VALUES ('".join("','",@$player)."');");
	    }
	    # somewhat hardwired, but make sure Frozen Bubble shows up in the list of playable games.
	    do_query("INSERT INTO gamemetadata (system, romname, gamename, genre, year, publisher, rompath, gametype) VALUES ('".
		     join("','",($players[3][0], $players[3][3], $players[3][0], "action/puzzle", "2006", "Frozen Bubble Team", "/usr/games", $players[3][4]))."');");

	    #
	    # smart music playlists
	    #
	    # categoryid, name
	    change_or_make_entry("music_smartplaylist_categories", [["name", "Decades"]], [["categoryid", 1]]);
	    change_or_make_entry("music_smartplaylist_categories", [["name", "Favorite Tracks"]], [["categoryid", 2]]);
	    change_or_make_entry("music_smartplaylist_categories", [["name", "New Tracks"]], [["categoryid", 3]]);

	    foreach my $decade (60, 70, 80, 90, 100) {
		my $id = ($decade / 10) - 5;
		my $query = "INSERT INTO music_smartplaylist_items (smartplaylistid, field, operator, value1, value2) VALUES ($id, 'Year', 'is between'," . ($decade+1900) . "," . ($decade+1909) . ");";
		do_query($query);
		$query = "INSERT INTO music_smartplaylists (name, categoryid, matchtype, orderby, limitto) VALUES ('". ($decade+1900) . "\\'s', 1, 'All', 'Artist (A)', 0);";
		do_query($query);
	    }

	    my @other_lists = (
		[
		 ( 'Rating', 'is greater than', '7', 'Favorite Tracks', 2, 'Artist (A), Album (A)', 0 ),
		 ( 'Play Count', 'is greater than', '0', '100 Most Played Tracks', 2, 'Play Count (D)', 100 ),
		 ( 'Play Count', 'is equal to', '0', 'Never Played Tracks', 3, 'Artist (A), Album (A)', 0 )
		]);

	    my $id=6;
	    foreach my $other_list (@other_lists) {
		change_or_make_entry("music_smartplaylist_items", [["field", @$other_list[0]], ["operator", @$other_list[1]], ["value1", @$other_list[2]]], [["smartplaylistid", $id]]);
		change_or_make_entry("music_smartplaylists", [["name", @$other_list[3]], ["categoryid", @$other_list[4]], ["matchtype", "All"], ["orderby", @$other_list[5]], ["limitto", @$other_list[6]]], [["smartplaylistid", $id]]);
		$id++;
	    }

	    #
	    # default playgroup with time-related settings
	    #
	    change_or_make_entry("playgroup", [["skipahead", 10], ["skipback", 5], ["timestretch", 100], ["jump", 1]], [["name", "Default"]]);

	    #
	    # useful recording profiles and transcoding options
	    #
	    change_or_make_entry("profilegroups", [["name", "Software Encoders (v4l based)"], ["cardtype", "V4L"], ["is_default", 1]], [["id", 1]]);
	    change_or_make_entry("profilegroups", [["name", "MPEG-2 Encoders (PVR-x50, PVR-500)"], ["cardtype", "MPEG"], ["is_default", 1]], [["id", 2]]);
	    change_or_make_entry("profilegroups", [["name", "Hardware MJPEG Encoders (Matrox G200-TV, Miro DC10, etc)"], ["cardtype", "MJPEG"], ["is_default", 1]], [["id", 3]]);
	    change_or_make_entry("profilegroups", [["name", "Hardware HDTV"], ["cardtype", "HDTV"], ["is_default", 1]], [["id", 4]]);
	    change_or_make_entry("profilegroups", [["name", "Hardware DVB Encoders"], ["cardtype", "DVB"], ["is_default", 1]], [["id", 5]]);
	    change_or_make_entry("profilegroups", [["name", "Transcoders"], ["cardtype", "TRANSCODE"], ["is_default", 1]], [["id", 6]]);
	    change_or_make_entry("profilegroups", [["name", "FireWire Input"], ["cardtype", "FIREWIRE"], ["is_default", 1]], [["id", 7]]);
	    change_or_make_entry("profilegroups", [["name", "USB Mpeg-4 Encoder (Plextor ConvertX, etc)"], ["cardtype", "GO7007"], ["is_default", 1]], [["id", 8]]);
	    change_or_make_entry("profilegroups", [["name", "DBOX2 Input"], ["cardtype", "DBOX2"], ["is_default", 1]], [["id", 9]]);
	    change_or_make_entry("profilegroups", [["name", "Freebox Input"], ["cardtype", "Freebox"], ["is_default", 1]], [["id", 10]]);
	    change_or_make_entry("profilegroups", [["name", "HDHomeRun Recorders"], ["cardtype", "HDHOMERUN"], ["is_default", 1]], [["id", 11]]);
	    change_or_make_entry("profilegroups", [["name", "CRC IP Recorders"], ["cardtype", "CRC_IP"], ["is_default", 1]], [["id", 12]]);

	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'transcodelossless', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'transcoderesize', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg4bitrate', 2200)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg4maxquality', 2)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg4minquality', 15)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg4qualdiff', 3)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'scalebitrate', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg4optionvhq', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg4option4mv', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg4optionidct', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg4optionime', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'encodingthreadcount', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg2bitrate', 4500)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'hardwaremjpegquality', 100)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'hardwaremjpeghdecimation', 4)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'hardwaremjpegvdecimation', 4)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg2streamtype', 'MPEG-2 PS')");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'mpeg2maxbitrate', 6000)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'samplerate', 48000)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (21, 'volume', 100)");

	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'transcodelossless', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'transcoderesize', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg4bitrate', 2200)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg4maxquality', 2)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg4minquality', 15)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg4qualdiff', 3)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'scalebitrate', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg4optionvhq', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg4option4mv', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg4optionidct', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg4optionime', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'encodingthreadcount', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg2bitrate', 4500)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'hardwaremjpegquality', 100)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'hardwaremjpeghdecimation', 4)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'hardwaremjpegvdecimation', 4)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg2streamtype', 'MPEG-2 PS')");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'mpeg2maxbitrate', 6000)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'samplerate', 48000)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (22, 'volume', 100)");

	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (27, 'transcodelossless', 1)");

	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'transcodelossless', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'transcoderesize', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg4bitrate', 2200)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg4maxquality', 2)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg4minquality', 15)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg4qualdiff', 3)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'scalebitrate', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg4optionvhq', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg4option4mv', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg4optionidct', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg4optionime', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'encodingthreadcount', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg2bitrate', 4500)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'hardwaremjpegquality', 100)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'hardwaremjpeghdecimation', 4)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'hardwaremjpegvdecimation', 4)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg2streamtype', 'MPEG-2 PS')");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'mpeg2maxbitrate', 6000)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'samplerate', 48000)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (28, 'volume', 100)");

	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'transcodelossless', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'transcoderesize', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg4bitrate', 1500)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg4maxquality', 2)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg4minquality', 15)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg4qualdiff', 3)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'scalebitrate', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg4optionvhq', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg4option4mv', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg4optionidct', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg4optionime', 0)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'encodingthreadcount', 1)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg2bitrate', 4500)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'hardwaremjpegquality', 100)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'hardwaremjpeghdecimation', 4)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'hardwaremjpegvdecimation', 4)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg2streamtype', 'MPEG-2 PS')");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mpeg2maxbitrate', 6000)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'samplerate', 44100)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'mp3quality', 7)");
	    do_query("INSERT INTO codecparams (profile, name, value) VALUES (29, 'volume', 100)");


	    # I don't know why we have so many of these.  Only profilegroup 6 seems to matter.
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 1]], [["id", 1]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 1]], [["id", 2]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 1]], [["id", 3]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 1]], [["id", 4]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 2]], [["id", 5]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 2]], [["id", 6]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 2]], [["id", 7]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 2]], [["id", 8]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 3]], [["id", 9]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 3]], [["id", 10]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 3]], [["id", 11]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 3]], [["id", 12]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 4]], [["id", 13]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 4]], [["id", 14]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 4]], [["id", 15]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 4]], [["id", 16]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 5]], [["id", 17]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 5]], [["id", 18]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 5]], [["id", 19]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 5]], [["id", 20]]);
	    change_or_make_entry("recordingprofiles", [["name", 'RTjpeg/MPEG4'], ["profilegroup", 6], ["videocodec", "MPEG-4"], ["audiocodec", "Uncompressed"]], [["id", 21]]);
	    change_or_make_entry("recordingprofiles", [["name", 'MPEG2'], ["profilegroup", 6], ["videocodec", "MPEG-4"], ["audiocodec", "Uncompressed"]], [["id", 22]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 8]], [["id", 23]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 8]], [["id", 24]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 8]], [["id", 25]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 8]], [["id", 26]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 6]], [["id", 27]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Medium Quality'], ["profilegroup", 6], ["videocodec", "MPEG-4"], ["audiocodec", "Uncompressed"]], [["id", 28]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 6], ["videocodec", "MPEG-4"], ["audiocodec", "MP3"]], [["id", 29]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 10]], [["id", 30]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 10]], [["id", 31]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 10]], [["id", 32]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 10]], [["id", 33]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 11]], [["id", 34]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 11]], [["id", 35]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 11]], [["id", 36]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 11]], [["id", 37]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 12]], [["id", 38]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 12]], [["id", 39]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 12]], [["id", 40]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 12]], [["id", 41]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 7]], [["id", 42]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 7]], [["id", 43]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 7]], [["id", 44]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 7]], [["id", 45]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Default'], ["profilegroup", 9]], [["id", 46]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Live TV'], ["profilegroup", 9]], [["id", 47]]);
	    change_or_make_entry("recordingprofiles", [["name", 'High Quality'], ["profilegroup", 9]], [["id", 48]]);
	    change_or_make_entry("recordingprofiles", [["name", 'Low Quality'], ["profilegroup", 9]], [["id", 49]]);

	    #
	    # settings
	    #
	    change_or_make_setting('AlwaysStreamFiles', '1'); # new in R6
	    change_or_make_setting('AutoCommercialSkip', '1');
	    change_or_make_setting('AutoExpireWatchedPriority', '1');
	    change_or_make_setting('BackendServerPort', '6543');
	    change_or_make_setting('BackendStatusPort', '6544');
	    change_or_make_setting('CDWriterDevice', 'ATA:1,0,0');
#	    change_or_make_setting('ChannelOrdering', 'chanid');
	    change_or_make_setting('CommercialSkipMethod', '255');
	    change_or_make_setting('DVDBookmarkPrompt', '1');
	    change_or_make_setting('DVDRipLocation', $SQL_DirTmp);
	    change_or_make_setting('DefaultRipQuality', '1');
	    change_or_make_setting('DefaultTranscoder', '28'); # change this number if you redefine the transcoders above
	    change_or_make_setting('Deinterlace', '1');
	    change_or_make_setting('DeletesFollowLinks', '1');
	    change_or_make_setting('DisableFirewireReset', '0');
	    change_or_make_setting('EITCrawIdleStart','60');
	    change_or_make_setting('EITIgnoresSource','0');
	    change_or_make_setting('EITTimeOffset','Auto');
	    change_or_make_setting('EITTransportTimeout','5');
	    change_or_make_setting('EPGEnableJumpToChannel','1');
	    change_or_make_setting('EPGFillType','12');
	    change_or_make_setting('EnableDVDBookmark','1');
	    change_or_make_setting('EndOfRecordingExitPrompt','1');
	    change_or_make_setting('GalleryDir', $SQL_DirPics);
	    change_or_make_setting('GalleryRecursiveSlideshow', '1');
#------------------------JM---------------------------
 	    change_or_make_setting('HaltCommand', 'sudo /sbin/halt');
# 	    change_or_make_setting('HostAudiotype','ALSA');
# 	    change_or_make_setting('HostMiro','1');
# 	    change_or_make_setting('HostXine','1');
# 	    change_or_make_setting('Hostpluginmythappletrailers','1');
# 	    change_or_make_setting('Hostpluginmytharchive','1');
# 	    change_or_make_setting('Hostpluginmythbrowser','1');
# 	    change_or_make_setting('Hostpluginmythcontrols','1');
# 	    change_or_make_setting('Hostpluginmythflix','1');
# 	    change_or_make_setting('Hostpluginmythgallery','1');
# 	    change_or_make_setting('Hostpluginmythgame','1');
# 	    change_or_make_setting('HostpluginmythgameFceu','1');
# 	    change_or_make_setting('HostpluginmythgameMame','1');
# 	    change_or_make_setting('HostpluginmythgameMame','1');
# 	    change_or_make_setting('HostpluginmythgameROMDB','1');
# 	    change_or_make_setting('HostpluginmythgameXE','1');
# 	    change_or_make_setting('HostpluginmythgameZsnes','1');
# 	    change_or_make_setting('HostpluginmythgameZsnes','1');
# 	    change_or_make_setting('Hostpluginmythmovietime','1');
# 	    change_or_make_setting('Hostpluginmythmusic','1');
# 	    change_or_make_setting('Hostpluginmythnews','1');
# 	    change_or_make_setting('Hostpluginmythphone','1');
# 	    change_or_make_setting('Hostpluginmythsmolt','1');
# 	    change_or_make_setting('Hostpluginmythstream','1');
# 	    change_or_make_setting('Hostpluginmythvideo','1');
# 	    change_or_make_setting('Hostpluginmythvideo_dvdcss','0');
# 	    change_or_make_setting('Hostpluginmythvideo_dvdcss','0');
# 	    change_or_make_setting('Hostpluginmythvodka','1');
# 	    change_or_make_setting('Hostpluginmythweather','1');
	    change_or_make_setting('JobAllowCommFlag', '1');
	    change_or_make_setting('JobAllowTranscode', '1');
	    change_or_make_setting('JobAllowUserJob1', '1');
	    change_or_make_setting('JobAllowUserJob2', '2');
	    change_or_make_setting('JobQueueCPU','0');
	    change_or_make_setting('JobQueueCheckFrequency','60');
	    change_or_make_setting('JobQueueCommFlagCommand','mythcommflag');
	    change_or_make_setting('JobQueueMaxSimultaneousJobs','1');
	    change_or_make_setting('JobQueueTranscodeCommand','mythtranscode');
	    change_or_make_setting('JobQueueWindowEnd','23:59');
	    change_or_make_setting('JobQueueWindowStart','00:00');
	    change_or_make_setting('JobsRunOnRecordHost','0');
	    change_or_make_setting('LiveTVInAllPrograms','1');
	    change_or_make_setting('MasterMixerVolume','100');
# 	    change_or_make_setting('MasterServerIP', '127.0.0.1');
# 	    change_or_make_setting('MasterServerPort', '6543');
	    change_or_make_setting('MediaChangeEvents','1');
	    change_or_make_setting('MonitorDrives', '1');
	    change_or_make_setting('MusicLocation', $SQL_DirMusic);
	    change_or_make_setting('MythArchivePng2yuvCmd', 'png2yuv'); # ??? still used?
	    change_or_make_setting('MythArchiveShareDir','/myth/archive/');
	    change_or_make_setting('MythArchiveTempDir', $SQL_DirTmp);
	    change_or_make_setting('MythFillDatabaseArgs', '--quiet');
	    change_or_make_setting('MythFillDatabaseLog', '/var/log/mythtv/mythfilldatabase.log');
	    change_or_make_setting('MythFillDatabasePath', '/usr/bin/nice -n 19 /usr/bin/mythfilldatabase');
	    change_or_make_setting('MythFillEnabled', '1');
	    change_or_make_setting('MythTVtv', $SQL_DirTV);
	    change_or_make_setting('NetworkControlEnabled', '1');
	    change_or_make_setting('PCMMixerVolume', '50');
	    change_or_make_setting('PVR350VideoDev', '/dev/video16');
	    change_or_make_setting('PlayBoxShading', '0');
	    change_or_make_setting('PlayMode', 'none');
	    change_or_make_setting('PlaybackExitPrompt', '2');
	    change_or_make_setting('PlaybackPreviewLowCPU', '1');
#	    change_or_make_setting('PlaybackReturnPrompt', '1');
#	    change_or_make_setting('PlaybackReturnPrompt', '2');
	    change_or_make_setting('RebootCommand', 'sudo /sbin/reboot');
	    change_or_make_setting('RecordFilePrefix',$SQL_DirTV);
	    change_or_make_setting('SelectChangesChannel', '1');
	    change_or_make_setting('ServerHaltCommand', 'sudo /sbin/halt -p');
	    change_or_make_setting('ShowWholeTree', '1');
	    change_or_make_setting('SmartChannelChange', '1');
	    change_or_make_setting('StartupSecsBeforeRecording', '120');
	    change_or_make_setting('TruncateDeletesSlowly', '1');
	    change_or_make_setting('UseOutputPictureControls', '1');
	    change_or_make_setting('UserJob4', 'myth2mp3 -cut \"%DIR%\" \"%FILE%\"');
	    change_or_make_setting('UserJobDesc1', 'User Job #1');
	    change_or_make_setting('UserJobDesc2', 'User Job #2');
	    change_or_make_setting('UserJobDesc3', 'User Job #3');
	    change_or_make_setting('UserJobDesc4', 'Extract audio');
	    change_or_make_setting('VCDPlayerCommand', 'mplayer vcd:\/\/ -cdrom-device %d -fs -zoom -vo xv -vf pp=lb');
	    change_or_make_setting('VideoArtworkDir', "$SQL_DirVideo/.covers");
	    change_or_make_setting('VideoBrowserNoDB', '1');
	    change_or_make_setting('VideoDefaultPlayer', 'mplayer-resumer.pl -fs -zoom -vo xv %s');
	    change_or_make_setting('VideoGalleryNoDB', '1');
	    change_or_make_setting('VideoStartupDir', $SQL_DirVideo);
	    change_or_make_setting('VideoTreeNoDB', '1');
	    change_or_make_setting('VisualMode','BumpScope;Gears;Goom;MonoScope;Squares;StereoScope;Synaesthesia;LibVisual-bumpscope;LibVisual-corona;LibVisual-infinite;AlbumArt');
	    change_or_make_setting('weatherbackgroundfetch', '1');
	    change_or_make_setting('WebBrowserCommand','/usr/bin/mythbrowser');
	    change_or_make_setting('WebBrowserHideScrollbars','0');
	    change_or_make_setting('WebBrowserScrollMode','1');
	    change_or_make_setting('WebBrowserScrollSpeed','4');
	    change_or_make_setting('WebBrowserZoomLevel','20');
	    change_or_make_setting('WebcamDevice','/dev/video');
	    change_or_make_setting('WOLbackendCommand','');
	    change_or_make_setting('WOLbackendConnectRetry','5');
	    change_or_make_setting('WOLslaveBackendsCommand','');
	    change_or_make_setting('WakeupTimeFormat','hh:mm yyyy-MM-dd');
	    change_or_make_setting('WatchTVGuide','0');
# 	    change_or_make_setting('WeatherDBSchemaVer','1000');
	    change_or_make_setting('WebBrowserCommand','/usr/bin/mythbrowser');
	    change_or_make_setting('WebBrowserHideScrollbars','0');
	    change_or_make_setting('WebBrowserScrollMode','1');
	    change_or_make_setting('WebBrowserScrollSpeed','4');
	    change_or_make_setting('WebBrowserZoomLevel','20');
	    change_or_make_setting('XineramaScreen','0');
	    change_or_make_setting('blockSDWUwithoutClient','1');
	    change_or_make_setting('idleWaitForRecordingTime','15');
	    change_or_make_setting('mythdvd.DVDPlayerCommand', 'Internal');
	    change_or_make_setting('mythvideo.VideoTreeRemember', '1');
	    change_or_make_setting('mythfilldatabaseLastRunStart','');
	    change_or_make_setting('mythfilldatabaseLastRunEnd','');
	    change_or_make_setting('mythfilldatabaseLastRunStatus','');

	    #
	    # customexample table
	    #
	    change_or_make_entry("customexample", [["fromclause", ""], ["whereclause", "program.category_type = \"movie\" AND program.airdate >= YEAR(DATE_SUB(NOW(), INTERVAL 1 YEAR)) AND program.stars > 0.5 "], ["search", "1"]], [["rulename", "New Flix"]]);

#	    # As much of MythWeather as we can automate for now
	    my $units = 0;
	    my $metric_units = do_query("SELECT * FROM settings WHERE value='SIUnits' AND data='YES'");
	    if ($metric_units) {
		$units=0;
	    } else {
		$units=1;
	    }
#	    change_or_make_entry("weatherscreens", [["draworder", "0"], ["container", "Six Day Forecast"], ["units", $units]], [["screen_id", 1]]);
#	    change_or_make_entry("weatherdatalayout", [["location", "0"], ["dataitem", "6dlocation"], ["weatherscreens_screen_id", 1]], [["weathersourcesettings_sourceid", 4]]);
#	    for (my $increment=0; $increment < 6; $increment++) {
#		change_or_make_entry("weatherdatalayout", [["location", "0"], ["dataitem", "date-$increment"], ["weatherscreens_screen_id", 1]], [["weathersourcesettings_sourceid", 4]]);
#		change_or_make_entry("weatherdatalayout", [["location", "0"], ["dataitem", "high-$increment"], ["weatherscreens_screen_id", 1]], [["weathersourcesettings_sourceid", 4]]);
#		change_or_make_entry("weatherdatalayout", [["location", "0"], ["dataitem", "icon-$increment"], ["weatherscreens_screen_id", 1]], [["weathersourcesettings_sourceid", 4]]);
#		change_or_make_entry("weatherdatalayout", [["location", "0"], ["dataitem", "low-$increment"], ["weatherscreens_screen_id", 1]], [["weathersourcesettings_sourceid", 4]]);
#	    }
#	    change_or_make_entry("weatherdatalayout", [["location", "0"], ["dataitem", "updatetime"], ["weatherscreens_screen_id", 1]], [["weathersourcesettings_sourceid", 4]]);
#
#	    change_or_make_entry("weathersourcesettings", [["sourceid", "1"], ["source_name", "BBC-Current-XML"], ["update_timeout", "7200"], ["retrieve_timeout", "30"], ["path", "/usr/share/mythtv/mythweather/scripts/bbccurrentxml.pl"], ["author", "Stuart Morgan"], ["version", "0.1"], ["email", "stuart\@tase.co.uk"], ["types", "cclocation,station_id,copyright,observation_time,weather,temp,relative_humidity,wind_dir,pressure,visibility,weather_icon,appt,wind_spdgst"]]);
#	    change_or_make_entry("weathersourcesettings", [["sourceid", "2"], ["source_name", "BBC-3day-XML"], ["update_timeout", "21600"], ["retrieve_timeout", "30"], ["path", "/usr/share/mythtv/mythweather/scripts/bbcthreedayxml.pl"], ["author", "Stuart Morgan"], ["version", "0.1"], ["email", "stuart\@tase.co.uk"], ["types", "3dlocation,station_id,copyright,weather_icon,date-0,icon-0,low-0,high-0,date-1,icon-1,low-1,high-1,date-2,icon-2,low-2,high-2,updatetime"]]);
#	    change_or_make_entry("weathersourcesettings", [["sourceid", "3"], ["source_name", "ENVCAN"], ["update_timeout", "900"], ["retrieve_timeout", "30"], ["path", "/usr/share/mythtv/mythweather/scripts/ca_envcan/envcan.pl"], ["author", "Joe Ripley"], ["version", "0.4"], ["email", "vitaminjoe\@gmail.com"], ["types", "cclocation,station_id,copyright,observation_time,observation_time_rfc822,weather,temp,relative_humidity,wind_dir,wind_degrees,wind_speed,wind_gust,pressure,dewpoint,heat_index,windchill,visibility,weather_icon,appt,wind_spdgst,3dlocation,6dlocation,date-0,icon-0,low-0,high-0,date-1,icon-1,low-1,high-1,date-2,icon-2,low-2,high-2,updatetime,date-3,icon-3,low-3,high-3,date-4,icon-4,low-4,high-4,date-5,icon-5,low-5,high-5"]]);
#	    change_or_make_entry("weathersourcesettings", [["sourceid", "4"], ["source_name", "NDFD-6_day"], ["update_timeout", "900"], ["retrieve_timeout", "30"], ["path", "/usr/share/mythtv/mythweather/scripts/ndfd.pl"], ["author", "Lucien Dunning"], ["version", "0.1"], ["email", "ldunning\@gmail.com"], ["types", "3dlocation,6dlocation,updatetime,high-0,high-1,high-2,high-3,high-4,high-5,low-0,low-1,low-2,low-3,low-4,low-5,icon-0,icon-1,icon-2,icon-3,icon-4,icon-5,date-0,date-1,date-2,date-3,date-4,date-5"]]);
#	    change_or_make_entry("weathersourcesettings", [["sourceid", "5"], ["source_name", "NDFD-18_hour"], ["update_timeout", "900"], ["retrieve_timeout", "30"], ["path", "/usr/share/mythtv/mythweather/scripts/ndfd18.pl"], ["author", "Lucien Dunning"], ["version", "0.1"], ["email", "ldunning\@gmail.com"], ["types", "18hrlocation,updatetime,temp-0,temp-1,temp-2,temp-3,temp-4,temp-5,18icon-0,18icon-1,18icon-2,18icon-3,18icon-4,18icon-5,pop-0,pop-1,pop-2,pop-3,pop-4,pop-5,time-0,time-1,time-2,time-3,time-4,time-5"]]);
#	    change_or_make_entry("weathersourcesettings", [["sourceid", "6"], ["source_name", "NWS-Alerts"], ["update_timeout", "600"], ["retrieve_timeout", "30"], ["path", "/usr/share/mythtv/mythweather/scripts/nws-alert.pl"], ["author", "Lucien Dunning"], ["version", "0.1"], ["email", "ldunning\@gmail.com"], ["types", "swlocation,updatetime,alerts"]]);
#	    change_or_make_entry("weathersourcesettings", [["sourceid", "7"], ["source_name", "NWS-XML"], ["update_timeout", "900"], ["retrieve_timeout", "30"], ["path", "/usr/share/mythtv/mythweather/scripts/nwsxml.pl"], ["author", "Lucien Dunning"], ["version", "0.2"], ["email", "ldunning\@gmail.com"], ["types", "cclocation,station_id,latitude,longitude,observation_time,observation_time_rfc822,weather,temperature_string,temp,relative_humidity,wind_string,wind_dir,wind_degrees,wind_speed,wind_gust,pressure_string,pressure,dewpoint_string,dewpoint,heat_index_string,heat_index,windchill_string,windchill,visibility,weather_icon,appt,wind_spdgst"]]);

	    my $ipaddress = execute_shell_command("ifconfig | grep inet.addr | head -1");
	    $ipaddress =~ s/.*inet addr:(\d+.\d+.\d+.\d+)\s.*/$1/g;






#-------------------jm
# 	    # Change from the generic IP address to the real one.
# 	    do_query("UPDATE settings SET data='$ipaddress' where data='127.0.0.1'");
# 	    do_query("UPDATE settings SET data='$ipaddress' where data='MythTVip'"); # ??? needed?

	    my $hostname = execute_shell_command("hostname") || "localhost";
	    # one table at a time, replace hostname with our actual hostname
	    # ??? can this be done all at once in MySQL?
	    foreach my $table ("capturecard", "inuseprograms", "jobqueue", "jumppoints", "keybindings", "music_playlists",
			       "musicplaylist", "recorded", "settings", "weatherscreens") {
		do_query("UPDATE $table SET hostname='$hostname'");
	    }

	    # Some entries in 'settings' should stay NULL:  http://www.mythtv.org/wiki/index.php/Settings_table
	    # There are fewer entries that stay NULL than there are that should have the hostname set, so while
	    # it duplicates some effort to change them from NULL to the hostname and them back to NULL, it's
	    # easier to maintain and more future-proof.

	    foreach my $entry ("mythfilldatabaseLastRunStart", "mythfilldatabaseLastRunEnd", "mythfilldatabaseLastRunStatus",
			       "DataDirectMessage", "HaveRepeats", "DBSchemaVer", "DefaultTranscoder", "MythFillSuggestedRunTime",
			       "MythFillGrabberSuggestsTime", "MasterServerIP", "MasterServerPort", "TVFormat", "VbiFormat", "FreqTable",
			       "TimeOffset", "MasterBackendOverride", "DeletesFollowLinks", "HDRingbufferSize", "EITTransportTimeout",
			       "EITIgnoresSource", "EITCrawIdleStart", "startupCommand", "blockSDWUwithoutClient", "idleWaitForRecordingTime",
			       "StartupSecsBeforeRecording", "WakeupTimeFormat", "SetWakeuptimeCommand", "ServerHaltCommand", "preSDWUCheckCommand",
			       "WOLbackendConnectRetry", "WOLbackendCommand", "WOLslaveBackendsCommand", "JobsRunOnRecordHost",
			       "AutoCommflagWhileRecording", "JobQueueCommFlagCommand", "JobQueueTranscodeCommand",
			       "AutoTranscodeBeforeAutoCommflag", "SaveTranscoding", "UserJobDesc1", "UserJob1", "UserJobDesc2", "UserJob2",
			       "UserJobDesc3", "UserJob3", "UserJobDesc4", "UserJob4", "PreviewPixmapOffset", "AllRecGroupPassword",
			       "MaximumCommercialSkip", "CommSkipAllBlanks", "LastFreeCard", "LiveTVPriority", "AutoExpireMethod",
			       "AutoExpireDefault", "RerecordWatched", "AutoExpireWatchedPriority", "AutoExpireLiveTVMaxAge",
			       "AutoExpireDayPriority", "AutoExpireExtraSpace", "AutoExpireInsteadOfDelete", "DeletedFifoOrder",
			       "CommercialSkipMethod", "AggressiveCommDetect", "AutoCommercialFlag", "AutoTranscode", "AutoRunUserJob1",
			       "AutoRunUserJob2", "AutoRunUserJob3", "AutoRunUserJob4", "OverTimeCategory", "CategoryOverTime",
			       "EPGEnableJumpToChannel", "LogEnabled", "MythFillEnabled", "MythFillDatabasePath", "MythFillDatabaseArgs",
			       "MythFillDatabaseLog", "MythFillPeriod", "MythFillMinHour", "MythFillMaxHour", "SchedMoveHigher", "SchedOpenEnd",
			       "ComplexPriority", "PrefInputPriority", "SingleRecordRecPriority", "FindOneRecordRecPriority", "ArchiveDBSchemaVer",
			       "FlixDBSchemaVer", "GalleryDBSchemaVer", "GameDBSchemaVer", "MusicDBSchemaVer", "PhoneDBSchemaVer",
			       "mythvideo.DBSchemaVer", "WeatherDBSchemaVer") {
		do_query("UPDATE settings SET hostname=NULL WHERE value='$entry'");
	    }

	    change_or_make_setting('MasterBackendOverride','1'); # I don't remember why, but making the hostname NULL is important here
	    do_query("UPDATE settings SET hostname=NULL WHERE value='MasterBackendOverride'");

	    # storagegroup
	    change_or_make_entry("storagegroup", [["groupname", "Default"], ["hostname", $hostname], ["dirname", $SQL_DirTV]], [["id", 1]]);

	    #
	    # Websites for mythbrowser
	    #
	    #change_or_make_entry("websites", [["grp", "LinHeS"], ["dsc", ""], ["updated", ""]], [["url", "http://knoppmyth.net"]]);
	    #change_or_make_entry("websites", [["grp", "LinHeS"], ["dsc", ""], ["updated", ""]], [["url", "http://knoppmythwiki.org"]]);

	    disconnect_from_db();

	    # Fix hostname for iPod feed URLs
	    $command = "sed -i \"s/hostname\\//$hostname\\//g\" /usr/local/bin/myth2ipod";
	    execute_shell_command($command);

	    # Fix hostname for XViD feed URLs
	    $command = "sed -i \"s/192.168.0.222\\//$hostname\\//g\" /usr/local/bin/myt2xvid3";
	    execute_shell_command($command);

	    # Customize default MythTV library.xml to reflect KnoppMyth's wider selection of
	    # online stream options.
	    #$command = "sed -i \"/<type>STREAM<\\/type>\$/{N; N; N; N; s/text>.*<\\/text/text>Online Streams<\\/text/; s/action>.*<\\/action/action>MENU is.xml<\\/action/; s/<depends.*depends>//; }\" /usr/share/mythtv/library.xml";
	    $command = "/bin/cp /usr/share/mythtv/library.xml.km /usr/share/mythtv/library.xml";
	    execute_shell_command($command);
	} else {
	    my $logger = get_logger('tweaker.script');
	    $logger->error("Unable to connect to mythconverg database");
	    $logger->error("Unable to implement option $option.");
	    return -1;
	}
	return 1;
    }

    file_tweaks($option) || exit -1;
    SQL_tweaks($option) || exit -1;
}

# Try to get a Recommendation Level for $option.
sub poll_options {
    my($option) = @_;
    recommendation_level("recommended", "These tweaks benefit all users.");
}

# Unimplemented in 0.7
sub check_option {
    help;
}

# Unimplemented in 0.7
sub count_iterations {
    help;
}

process_parameters;