summaryrefslogtreecommitdiffstats
path: root/abs/core/tweaker/bin/twk_upgrade.pl
diff options
context:
space:
mode:
Diffstat (limited to 'abs/core/tweaker/bin/twk_upgrade.pl')
-rwxr-xr-xabs/core/tweaker/bin/twk_upgrade.pl190
1 files changed, 190 insertions, 0 deletions
diff --git a/abs/core/tweaker/bin/twk_upgrade.pl b/abs/core/tweaker/bin/twk_upgrade.pl
new file mode 100755
index 0000000..b5d09b6
--- /dev/null
+++ b/abs/core/tweaker/bin/twk_upgrade.pl
@@ -0,0 +1,190 @@
+#!/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/>.
+
+#
+# NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+#
+# Tweaker 0.7 is not interactive, so these post-upgrade changes are a stopgap
+# measure to make sure people upgrading from R5F27 get sensible settings
+# for things that MythTV 0.21 doesn't know how to handle properly. This file
+# should shrink or disappear entirely once Tweaker becomes interactive.
+#
+# NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE NOTE
+#
+
+use Switch;
+use Tweaker::Script;
+package Tweaker::Script;
+
+set_known_options( 'all' );
+
+# Try to implement the given option.
+sub implement_option {
+ my($option) = @_;
+
+ $dbconnectionstring = get_mythtv_connection_string();
+
+ if (connect_to_db("DBI:mysql:$dbconnectionstring")) {
+ # use poll results from twk_cpu.pl to set playback decoder options
+ my @levels = ("low", "medium", "high");
+ foreach my $level (@levels) {
+ my @results = split(/\|/, execute_shell_command("twk_cpu.pl --poll $level"));
+ foreach my $result (@results) {
+ if ($result eq "recommended") {
+ if ("$level" eq "low") {
+ change_or_make_setting('DefaultVideoPlaybackProfile', 'CPU--') || exit -1; # best playback defaults for weak hardware
+ } elsif ("$level" eq "medium") {
+ change_or_make_setting('DefaultVideoPlaybackProfile', 'CPU+') || exit -1; # best playback defaults for average hardware
+ } elsif ("$level" eq "high") {
+ change_or_make_setting('DefaultVideoPlaybackProfile', 'CPU++') || exit -1; # best playback defaults for powerful hardware
+ }
+ }
+ }
+ }
+
+ # Update visualization modes for 0.21
+ change_or_make_setting('VisualMode','BumpScope;Gears;Goom;MonoScope;Squares;StereoScope;Synaesthesia;LibVisual-bumpscope;LibVisual-corona;LibVisual-infinite;LibVisual-jakdaw;LibVisual-jess;AlbumArt');
+
+ # Remove possibly obsolete and conflicting theme cache entries.
+ execute_shell_command("/bin/rm -rf /home/mythtv/.mythtv/themecache/");
+
+ # Fix bizarre ownership of files:
+ execute_shell_command("chown -f root: /usr/bin/get_dual.sh");
+ execute_shell_command("chown -fR root: /usr/lib/krp");
+ execute_shell_command("chown -fR root: /usr/local/bin");
+ execute_shell_command("chown -f root: /usr/share/man/man1/tv_grab_au.1.gz");
+ execute_shell_command("chown -f root: /usr/share/xmltv/tv_grab_au/channel_ids");
+ execute_shell_command("chown -fR root:src /usr/src/");
+
+ # Fix video problems for some nVidia users
+ execute_shell_command("grep nvidia /etc/X11/xorg.conf && sed -i -e 's/^[ \t]*Option.*\"XvmcUsesTextures\".*/#REMOVEME/g' -e 's/^[ \t]*Option.*\"UseEvents\".*/#REMOVEME/g' /etc/X11/xorg.conf"); # clear out old entries, if present
+ execute_shell_command("grep nvidia /etc/X11/xorg.conf && sed -i -n '1h;2,\$H;\${g;s/#REMOVEME\\n//g;p}' /etc/X11/xorg.conf"); # clear out old entries, if present
+ execute_shell_command("grep nvidia /etc/X11/xorg.conf && sed -i 's/\\(^[ \t]*Driver.*\"nvidia\".*\\)/\\1\\n\tOption \"XvmcUsesTextures\" \"false\"\\n\tOption \"UseEvents\" \"true\"/g' /etc/X11/xorg.conf");
+ execute_shell_command("if [ -e /home/mythtv/.nvidia-settings-rc ] ; then sed -i -e \"s'.*XVideoTextureSyncToVBlank.*'#REMOVEME'g\" -e \"s'.*XVideoBlitterSyncToVBlank.*'#REMOVEME'g\" /home/mythtv/.nvidia-settings-rc; fi");
+ execute_shell_command("grep nvidia /etc/X11/xorg.conf && echo 0/XVideoTextureSyncToVBlank=0 >> /home/mythtv/.nvidia-settings-rc && echo 0/XVideoBlitterSyncToVBlank=0 >> /home/mythtv/.nvidia-settings-rc && sed -i -n '1h;2,\$H;\${g;s/#REMOVEME\\n//g;p}' /home/mythtv/.nvidia-settings-rc");
+
+
+ # Enable any digital audio out device we can.
+ my $command = "amixer scontrols | grep IEC958";
+ my @results = split('\n', execute_shell_command($command));
+ foreach my $line (@results) {
+ if ($line =~ /Simple mixer control (.*),.*/i) {
+ $command = "su - mythtv -c \"amixer set $1 on\""; # Tries to set all IEC958 devices to 'on'
+ # but some are just placeholders and can't be turned 'on', therefore don't error out if we fail
+ execute_shell_command($command);
+ }
+ }
+ execute_shell_command("alsactl store"); # persist the above change(s)
+
+ # The Chaintech AV-710 was generally configured for digital audio in R5F27 in a way that worked
+ # great there but which is failing utterly in R5.5. Try to detect this old configuration, and if
+ # it's present, implement the new settings which seem to work for all digital audio devices.
+ # This may only match 80% of the AV-710 users, but the rest of them can just run the necessary
+ # tweaker command by hand to get the same result.
+ if (execute_shell_command('lspci -mn | grep -e ".*0401.*1412.*1724.*1412.*1724"')) {
+ # found an AV-710, now see if it's configured for digital audio
+ if (do_query("SELECT * FROM settings WHERE value='AudioOutputDevice' AND data='/dev/adsp'")) {
+ # The user was using this AV-710's spdif output, so give them the new good digital configuration
+ execute_shell_command("twk_audio.pl --implement digital");
+ }
+ }
+ change_or_make_setting('MixerDevice', 'ALSA:default') || exit -1;
+
+ # Undo obsolete mplayer workaround for aspect ratio
+ execute_shell_command("sed -i 's/.*monitoraspect.*//g' /home/mythtv/.mplayer/config");
+
+ 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('MythFillDatabaseLog', '/var/log/mythtv/mythfilldatabase.log');
+ 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'");
+
+ 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("ERROR: Unable to connect to mythconverg database");
+ $logger->error("ERROR: Unable to implement option $option.");
+ exit -1;
+ }
+ disconnect_from_db();
+}
+
+# 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;