diff options
Diffstat (limited to 'abs/mv-core/MythVantage-system')
30 files changed, 1973 insertions, 0 deletions
diff --git a/abs/mv-core/MythVantage-system/45-event.rules b/abs/mv-core/MythVantage-system/45-event.rules new file mode 100644 index 0000000..f88dc0c --- /dev/null +++ b/abs/mv-core/MythVantage-system/45-event.rules @@ -0,0 +1 @@ +KERNEL=="event*", NAME="input/%k", MODE="0640" , GROUP="users" diff --git a/abs/mv-core/MythVantage-system/PKGBUILD b/abs/mv-core/MythVantage-system/PKGBUILD new file mode 100644 index 0000000..7f01ac0 --- /dev/null +++ b/abs/mv-core/MythVantage-system/PKGBUILD @@ -0,0 +1,43 @@ +pkgname=MythVantage-system +pkgver=1.0 +pkgrel=1 +arch=('i686') +MVDIR=$startdir/pkg/usr/MythVantage +BINDIR=$startdir/pkg/usr/bin +install=STB.install +pkgdesc="scripts and things related to having a automated system" +depends=(unclutter ghosd ncid func wol ) +provides=(STB-system) + +binfiles="playmedia.sh STB-start saytime.sh restartfrontend.sh backup_job restore_job.sh update_system update_system_all repo_sync.sh backend_control.sh load-modules-mythvantage.sh file_time_offset.py grabkey.py imdb-bulk-update.pl notify.py optimize_mythdb.py myth_mtc.py myth_mtc.sh firstboot.sh initial_db_run" + +source=(startfrontend inittab STBWINDOWMANAGER smolt.cron $binfiles mfegdbcommands.txt mbegdbcommands.txt 45-event.rules) + +build() { + cd $startdir/src + install -m755 -D STBWINDOWMANAGER $startdir/pkg/etc/X11/STBWINDOWMANAGER + install -m755 -D startfrontend $startdir/pkg/etc/X11/Sessions/STB + install -m755 -D mfegdbcommands.txt $MVDIR/mfegdbcommands.txt + install -m755 -D mbegdbcommands.txt $MVDIR/mbegdbcommands.txt +####### install to /usr/MythVantage/bin/ +mkdir -p $BINDIR +for i in $binfiles +do + item=$i + install -m755 -D $item $MVDIR/bin/$item + echo $item + cd $BINDIR + pwd + ln -s ../MythVantage/bin/$i . + + cd - +done +########## + + install -m755 -D smolt.cron $startdir/pkg/etc/cron.weekly/smolt.cron + + install -m755 -D 45-event.rules $startdir/pkg/etc/udev/rules.d/45-event.rules + + +} + diff --git a/abs/mv-core/MythVantage-system/STB-start b/abs/mv-core/MythVantage-system/STB-start new file mode 100644 index 0000000..39a50f0 --- /dev/null +++ b/abs/mv-core/MythVantage-system/STB-start @@ -0,0 +1,160 @@ +#!/bin/sh +. /etc/profile +# $Xorg: startx.cpp,v 1.3 2000/08/17 19:54:29 cpqbld Exp $ +# +# This is just a sample implementation of a slightly less primitive +# interface than xinit. It looks for user .xinitrc and .xserverrc +# files, then system xinitrc and xserverrc files, else lets xinit choose +# its default. The system xinitrc should probably do things like check +# for .Xresources files and merge them in, startup up a window manager, +# and pop a clock and serveral xterms. +# +# Site administrators are STRONGLY urged to write nicer versions. +# +# $XFree86: xc/programs/xinit/startx.cpp,v 3.16tsi Exp $ + + +userclientrc=/etc/X11/Sessions/STB +userserverrc=$HOME/.xserverrc +sysclientrc=/usr/X11R6/lib/X11/xinit/xinitrc +sysserverrc=/usr/X11R6/lib/X11/xinit/xserverrc +defaultclient=/usr/X11R6/bin/xterm +defaultserver=/usr/X11R6/bin/X +defaultclientargs="" +defaultserverargs="" +clientargs="" +serverargs="" + + + + + + +if [ -f $userclientrc ]; then + defaultclientargs=$userclientrc +elif [ -f $sysclientrc ]; then + defaultclientargs=$sysclientrc +fi + + + + +if [ -f $userserverrc ]; then + defaultserverargs=$userserverrc +elif [ -f $sysserverrc ]; then + defaultserverargs=$sysserverrc +fi + +whoseargs="client" +while [ x"$1" != x ]; do + case "$1" in + # '' required to prevent cpp from treating "/*" as a C comment. + /''*|\./''*) + if [ "$whoseargs" = "client" ]; then + if [ x"$clientargs" = x ]; then + client="$1" + else + clientargs="$clientargs $1" + fi + else + if [ x"$serverargs" = x ]; then + server="$1" + else + serverargs="$serverargs $1" + fi + fi + ;; + --) + whoseargs="server" + ;; + *) + if [ "$whoseargs" = "client" ]; then + clientargs="$clientargs $1" + else + # display must be the FIRST server argument + if [ x"$serverargs" = x ] && \ + expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then + display="$1" + else + serverargs="$serverargs $1" + fi + fi + ;; + esac + shift +done + +# process client arguments +if [ x"$client" = x ]; then + # if no client arguments either, use rc file instead + if [ x"$clientargs" = x ]; then + client="$defaultclientargs" + else + client=$defaultclient + fi +fi + +# process server arguments +if [ x"$server" = x ]; then + # if no server arguments or display either, use rc file instead + if [ x"$serverargs" = x -a x"$display" = x ]; then + server="$defaultserverargs" + else + server=$defaultserver + fi +fi + +if [ x"$XAUTHORITY" = x ]; then + XAUTHORITY=$HOME/.Xauthority + export XAUTHORITY +fi + +removelist= + + +# set up default Xauth info for this machine +case `uname` in +Linux*) + if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then + hostname=`hostname -f` + else + hostname=`hostname` + fi + ;; +*) + hostname=`hostname` + ;; +esac + +authdisplay=${display:-:0} +mcookie=`mcookie` +for displayname in $authdisplay $hostname$authdisplay; do + if ! xauth list "$displayname" | grep "$displayname " >/dev/null 2>&1; then + xauth -q << EOF +add $displayname . $mcookie +EOF + removelist="$displayname $removelist" + fi +done + + +xinit $client $clientargs -- $server $display $serverargs + +if [ x"$removelist" != x ]; then + xauth remove $removelist +fi + + + + + +if command -v deallocvt > /dev/null 2>&1; then + deallocvt +fi + + + + + + + diff --git a/abs/mv-core/MythVantage-system/STB.install b/abs/mv-core/MythVantage-system/STB.install new file mode 100644 index 0000000..d10e0c1 --- /dev/null +++ b/abs/mv-core/MythVantage-system/STB.install @@ -0,0 +1,113 @@ +# This is a default template for a post-install scriptlet. You can +# remove any functions you don't need (and this header). + +# arg 1: the new package version +pre_install() { +/bin/true +} + +# arg 1: the new package version +post_install() { +MVDIR=/usr/MythVantage/bin +# ln -s $MVDIR/backup_job /etc/cron.daily/backup_cron +# ln -s $MVDIR/update_system /etc/cron.daily/xupdate_system_cron + ln -s $MVDIR/repo_sync.sh /etc/cron.daily/zrepo_sync.sh + ln -s $MVDIR/myth_mtc.sh /etc/cron.daily/myth_mtc.sh + + if [ ! -e /etc/cron.tenminutes ] + then + mkdir /etc/cron.tenminutes + fi + + ln -s $MVDIR/grabkey.py /etc/cron.tenminutes/grabkey.py + + +LINE="nobody ALL = NOPASSWD: /sbin/sv stop mythbackend" +LINE1="nobody ALL = NOPASSWD: /sbin/sv start mythbackend" +LINE2="nobody ALL = NOPASSWD: /usr/bin/backup_job" +LINE3="nobody ALL = NOPASSWD: /bin/ls" +LINE4="nobody ALL = NOPASSWD: /usr/bin/restore_job.sh" +LINE5="nobody ALL = NOPASSWD: /usr/bin/update_system" +LINE7="nobody ALL = NOPASSWD: /sbin/poweroff" +LINE8="nobody ALL = NOPASSWD: /usr/bin/update_system_all" +LINE9="nobody ALL = NOPASSWD: /usr/bin/func" +LINE10="nobody ALL = NOPASSWD: /data/srv/hobbit/server/ext/hbfunc.py" +LINE11="nobody ALL = NOPASSWD: /usr/bin/certmaster-ca" +LINE12="nobody ALL = NOPASSWD: /sbin/reboot" +LINE13="nobody ALL = NOPASSWD: /usr/MythVantage/bin/build_diskless.sh" +LINE14="nobody ALL = NOPASSWD: /sbin/sv stop dnsmasq" +LINE15="nobody ALL = NOPASSWD: /sbin/sv start dnsmasq" +LINE16="nobody ALL = NOPASSWD: /sbin/sv hup dnsmasq" + +for i in "$LINE" "$LINE1" "$LINE2" "$LINE3" "$LINE4" "$LINE5" "$LINE7" "$LINE8" "$LINE9" "$LINE10" "$LINE11" "$LINE12" "$LINE13" "$LINE14" "$LINE15" "$LINE16" +do + cp /etc/sudoers /etc/sudoers.bak + grep -q "$i" /etc/sudoers + if [ $? != 0 ] + then + echo "$i" >> /etc/sudoers + visudo -cf /etc/sudoers + if [ ! $? = 0 ] + then + cp /etc/sudoers.bak /etc/sudoers + echo $i + echo "Error adding files" + exit 1 + fi + fi +done + +REALTIME="session required pam_limits.so" +grep -q "pam_limits.so" /etc/pam.d/su + if [ $? != 0 ] + then + echo "$REALTIME" >> /etc/pam.d/su + + fi + +mkdir -p /data/home/mythtv/capture +chown mythtv:mythtv /data/home/mythtv/capture + +} + +# arg 1: the new package version +# arg 2: the old package version +pre_upgrade() { + if [ -e /etc/cron.daily/backup_cron ] + then + rm -f /etc/cron.daily/backup_cron + fi + if [ -e /etc/cron.daily/xupdate_system_cron ] + then + rm -f /etc/cron.daily/xupdate_system_cron + fi + + if [ -e /etc/cron.daily/myth_mtc.py ] + then + rm -f /etc/cron.daily/myth_mtc.py + fi + + + + +} + +# arg 1: the new package version +# arg 2: the old package version +post_upgrade() { + post_install +} + +# arg 1: the old package version +pre_remove() { + /bin/true +} + +# arg 1: the old package version +post_remove() { + /bin/true +} + +op=$1 +shift +$op $* diff --git a/abs/mv-core/MythVantage-system/STBWINDOWMANAGER b/abs/mv-core/MythVantage-system/STBWINDOWMANAGER new file mode 100644 index 0000000..e2ac216 --- /dev/null +++ b/abs/mv-core/MythVantage-system/STBWINDOWMANAGER @@ -0,0 +1,2 @@ +#STBWINDOWMANAGER="/usr/bin/evilwm -fn fixed -bw 0" +STBWINDOWMANAGER="/usr/bin/e16" diff --git a/abs/mv-core/MythVantage-system/backend_control.sh b/abs/mv-core/MythVantage-system/backend_control.sh new file mode 100755 index 0000000..53b973b --- /dev/null +++ b/abs/mv-core/MythVantage-system/backend_control.sh @@ -0,0 +1,34 @@ +#!/bin/bash +#. /etc/systemconfig +#echo $@ > /tmp/parms +#start Slavebackend: fusion 192.168.1.120 +COMMAND=$1 +BETYPE=$2 +eval LAST=\$$# +dbhost=`echo $LAST` + + +MESSAGE="" +case $COMMAND in + stop) MESSAGE=`/usr/bin/curl http://$dbhost:1337/bestop.cgi 2>/dev/null` + ;; + + start ) + MESSAGE=`/usr/bin/curl http://$dbhost:1337/bestart.cgi 2>/dev/null` + ;; + + restart) + /usr/bin/backend_control.sh stop $dbhost + sleep 3 + /usr/bin/backend_control.sh start $dbhost +# /tmp/backend_control.sh start $dbhost + ;; + clearcache) + MESSAGE2=`/usr/bin/curl http://$dbhost:1337/beclear.cgi 2>/dev/null` +esac +exit 0 +if [ ! "x$MESSAGE" = x ] +then + xsay -t 3 "$MESSAGE" +fi + diff --git a/abs/mv-core/MythVantage-system/backup_job b/abs/mv-core/MythVantage-system/backup_job new file mode 100755 index 0000000..c3997ab --- /dev/null +++ b/abs/mv-core/MythVantage-system/backup_job @@ -0,0 +1,63 @@ +#!/bin/bash +echo "#########################################################" +echo "Starting backup " +. /etc/profile +. /etc/systemconfig +BACKUPDIR=/data/database_backup +DATE=`date +%F_%H-%M` +mkdir -p $BACKUPDIR/$DATE + +#backup db +pacman -Q mysql 2>/dev/null +if [ $? = 0 ] +then + mysqldump mythconverg > $BACKUPDIR/$DATE/mythconverg + mysqldump ncid > $BACKUPDIR/$DATE/ncid + mysqldump webcal > $BACKUPDIR/$DATE/webcal +fi + +#backup etc +cp -rp /etc $BACKUPDIR/$DATE/etc +cp -rp /var/lib/oss $BACKUPDIR/$DATE/oss + +#backup func keys +cp -rp /data/srv/func $BACKUPDIR/$DATA/func + +#make_zip file +cd $BACKUPDIR +tar -zcvf $BACKUPDIR/backup.$DATE.tgz $DATE + +if [ -d $BACKUPDIR/$DATE ] +then + rm -rf $BACKUPDIR/$DATE +fi + +if [ -f /data/srv/hobbit/server/ext/hbnotes.py ] +then + /data/srv/hobbit/server/ext/hbnotes.py + chown nobody:nobody /data/srv/httpd/htdocs/hobbit/notes/* 2> /dev/null >/dev/null + + +fi + + +#Remote copy +if [ x$RemoteBackup = x1 ] +then + localRemoteCheck=`echo $RemoteBackupDir | cut -d: -f1` + if [ x$localRemoteCheck = xdir ] + then + localRemotedir=`echo $RemoteBackupDir | cut -d: -f2` + cmd="cp $BACKUPDIR/backup.$DATE.tgz $localRemotedir" + echo "copying$BACKUPDIR/backup.$DATE.tgz to $localRemotedir " + else +# sshcmd="scp -o StrictHostKeyChecking=no -o ConnectTimeout=1 -i /data/srv/.nobody_ssh/id_dsa $BACKUPDIR/backup.$DATE.tgz" +# cmd="${sshcmd} mythtv@${RemoteBackupDir}:/data/database_backup/" + /usr/bin/func ${RemoteBackupDir} copyfile -f $BACKUPDIR/backup.$DATE.tgz --remotepath $BACKUPDIR/backup.$DATE.tgz + + echo "copying$BACKUPDIR/backup.$DATE.tgz to ${RemoteBackupDir}:/data/database_backup/" + fi + $cmd +fi + +echo "#########################################################" diff --git a/abs/mv-core/MythVantage-system/file_time_offset.py b/abs/mv-core/MythVantage-system/file_time_offset.py new file mode 100755 index 0000000..f2973d0 --- /dev/null +++ b/abs/mv-core/MythVantage-system/file_time_offset.py @@ -0,0 +1,39 @@ +#!/usr/bin/python + + +import time +import os +import glob +import getopt +import sys +def main(argv): + filecount=0 +# root = "/tmp" +# offset = 4 + now = int(time.time()) + + + try: + opts, args = getopt.getopt(argv, "hs:d:") + except getopt.GetoptError: + sys.exit(2) + for opt, arg in opts: + if opt in ("-h", "--help"): + print "-s seconds -d /testdir" + print "default if 4 seconds" + sys.exit() + elif opt in ( "-s" ): + offset = int(arg) + elif opt in ("-d"): + root = arg + + for item in glob.glob(root+"/*"): + lastmodDate = os.path.getmtime(item) + tdiff= now-lastmodDate + #print tdiff, offset + + if tdiff > offset: + filecount+=1 + print filecount +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/abs/mv-core/MythVantage-system/firstboot.sh b/abs/mv-core/MythVantage-system/firstboot.sh new file mode 100755 index 0000000..366874a --- /dev/null +++ b/abs/mv-core/MythVantage-system/firstboot.sh @@ -0,0 +1,44 @@ +#!/bin/bash +. ~/.configured +ATTEMPT=0 +function try_smolt { + ((ATTEMPT=ATTEMPT+1)) + echo $ATTEMPT + status=$(echo "jump mythsmolt" | telnet localhost 6546 2>&1) + echo $status|grep -q refused + status=$? + if [ $status != 0 ] + then + fb_status=0 + echo "FB=NO" > ~/.configured + fi + if [ $ATTEMPT = 200 ] + then + fb_status=0 + fi +} + +if [ ! -e /tmp/debug ] +then + if [ ! -e /tmp/nomfe ] + then + if [ ! -e ~/.mythtv/pub-uuid ] + then + if [ x$FB != xNO ] + then + fb_status=4 + while [ $fb_status != 0 ] + do + try_smolt + if [ $fb_status != 0 ] + then + sleep 1 + fi + done + fi + fi + fi +fi + + + diff --git a/abs/mv-core/MythVantage-system/grabkey.py b/abs/mv-core/MythVantage-system/grabkey.py new file mode 100755 index 0000000..b8bc059 --- /dev/null +++ b/abs/mv-core/MythVantage-system/grabkey.py @@ -0,0 +1,109 @@ +#!/usr/bin/python +#polls the hobbit server for ghost clients. If it finds ghosts it will make a new bb-hosts file +#with the new clients. +#Will not add duplicate clients +#return code of 0 means a new file was written, anything else is an error or no inserts occured +import urllib2 +import string +import sys +import os + +def readkeyfile(): + global keylist + try: + infile = open('/data/home/mythtv/.ssh/authorized_keys', 'r') + except(IOError), e: + keylist='' + else: + keylist = infile.readlines() + infile.close() + + +def grabkey(server): + global numberlines + global mbekey + url="http://" + server + ":1337/serverkey.cgi" + + try: + f = urllib2.urlopen(url) + except urllib2.HTTPError, e: + if e.code != 200: + print 'error find key' + sys.exit(1) + else: + mbekey = f.readlines() + f.close() + numberlines = len(mbekey) + #print mbekey + + +def makenewkeyfile(): + global keylist + global mbekey + global numberlines + global numinserts + numinserts=0 + outlist = [] + for item in keylist: + if item not in outlist: + outlist.append(item) + + for item in mbekey: +# line = item.rstrip() + #nline = "%s #" % (line) + #nline = nline + '\n' + if item not in outlist: + outlist.append(item) + #print "adding: " + item + numinserts = numinserts + 1 + if numinserts > 0: + try: + outfile = open("/data/home/mythtv/.ssh/authorized_keys","w") + except(IOError), e: + os.system('mkdir -p /data/home/mythtv/.ssh') + outfile = open("/data/home/mythtv/.ssh/authorized_keys","w") + for i in outlist: + outfile.write(i + '\n' ) + outfile.close + os.system('chown -R mythtv /data/home/mythtv/.ssh') + os.system('chmod 700 /data/home/mythtv/.ssh/authorized_keys') + + +global infile +global keylist +global numberlines +global numinserts +global mbekey +readkeyfile() +#print numberlines +#print mbekey + +try: + infile = open('/etc/systemconfig', 'r') +except(IOError), e: + sys.exit(1) +else: + keylist = infile.readlines() + infile.close() +for item in keylist: + if item.startswith("dbhost"): + itemlist=item.split("=") + server=itemlist[1].strip() + server=server.rstrip() + server=server.strip('"') + server=server.rstrip('"') +grabkey(server) + + +if numberlines > 0: + makenewkeyfile() +else: + print "nothing to add" + + +if numinserts < 1: + sys.exit(1) +else: + sys.exit(0) + + diff --git a/abs/mv-core/MythVantage-system/imdb-bulk-update.pl b/abs/mv-core/MythVantage-system/imdb-bulk-update.pl new file mode 100644 index 0000000..87a9668 --- /dev/null +++ b/abs/mv-core/MythVantage-system/imdb-bulk-update.pl @@ -0,0 +1,720 @@ +#!/usr/bin/perl +################################################################################ +# Wrapper for imdb.pl tool for bulk movie metadata updates for mythdora # +# # +# 08/28/2007 # +# Ryan Pisani <mythdora@thepisanis.com> # +################################################################################ +#Parts of this were adopted from imdbbatchupdater.pl which in turn uses much # +#of the original imdb.pl. This is a simpler wrapper to maintain and it utilizes# +#the standard imdb.pl shipped with mythvideo. # +################################################################################ +#version: 1.0 : Initial roll-out works with imdb.pl 1.3 # +#version: 1.1 : Added some further error checking # +#version: 1.2 : Added -Manual flag for manual entering of IMDBIDs # +#version: 1.3 : Added -fileup metadata update for newly added/removed movies # +#version: 1.4 : Duplicate menu will default to first entry in the returned # +# list. # +# Added -Exclude flag to mark any items with non-imdb match with # +# a bogus imdb number to be skipped in later searches. # +# Added -help for extended examples in usage # +#version: 1.5 : Added -Folder flag to overide videopath for new video search # +# Fixed hash sort of new files so that entries with more than 1 # +# entry in the DB will not be "true" in new check. # +# Fixed a bug in the newvideo find where multiples were added # +# Fixed a bug in the newvideo find where multiples were added # +#version:1.5.1: Added showlevel fix in -Fileup to fix incorrect default showlvl# +#version: 1.6 : Found bug in -Title lookups where title was updated blank # +################################################################################ +use strict; +use DBI; +use Getopt::Long; +use File::Find; +use File::Basename; +use Sys::Hostname; + +#Set Global Path For Execution +$ENV{PATH}="/bin:/usr/sbin:/usr/bin:/sbin"; + +#Defaults & global declarations here +my $dbhost = '127.0.0.1'; +my $db = 'mythconverg'; +my $dbuser = 'mythtv'; +my $dbpass = 'mythtv'; +my $imdbnum; #imdbnum set from imdb.pl +my $movie; #movie title set from query +my $intid; #incremental id for videometadata table +my @FAILEDLOOKUP; #array to store failed lookups +my $imdb= '/usr/local/share/mythtv/mythvideo/scripts/imdb.pl'; +my $posters; #coverart directory +my $new; #-N flag +my $all; #-A flag +my $sqlstat; #used to store sql statments +my $stitle; #grabbed from input for title search +my $dup; #set if dupskip is on +my $manual; #set if manual is on +my $host = hostname; #the executing hosts machine name +my $fileup; #set if fileup is on +my $exclude; #set if exclude is on +my $currentimdb; #dbs current imdb number before lookup is set +my $help; #pass to usage if help flag i set for extended +my $folder; #set if -Folder is set to overide DB for Videopath +my $title; #Global Title to carry + + +GetOptions("Posters=s"=>\$posters, + "A"=>\$all, + "N"=>\$new, + "Fileup"=>\$fileup, + "help"=>\$help, + "Exclude"=>\$exclude, + "Manual"=>\$manual, + "Dupskip"=>\$dup, + "Title=s"=>\$stitle, + "Folder=s"=>\$folder, + "Host=s"=>\$dbhost, + "User=s"=>\$dbuser, + "Imdb=s"=>\$imdb, + "Password=s"=>\$dbpass); + + +if ( $help eq '1' ) { + + #Show extended usage + usage($help); + +} + +#One quick sanity check here for anyone looking to -A and -Exclude together + +if ( $exclude eq '1' && $all eq '1' ) { + +print <<STOP; + +**********************************Warning*************************************** + + -Exclude and -A are not recommended to be used together. If they are + used together you may find yourself seriously pissed off. + + -Exclude and -A will override any you may have previously entered in + manually because IMDB lookup may have failed. Furthermore the files + will go back to no-data and excluded from future searches. + + It is in your best interest to use -Exclude only with -N + + You have been warned. + +**********************************Warning*************************************** + +Hit [Enter] to exit, or type 'go' to continue with -Exclude and -A: +STOP + +chomp(my $choice=<STDIN>); + + if ( "$choice" ne "go" ) { + + exit; + + } + +} + + +#if the file update flag is set we'll update the db videometadata before continuing +if ( $fileup eq '1' ) { + + findnewvids($folder); + +} + +#Now parse sql options in an order that we care about +if ( $stitle ne "" ) { + + $sqlstat = "select inetref, filename, intid from videometadata where title like \"%$stitle%\""; + +} + +elsif ( $all eq '1') { + + $sqlstat = "select inetref, filename, intId from videometadata order by title"; + +} + +elsif ( $new eq '1' ) { + + $sqlstat = "select inetref, filename, intId, title from videometadata where inetref=\"00000000\" order by title"; + +} + +else { + + usage(); + +} + + +#Check to see if posters have been defined if not grab from db +if ( $posters eq "" ) { + + $posters=getposter(); + +} + +#Check for the posters directory & perms +if ( ! -d "$posters" || ! -w "$posters" ) { + + die "\nError: $posters doesn't exist or is not writable\n\n"; + +} + + +#Check for imdb.pl script or the one defined +if ( ! -x "$imdb" ) { + + die "Error: $imdb.pl is not executable\n"; + +} + + +#print "$sqlstat\n"; + +#Prepare the sql connection +my $dbh = DBI->connect("dbi:mysql:$db:$dbhost","$dbuser","$dbpass"); + +my $sth = $dbh->prepare($sqlstat); + +$sth->execute || die "SQL statement failed"; + +while (my @row=$sth->fetchrow_array) { + + #Grab current imdb number in DB + chomp($currentimdb = "$row[0]"); + + #Grab incremental id in DB for rewrite + chomp($intid = "$row[2]"); + + lc($movie = `basename "$row[1]"`); + + #Grab file id in DB for search + chomp($movie); + + #Grab title data + chomp(my $title= "$row[3]"); + + sep(); + + #print "current:$currentimdb , intid:$intid, movie: $movie, title: $title\n"; + #check to see if -Manual flag is set + if ( $manual ne '1' ) { + + print "Searching for IMDB movieID for $movie\n"; + chomp(($imdbnum)=(split /:/, `$imdb -M "$movie"`) [0] ); + + } + else { + + print "Enter the IMDB movieID for $movie\n"; + print "Enter the corresponding imdb number([Enter] to skip):"; + chomp($imdbnum=<STDIN>); + } + + #We'll check the imdb ids here. If they're longer than expected we assume + #it to be more than one return + if (length($imdbnum) > '8') { + + #Check the multiple entries and skip if flag is set + if ($dup ne '1') { + + my @TITLES=`$imdb -M "$movie"`; + + print "More than one match for $movie exists at IMDB\n"; + + for (my $i=0;$i<=$#TITLES;$i++) { + + print "$i) $TITLES[$i]"; + + } + + print "Select a title ([0] Default, [x] to skip, [m] manual imdb number):"; + chomp(my $choice=<STDIN>); + + #print "my choice $choice\n"; + if ($choice eq "") { + + $choice="0"; + chomp($imdbnum=(split /:/, $TITLES[$choice]) [0]); + } + + elsif ($choice eq "x") { + + $imdbnum=""; + push(@FAILEDLOOKUP, "$movie"); + + + } + + elsif ($choice =~ /[0-9]/) { + + chomp($imdbnum=(split /:/, $TITLES[$choice]) [0]); + #print $imdbnum; + + } + + elsif ($choice eq "m") { + + print "Enter IMDB number: "; + chomp($imdbnum=<STDIN>); + } + + else { + + die "Not a valid selection\n"; + + } + } + else { + + $imdbnum=""; + push(@FAILEDLOOKUP, "$movie"); + } + + } + + #Else check for failed lookups and -Exclude flag + elsif ( "$imdbnum" eq "" && "$exclude" eq "1" && "$currentimdb" eq "00000000" ) { + + #We set a new bogus one to be ignored in later -N searches + $imdbnum="99999999"; + + push(@FAILEDLOOKUP, "$movie"); + + } + + + #Log the failed lookups here for later + elsif ( "$imdbnum" eq "" ) { + + push(@FAILEDLOOKUP, "$movie"); + + #print $#FAILEDLOOKUP; + + } + + + + #now check for imdbnumber from query + if ( "$imdbnum" ne "" ) { + + my $coverfile; + my $year; + my $director; + my $plot; + my $userrating; + my $rating; + my $time; + + #If bogus is set do this first + if ("$imdbnum" eq "99999999") { + + $coverfile="No Cover"; + $year="1895"; + $director="Unknown"; + $plot="Unknown"; + $userrating="0"; + $rating="NR"; + $time="0"; + } + + else { + + #Now lets fine the cover image + #print "Going to use $imdb -P $imdbnum\n"; + chomp(my $cover=`$imdb -P "$imdbnum"`); + #print "$cover"; + + if ($cover =~ /jpg/) { + + $coverfile="$posters/$imdbnum.jpg"; + print "Retrieving $cover\n"; + system("wget $cover -O $coverfile >/dev/null 2>&1"); + + } + else { + + $coverfile="No Cover"; + + } + + + #Now get the rest of the imdb data + undef my @TEMPDATA; + @TEMPDATA=`$imdb -D $imdbnum`; + chomp(($title)=(split /Title:/, $TEMPDATA[0])[1]); + $title=~s/"//g; + chomp(($year)=(split /Year:/, $TEMPDATA[1])[1]); + chomp(($director)=(split /Director:/, $TEMPDATA[2])[1]); + chomp(($plot)=(split /Plot:/, $TEMPDATA[3])[1]); + $plot=~s/"//g; + chomp(($userrating)=(split /UserRating:/, $TEMPDATA[4])[1]); + chomp(($rating)=(split /MovieRating:/, $TEMPDATA[5])[1]); + chomp(($time)=(split /Runtime:/, $TEMPDATA[6])[1]); + + #print $#TEMPDATA; + #print "$title\n $year\n $director\n $plot\n $userrating\n $rating\n $time\n"; + } + + + + #Now let's write that data into the db + print "Updating videometadata with new information\n"; + my $sqlstat="update videometadata set title=\"$title\", year=\"$year\", director=\"$director\", plot=\"$plot\", userrating=\"$userrating\", coverfile=\"$coverfile\", rating=\"$rating\", length=\"$time\", inetref=\"$imdbnum\" where intid=\"$intid\""; + + + my $sth = $dbh->prepare($sqlstat); + + $sth->execute || die "SQL statement failed\n"; + + + } + +} + +if ( $#FAILEDLOOKUP >= 0 ) { + +print "\n\nThe following videos had imdb lookup errors:\n @FAILEDLOOKUP\n"; + +} + + +sub usage { + + my $help=$_[0]; + my $comm=basename($0); + +print <<STOP; + +usage: $comm -[Required] -[Optional] -[Host] parameters + + Required parameters: + -A Get IMDB data for ALL movies in database + -N Get IMDB data for movies with no IMDBID in database + -Title Get IMDB data for movie(s) matching a quoted pattern + + Optional parameters: + -Exclude Mark entries with no result with imdb placeholder (DEFAULT: OFF) + -Fileup Search for new/removed videos and update database (DEFAULT: OFF) + -Manual Query for manual IMDB number for each title (DEFAULT: OFF) + -Dupskip Ignore the videos that find multiple imdb results (DEFAULT: OFF) + + Host parameters: + -Host Specify a database host (DEFAULT:$dbhost) + -User Specify a database user (DEFAULT:$dbuser) + -Password Specify a database password (DEFAULT:$dbpass) + -Imdb Specify path to a working imdb.pl (DEFAULT:$imdb) + -Posters Specify a cover art directory if different from entry in DB + -Folder Specify a video folder to search if differs from entry in DB + + Example: + $comm -N -Host myhostname -User mythuser -Password mythpass + + Use $comm -help for extended examples +STOP + +if ( $help eq '1' ) { +print <<STOP; + + New file check with IMDB lookup and non-local DB: + $comm -N -Fileup -Host 192.168.1.50 + + New file check with IMDB lookup and future exclusion for non-match: + $comm -N -Fileup -Exclude + + New file check, IMDB lookup for ALL movies, skipping multiple IMDB returns: + $comm -A -Fileup -Dupskip + + Title search with Manual IMDB entry + $comm -Title "Austin Powers" -Manual +STOP +} +exit; +} + + +#Get Posters directory from host if possible out of settings +sub getposter { + + my $sqlstat="select data from settings where hostname=\'$host\' and value=\'VideoArtworkDir\'"; + + my $dbh = DBI->connect("dbi:mysql:$db:$dbhost","$dbuser","$dbpass") || die usage(); + + my $sth = $dbh->prepare($sqlstat); + + $sth->execute || die "SQL statement failed"; + + chomp(my $posters=$sth->fetchrow_array); + + return($posters); + +} + +#Routine to locate new & removed videos and update videometadata accordingly +sub findnewvids { + + my $folder=$_[0]; + my $videopath; + + sep(); + + + if ( $folder eq "" ) { + + print "Retrieving Video Path for this $host from $db.settings\n"; + + #First get video directory path from settings database for exectuting host + my $sqlstat="select data from settings where hostname=\'$host\' and value=\'VideoStartupDir\'"; + + my $dbh = DBI->connect("dbi:mysql:$db:$dbhost","$dbuser","$dbpass"); + + my $sth = $dbh->prepare($sqlstat); + + $sth->execute || die "SQL statement failed"; + + chomp($videopath=$sth->fetchrow_array); + + } + else { + print "Setting Video Path with manual override to $folder\n"; + chomp($videopath="$folder"); + + } + sep(1); + + #Now let's get the ignored file types so that we can truly ignore any overrides + print "Retrieving ignored files extensions from $db.videometadata\n"; + + $sqlstat = "select extension from videotypes where f_ignore=\"1\" order by extension"; + + my $dbh = DBI->connect("dbi:mysql:$db:$dbhost","$dbuser","$dbpass"); + + my $sth = $dbh->prepare($sqlstat); + + $sth->execute || die "SQL statement failed"; + + my @ITYPES; + #put the ignored extensions found in the DB into an array + while (my @row=$sth->fetchrow_array) { + + push(@ITYPES,"@row"); + + } + + sep(1); + #Now look at allowed extensions and create an array to use when finding files + #We'll append these to a list of pre-defined ones below + + print "Retrieving allowable file extensions from $db.videometadata\n"; + + $sqlstat = "select extension from videotypes where f_ignore=\"0\" order by extension"; + + my $dbh = DBI->connect("dbi:mysql:$db:$dbhost","$dbuser","$dbpass"); + + my $sth = $dbh->prepare($sqlstat); + + $sth->execute || die "SQL statement failed"; + + + #Array of commonly allowed video extensions + my @TYPES=(".wmv",".avi",".vob",".iso",".bin",".mpeg",".mpg",".mp4",".mov"); + + #put the extensions found in the DB into an array + while (my @row=$sth->fetchrow_array) { + + if ( "@TYPES" !~ /@row/ ) { + + push(@TYPES,".@row"); + + } + + + } + + my @FTYPES; + + #Pull any ignored extensions out of final file type search string + foreach (@TYPES) { + + if ( "@ITYPES" !~ /$_/ ) { + + push(@FTYPES,"($_)\\Z|"); + + } + + + } + + my $types=join"",@FTYPES; + + #Take the last | off of the search string + chop($types); + + sep(1); + + #Search for all files that match our allow file extension patterns as defined in $types + my @FILES; + find (sub{ + + my $file=$File::Find::name ; + if ( $file =~ /$types/i) { + push(@FILES,"$file"); + #print "$file\n"; + } + + }, "$videopath"); + + @FILES=sort(@FILES); + + my $totalfiles="$#FILES" + 1; + + if ($totalfiles gt '1') { + + print "Found $totalfiles total videos in $videopath\n"; + sep(1); + + } + else { + + die "No video files were found in $videopath\n"; + + + } + + #Now lets see what's in videometadata + print "Retrieving a list of known videos from $db.videometadata\n"; + + sep(1); + + $sqlstat = "select filename from videometadata where filename like \"%$videopath%\" order by filename"; + + my $dbh = DBI->connect("dbi:mysql:$db:$dbhost","$dbuser","$dbpass"); + + my $sth = $dbh->prepare($sqlstat); + + $sth->execute || die "SQL statement failed"; + + #put those extensions found in the DB into an array + + my @LISTINDB; + while (my @row=$sth->fetchrow_array) { + + push(@LISTINDB,"@row"); + + } + + print "Scrubbing the database for any videos that no longer exist in $videopath\n"; + + my @FILESINDB; #Database entries with an actual file associated + #Now scrub database entries for any files that are no longer present + foreach (@LISTINDB) { + + if (! -e "$_") { + + print "\nRemoving entry for $_ from database\n"; + + $sqlstat = "delete from videometadata where filename=\"$_\""; + + my $dbh = DBI->connect("dbi:mysql:$db:$dbhost","$dbuser","$dbpass"); + + my $sth = $dbh->prepare($sqlstat); + + $sth->execute || die "SQL statement failed"; + + } + else { + + #Add to new scrubbed list + push(@FILESINDB, "$_"); + + } + + + + } + + sep(); + + + my %count =(); + + my @FILESDIFF; + #Now well check to see what files differ between DB entries the Data + foreach my $element (@FILESINDB, @FILES) { + + $count{$element}++; + + } + foreach my $element (keys %count) { + + if ( $count{$element} < 2 ) { + + push(@FILESDIFF, $element); + print "$element\n"; + + } + } + + #Now we tell the user how many updates to be made + my $totaldiff="$#FILESDIFF" + 1; + + if ($totaldiff gt '0') { + + print "Found a total of $totaldiff to be added to database\n"; + sep (1); + + } + else { + + print "Found no new videos to be added to database\n"; + + } + + #Now we need to grab just a title and populate the db with + foreach (@FILESDIFF) { + + my $title=basename($_,@TYPES); + + print "\nAdding entry for $_ to $db.videometadata\n"; + + $sqlstat = "insert into videometadata (title,director,rating,inetref,coverfile,filename,showlevel) values(\"$title\",\"Unknown\",\"NR\",\"00000000\",\"No Cover\",\"$_\",\"1\");"; + + my $dbh = DBI->connect("dbi:mysql:$db:$dbhost","$dbuser","$dbpass"); + + my $sth = $dbh->prepare($sqlstat); + + $sth->execute || die "SQL statement failed"; + + } + + #print "@FILESDIFF\n"; + + + +} + + + + +#Prints a easy on the eye separator +sub sep { + + if (defined $_[0]) { + + print "=============================================================================\n"; + sleep $_[0]; + } + else { + + print "=============================================================================\n"; + + } + +} diff --git a/abs/mv-core/MythVantage-system/initial_db_run b/abs/mv-core/MythVantage-system/initial_db_run new file mode 100644 index 0000000..0824c60 --- /dev/null +++ b/abs/mv-core/MythVantage-system/initial_db_run @@ -0,0 +1,24 @@ +#!/bin/bash +. /etc/profile +. /etc/systemconfig +rundb=1 + +if [ -f /var/log/mfdb.first.log ] +then + #check exit code + rundb=`tail -1 /var/log/mfdb.first.log` +fi + +if [ ! $rundb = 0 ] +then + echo "Running 1st mythfilldatabase" + echo "Do not remove this file. This file is used to determine if mythfilldatabase needs to run before starting mythbackend" > /var/log/mfdb.first.log + + + /usr/local/bin/mythfilldatabase 2>&1 >> /var/log/mfdb.first.log + + echo $? >> /var/log/mfdb.first.log +fi + + + diff --git a/abs/mv-core/MythVantage-system/inittab b/abs/mv-core/MythVantage-system/inittab new file mode 100644 index 0000000..caa0542 --- /dev/null +++ b/abs/mv-core/MythVantage-system/inittab @@ -0,0 +1,34 @@ +# +# /etc/inittab +# + +# Runlevels: +# 0 Halt +# 1(S) Single-user +# 2 Not used +# 3 Multi-user +# 4 Not used +# 5 X11 +# 6 Reboot + +id:3:initdefault: + +rc::sysinit:/etc/rc.sysinit +rs:S1:wait:/etc/rc.single +rm:2345:wait:/etc/rc.multi +rh:06:wait:/etc/rc.shutdown +su:S:wait:/sbin/sulogin -p + +c1:2345:respawn:/sbin/agetty 38400 vc/1 linux +c2:2345:respawn:/sbin/agetty 38400 vc/2 linux +c3:2345:respawn:/sbin/agetty 38400 vc/3 linux +c4:2345:respawn:/sbin/agetty 38400 vc/4 linux +c5:2345:respawn:/sbin/agetty 38400 vc/5 linux +c6:2345:respawn:/sbin/agetty 38400 vc/6 linux + +ca::ctrlaltdel:/sbin/shutdown -t3 -r now + +x:5:respawn:/usr/bin/xdm -nodaemon + +SV:345:respawn:/usr/bin/svscan /service +# End of file diff --git a/abs/mv-core/MythVantage-system/load-modules-mythvantage.sh b/abs/mv-core/MythVantage-system/load-modules-mythvantage.sh new file mode 100755 index 0000000..8382a29 --- /dev/null +++ b/abs/mv-core/MythVantage-system/load-modules-mythvantage.sh @@ -0,0 +1,32 @@ +#!/bin/bash +#/usr/bin/load-modules-mythvantage.sh UNLOAD LCD +. /etc/systemconfig + +case $1 in +UNLOAD|unload ) + MODULELIST=`grep /etc/modules.mythvantage $2` + for i in $MODULELIST + do + /sbin/rmmod $i + done + + ;; + + *) echo "- Loading MythVantage-modules" + #try to load the cx88 modules + if [ ! x$SystemType = xFrontend_only ] + then + /sbin/modprobe cx88-dvb 2>/dev/null + fi + + if [ -f /etc/modules.mythvantage ] + then + while read line + do + module=`echo $line |cut -d# -f1` + /sbin/modprobe $module + + done < /etc/modules.mythvantage + fi +esac + diff --git a/abs/mv-core/MythVantage-system/mbegdbcommands.txt b/abs/mv-core/MythVantage-system/mbegdbcommands.txt new file mode 100644 index 0000000..dda675b --- /dev/null +++ b/abs/mv-core/MythVantage-system/mbegdbcommands.txt @@ -0,0 +1,8 @@ +handle SIGPIPE nostop noprint +handle SIG33 nostop noprint +set logging on +set pagination off +set args -v most +run +thread apply all bt full +set logging off diff --git a/abs/mv-core/MythVantage-system/mfegdbcommands.txt b/abs/mv-core/MythVantage-system/mfegdbcommands.txt new file mode 100644 index 0000000..cf59068 --- /dev/null +++ b/abs/mv-core/MythVantage-system/mfegdbcommands.txt @@ -0,0 +1,8 @@ +handle SIGPIPE nostop noprint +handle SIG33 nostop noprint +set logging on +set pagination off +set args -d -v most +run +thread apply all bt full +set logging off
\ No newline at end of file diff --git a/abs/mv-core/MythVantage-system/myth_mtc.py b/abs/mv-core/MythVantage-system/myth_mtc.py new file mode 100755 index 0000000..faeee84 --- /dev/null +++ b/abs/mv-core/MythVantage-system/myth_mtc.py @@ -0,0 +1,139 @@ +#!/usr/bin/python + + +import sys,popen2 +import optparse +import re +import socket +import os +import datetime,time + + + +try: + from MythTV import MythTV + mythtv = MythTV() +except: + mythtv = None + +#print mythtv.db.getSetting( 'Theme', socket.gethostname()) + +def optimize(): + cursor = mythtv.db.cursor() + cursor.execute("SHOW tables") + result = cursor.fetchall() + ops=["REPAIR","OPTIMIZE","ANALYZE"] + for row in result: + ctable=row[0] + for op in ops: + print op,ctable + cmd= "%s table %s" %(op,ctable) + cursor.execute(cmd) + + +def upcoming_check(): + upcoming = mythtv.getUpcomingRecordings() + try: + show=str(upcoming[0]) + show=show.strip() + showtime=show.partition("(")[2].strip(")") + now=time.time() + rec_time=time.strptime( showtime ,"%Y-%m-%d %H:%M:%S" ) + r=time.mktime(rec_time) + time_diff= ( r - now ) / 60 + except: + time_diff=100 + show="No show" + if ( time_diff > 30) : + return True + else: + print show , "is upcoming in " , time_diff + return False + + +def schemalock_check(): + c = mythtv.db.cursor() + c.execute("select count(*) from schemalock") + results=c.fetchone() + schemalock=results[0] + if schemalock == 0: + return True + else: + print "schema is locked" + return False + +def job_check(): + c = mythtv.db.cursor() + c.execute("select count(*) from jobqueue where status = 4") + results=c.fetchone() + jobs= results[0] + if jobs == 0 : + return True + else: + print " jobs are running" + return False + + +def in_use(): + c = mythtv.db.cursor() + c.execute("select count(*) from inuseprograms") + results=c.fetchone() + prginuse=results[0] + if prginuse == 0 : + return True + else: + print "programs in use" + return False + +def mfd_check(): + ismfd=popen2.Popen3('/bin/ps cax|/bin/grep -v grep |/bin/grep mythfilldatabase') + ismfd.wait() + mfdIdle=ismfd.poll() + if mfdIdle == 0: + print "mythfilldatabase is running" + return False + else: + return True + + + +def idle_check(): + if ( upcoming_check() and schemalock_check() and job_check() and in_use() and mfd_check() ): + idle=True + print "Myth is idle" + else: + idle=False + print "Myth is NOT idle" + return idle + +def run_stuff(): + if idle_check(): + print "Running optimize" + optimize() + + print "Running backup" + os.system('/usr/MythVantage/bin/backup_job') + + print "Running system_update" + os.system('/usr/MythVantage/bin/update_system') + continue_loop=False + else: + continue_loop=True + return continue_loop + +#--------------------------------- +starttime=time.time() +ctin=True +while ctin: + ctin=run_stuff() + if ctin: + time.sleep(600) + current_time=time.time() + if (current_time - starttime) > 10800 : + ctin = False + print "time exceeded (3 hours)" + exit(1) + + + + diff --git a/abs/mv-core/MythVantage-system/myth_mtc.sh b/abs/mv-core/MythVantage-system/myth_mtc.sh new file mode 100755 index 0000000..fc81254 --- /dev/null +++ b/abs/mv-core/MythVantage-system/myth_mtc.sh @@ -0,0 +1,12 @@ +#!/bin/bash +. /etc/profile +date=`date +%Y-%m-%d` +myth_mtc.py > /var/log/$date/myth_mtc.log +if [ $? = 0 ] +then + echo "Finished" >> /var/log/$date/myth_mtc.log +else + echo "Time Exceede" >> /var/log/$date/myth_mtc.log +fi + + diff --git a/abs/mv-core/MythVantage-system/notify.py b/abs/mv-core/MythVantage-system/notify.py new file mode 100755 index 0000000..2e520c5 --- /dev/null +++ b/abs/mv-core/MythVantage-system/notify.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +# import MySQL module + +import MySQLdb +import sys +import getopt +import socket +import os + +def main(argv): + db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") + # create a cursor + cursor = db.cursor() + # execute SQL statement + cursor.execute("SELECT DISTINCT(hostname) from settings where not hostname is NULL") + result = cursor.fetchall() + message = sys.argv[2] + messagetype = sys.argv[1] + port=str(5000) + if messagetype == "PH2": + port=str(5001) + + + message = message + " :::" + messagetype + for row in result: + os.system("/usr/bin/osdClient.pl " + row[0] + " " + port + " "+ "\"" + message + "\"" + "&" ) + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/abs/mv-core/MythVantage-system/optimize_mythdb.py b/abs/mv-core/MythVantage-system/optimize_mythdb.py new file mode 100755 index 0000000..e7b35ed --- /dev/null +++ b/abs/mv-core/MythVantage-system/optimize_mythdb.py @@ -0,0 +1,16 @@ +#!/usr/bin/python +# import MySQL module +import MySQLdb +import socket +import sys +db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") +cursor = db.cursor() +cursor.execute("SHOW tables") +result = cursor.fetchall() +ops=["REPAIR","OPTIMIZE","ANALYZE"] +for row in result: + ctable=row[0] + for op in ops: + print op,ctable + cmd= "%s table %s" %(op,ctable) + cursor.execute(cmd) diff --git a/abs/mv-core/MythVantage-system/playmedia.sh b/abs/mv-core/MythVantage-system/playmedia.sh new file mode 100755 index 0000000..0b62655 --- /dev/null +++ b/abs/mv-core/MythVantage-system/playmedia.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +DVD="xine --no-logo -B --no-splash --auto-play=pfhqd --post tvtime:method=Greedy2Frame,enable=1" +#DVD="mplayer" +#DVD="pdvd" + +VCD="xine" +#VCD="mplayer" +#VCD="pdvd" + +VIDEO="xine --no-logo -B --no-splash --auto-play=pfhq --post tvtime:method=Greedy2Frame,enable=1" +#VIDEO="mplayer" +CD="xmms /media/removeable" + +TYPE=$1 +shift + +UNMOUNT=0 +case $TYPE in + dvd|DVD ) + PLAYCMD="$DVD" + ;; + vcd|VCD ) + PLAYCMD="$VCD" + ;; + video|VIDEO ) + PLAYCMD="$VIDEO" + EXT=isoa + if [ $EXT = "iso" ] + then + echo "mount logic" + UNMOUNT=1 + fi + ;; + CD|cd ) + PLAYCMD="$CD" + ;; + + * ) echo "not a valid type" + exit 1 + + ;; +esac + + + +$PLAYCMD "$@" + +if [ $UNMOUNT -eq 1 ] +then + echo "umount logic here" +fi + diff --git a/abs/mv-core/MythVantage-system/repo_sync.sh b/abs/mv-core/MythVantage-system/repo_sync.sh new file mode 100755 index 0000000..e36d055 --- /dev/null +++ b/abs/mv-core/MythVantage-system/repo_sync.sh @@ -0,0 +1,11 @@ +#!/bin/sh +echo "##################################################################################" +echo "Starting sync" +. /etc/profile +. /etc/systemconfig +if [ x$PKG_MIRROR = x"1" ] +then +$RSYNC jmeyer.us::current-STB /data/var/mirror/current-STB + +fi +echo "##################################################################################" diff --git a/abs/mv-core/MythVantage-system/restartfrontend.sh b/abs/mv-core/MythVantage-system/restartfrontend.sh new file mode 100755 index 0000000..5919974 --- /dev/null +++ b/abs/mv-core/MythVantage-system/restartfrontend.sh @@ -0,0 +1,4 @@ +#!/bin/bash +echo "Restarting Frontend" | osd_cat -f -*-*-*-*-*-*-25-*-*-*-*-*-*-* -A center - p bottom & +killall -9 mythfrontend +killall -9 mythfrontend diff --git a/abs/mv-core/MythVantage-system/restore_job.sh b/abs/mv-core/MythVantage-system/restore_job.sh new file mode 100755 index 0000000..0d0bec7 --- /dev/null +++ b/abs/mv-core/MythVantage-system/restore_job.sh @@ -0,0 +1,39 @@ +#!/bin/bash +backupfile=$1 +. /etc/profile +BACKUPDIR=/data/database_backup +RESTOREDIR=$BACKUPDIR/restore +DIR=`echo $backupfile |cut -d. -f2` +CSQL="create database mythconverg;" +DSQL="drop database mythconverg; " +MYSQL="mysql -u mythtv -pmythtv" + + + +mkdir $RESTOREDIR +cp $BACKUPDIR/$backupfile $RESTOREDIR +cd $RESTOREDIR && tar -xvf $backupfile && cd $DIR + +if [ -f mythconverg ] +then + #drop the db + $MYSQL -e "$DSQL" + #create the db + $MYSQL -e "$CSQL" + #restore the database_backup + echo "Restoring the database $DIR" + $MYSQL mythconverg < mythconverg + if [ $? = 0 ] + then + echo "Done" + else + echo "An error occured" + fi + else + echo "couldn't file a file to restore" +fi + + +#cleanup +rm -rf $RESTOREDIR/$DIR +rm -f $RESTOREDIR/$backupfile
\ No newline at end of file diff --git a/abs/mv-core/MythVantage-system/saytime.sh b/abs/mv-core/MythVantage-system/saytime.sh new file mode 100755 index 0000000..39e3599 --- /dev/null +++ b/abs/mv-core/MythVantage-system/saytime.sh @@ -0,0 +1,14 @@ +#!/bin/bash +cd /opt/saytime +if [ ! -e /tmp/timelock ] +then + touch /tmp/timelock + ps -ef | grep osd_clock + if [ $? = 0 ] + then + killall -9 osd_clock + fi + + date +%r |osd_cat -c green -f -adobe-courier-*-*-*-*-*-*-*-*-*-150-*-* & + rm /tmp/timelock +fi diff --git a/abs/mv-core/MythVantage-system/smolt.cron b/abs/mv-core/MythVantage-system/smolt.cron new file mode 100644 index 0000000..e0ba37c --- /dev/null +++ b/abs/mv-core/MythVantage-system/smolt.cron @@ -0,0 +1,11 @@ +#!/bin/bash +. /etc/profile +if [ -f /data/home/mythtv/.mythtv/hw-uuid ] +then + cd /usr/local/share/mythtv/mythsmolt/scripts + touch /var/log/smolt.update + chown mythtv /var/log/smolt.update + random=$((RANDOM%2000)) + sleep $random + su mythtv -c "./sendProfile.py -a" > /var/log/smolt.update +fi diff --git a/abs/mv-core/MythVantage-system/startfrontend b/abs/mv-core/MythVantage-system/startfrontend new file mode 100755 index 0000000..ba22900 --- /dev/null +++ b/abs/mv-core/MythVantage-system/startfrontend @@ -0,0 +1,147 @@ +#!/bin/sh +. /etc/profile +. /etc/systemconfig +. /etc/X11/STBWINDOWMANAGER + +xhost +local: +xhost +127.0.0.1 +xset -dpms s off +export MALLOC_CHECK_=0 +#killall -q -9 xsay & +#rm -rf /tmp/xsay* & + +function lirc_check { + lcmd=`irsend LIST "" "" 2>&1 ` + status=$? + if [ $status = 0 ] + then + rc=0 + else + echo $lcmd |grep -q "Connection refused" + status=$? + if [ $status = 0 ] + then + echo "lirc_check: lircd is not running" + else + echo " lirc_check: lircd is running but no receiver found" + fi + rc=1 + fi + return $rc +} + + + + +$STBWINDOWMANAGER & +keylaunch & +/usr/bin/tilda & +/usr/X11R6/bin/unclutter -root -idle 0 -jitter 400 -noevents & +/usr/bin/xvattr -a XV_COLORKEY -v 0 +/usr/local/bin/mtd & +/usr/bin/nvidia-settings -l +/usr/bin/nvidia-settings -a InitialPixmapPlacement=2 + + +#if [ x$ncidclient = "x1" ] +#then +# ncid --no-gui & +#fi + +if [ -f /opt/vmware/bin32/vmware-user-wrapper ] +then + /opt/vmware/bin32/vmware-user-wrapper & +fi + +if [ x$ShowTips = "x1" ] +then +# xsay -t 10 "Alt+h list shortcuts" +bash -c "sleep 6;osdClient.pl localhost 5000 'ALT+h for shortcuts:::SYS' "& + +fi + + +#wait for lirc +if [ x$HostLircWait = x1 ] +then + lcheck=5 + lirc_check + status=$? + + while [[ ! $status = 0 && ! $lcheck = 0 ]] + do + bash -c "osdClient.pl localhost 5000 'Waiting on remote - $lcheck:::SYS' "& + sudo sv restart lircd ; echo "restart lircd" + sleep .5 + lirc_check + status=$? + lcheck=$((lcheck - 1)) + done + + +fi + + + + + +if [ ! $SystemType = "Frontend_only" ] +then + if [ ! -f ~/.configured ] + then + autocard.py -g & + MythVantage -b + #0 yes + #1 yes/autodetech + #2 no + STATUS=$? + if [ ! $STATUS = 2 ] + then + /usr/bin/backend_control.sh stop BE 127.0.0.1 + /usr/local/bin/mythtv-setup + /usr/bin/backend_control.sh start BE 127.0.0.1 + fi + touch ~/.configured + fi +else + #touch file for FE only(mythsmolt) + touch ~/.configured +fi + + +if [ x"$UseMythWelcome" = "x1" ] +then + STARTCMD="/usr/local/bin/mythwelcome" +else + STARTCMD="/usr/local/bin/mythfrontend -d" +fi + +echo "=====================================================================" +echo "Starting $STARTCMD" +#spawn fb to start mythsmolt +firstboot.sh & + +while [ x = x ] +do + if [ -f /tmp/nomfe ] + then + sleep 120 + else + if [ -f /tmp/debug ] + then + + echo "using gbd/debug" + gdb /usr/local/bin/mythfrontend -x $MV_ROOT/mfegdbcommands.txt + bash -c "osdClient.pl localhost 5000 'Restart: mdb.txt.mythfrontend:::SYS' "& + mv gdb.txt gdb.txt.mythfrontend + sleep 10 + + else + killall -9 irexec + /usr/bin/irexec & + $STARTCMD 2>&1 + fi + fi +echo "_______________________________________________________" +done + diff --git a/abs/mv-core/MythVantage-system/update_system b/abs/mv-core/MythVantage-system/update_system new file mode 100755 index 0000000..563ac22 --- /dev/null +++ b/abs/mv-core/MythVantage-system/update_system @@ -0,0 +1,52 @@ +#!/bin/bash + +echo "##################################################################################" +echo "Starting update" +. /etc/profile + +if [ x$1 = x ] +then + . /etc/systemconfig +else +Hostupdateplan=$1 +fi + + +case $Hostupdateplan in + "Myth_only") + echo "updating myth packages" + postfix=`cat $INSTALL_DIR/usr/local/share/mythtv/.releasetype` + for mythl in mythphone mytharchive mythbrowser mythnews mythgame mythflix mythweather mythcontrols mythgallery mythmovietime mythmusic mythsmolt mythvideo mythweb mythtv + do + mythlist="$mythlist $mythl$postfix" + done + + pacman -Sy + list=`pacman -Qu $pkg |grep Targets` + for pkg in STB-system live-installer $mythlist + do + echo $list|grep -q $pkg + if [ $? = 0 ] + then + echo "Updating $pkg" + pacman --noconfirm -S $pkg + else + echo "$pkg is up to date" + fi + done + ;; + "All") + echo "updating ALL packages" + pacman -Sy + pacman --noconfirm -Sfu + ;; + "None") + echo "updating NO packages" + ;; + *) + echo "unkown plan $Hostupdateplan" + ;; +esac + + +echo "##################################################################################" diff --git a/abs/mv-core/MythVantage-system/update_system_all b/abs/mv-core/MythVantage-system/update_system_all new file mode 100755 index 0000000..26205bd --- /dev/null +++ b/abs/mv-core/MythVantage-system/update_system_all @@ -0,0 +1,10 @@ +#!/bin/bash +results=`cat /data/srv/hobbit/server/etc/bb-hosts|grep -v ^#|awk '{print $2}' ` +#echo $results +for i in $results +do + echo "$i" + echo "-------------------------------------------" + sudo /usr/bin/func $i call pacman update_system $1 + ssh -o StrictHostKeyChecking=no -i /data/srv/.nobody_ssh/id_dsa mythtv@$i "sudo /usr/bin/update_system $1" +done diff --git a/abs/mv-core/MythVantage-system/wmaker b/abs/mv-core/MythVantage-system/wmaker new file mode 100644 index 0000000..c66f5b6 --- /dev/null +++ b/abs/mv-core/MythVantage-system/wmaker @@ -0,0 +1,2 @@ +/usr/local/bin/onscreend & +/usr/bin/wmaker |