LinHES Forums
http://forum.linhes.org/

manual database delete?
http://forum.linhes.org/viewtopic.php?f=6&t=6150
Page 5 of 5

Author:  marc.aronson [ Thu Nov 17, 2005 8:00 pm ]
Post subject: 

Mike, thank you!

Chris, did the script I emailed you solve the problem you were having with the script?

Author:  cmaines [ Fri Nov 18, 2005 12:17 pm ]
Post subject: 

Yes, Marc, thanks! The script you e-mailed worked just fine. Sorry it took so long to respond. I also see that the script earlier in this thread has been edited so that it is correct.

Author:  marc.aronson [ Fri Nov 18, 2005 7:27 pm ]
Post subject: 

So I guess the remaining question is why myth tv doesn't recognize the old recordings properly. ie: Why it doesn't count them as part of the max # of recordings you can keep.

I'm not sure I can help you with that one, but I would suggest making sure the permissions and ownership on those files is the same as all of the others.

marc

Author:  mjl [ Fri Nov 18, 2005 7:52 pm ]
Post subject: 

Hi,
It sounds like cmaines hosed himself with the restore button if I read the thread correctly? The nuv files are still valid to play however because of the restore function, the matching label in the database is gone. I think I referred to that as a C or D situation? The trick would be is to figure out how to recreate manually a name in the data base that refers to the orphaned recording.

A possible way of doing that, would be to make a junk recording, then using webmin I suppose one could go into db under the recordings and edit the file names to reference the orphans. It would have to be real important for that kind of effort :)

Thanks
Mike

Author:  linuxgeek [ Sun Jan 08, 2006 11:56 am ]
Post subject: 

I have BEEN less then successful with this script or any script for mythlink.sh.

I have carefully read this entire thread.. to no avail...

When I run this manually I get lots of errors.. See Snippet blow:

Use of uninitialized value in concatenation (.) or string at -e line 23, <> line 2.
Use of uninitialized value in concatenation (.) or string at -e line 23, <> line 2.
Use of uninitialized value in pattern match (m//) at -e line 37, <> line 2.
Use of uninitialized value in substr at -e line 40, <> line 2.
substr outside of string at -e line 40, <> line 2.
Use of uninitialized value in hash element at -e line 40, <> line 2.
Use of uninitialized value in substr at -e line 40, <> line 2.
substr outside of string at -e line 40, <> line 2.
Use of uninitialized value in concatenation (.) or string at -e line 40, <> line 2.

---- End of snippet ----

2nd it creates these erronous files in /myth/tv/

root@mythtv:~# ls /myth/tv
'rehash' to get table and field completion, but startup__.nuv
--disable-auto-rehash.__.nuv
Directory where character sets are.__.nuv
No automatic rehashing. One has to use 'rehash' to get__.nuv
Set the default character set.__.nuv
and reconnecting may take a longer time. Disable with__.nuv

Any ideas?

Author:  marc.aronson [ Sun Jan 08, 2006 1:48 pm ]
Post subject: 

Linuxgeek, I've sent you a PM for more info.

Marc

Author:  mjl [ Sun Jan 08, 2006 11:43 pm ]
Post subject: 

Hi linuxgeek,

Not sure which script you ran, however one thing to be very watchful of is line wrapping. It helps if when you start your nano add the -w switch. nano -w <your-script-label-here>

That is often the cause for things not seeming to work properly. Marc did a great job on the task and it does work (assuming we talking to same script for mythlink.sh) :)

I wasn't able to find the thread however it was connected to "deadwood"

Mike

Author:  linuxgeek [ Mon Jan 09, 2006 11:06 pm ]
Post subject: 

Thanks Marc..

I have my mysql passwd protected for root.

So I added the -p PASSWD to the mysql run line.

This was breaking mythlink.sh.

Thanks to Marc for pointing out the space issue
between -p and PASSWD... Once I removed the
space all is well now...

Thanks Marc and Mjl for your posts.

Author:  marc.aronson [ Wed Jan 11, 2006 9:05 am ]
Post subject: 

Folks:

Below is an updated version of the "dead_wood" script. The key change is that I've added a way of providing a password for those that have password protected their MYSQL data bases. I don't have password protection on my MYSQL data base and I am able to confirm it works properly with no password. Linuxgeek has confirmed that it works properly on his password-protected MYSQL data base -- thanks to Linuxgeek for running that test for me!

Marc

Code:
#! /bin/bash
#
# This scropt will look for orphased ".nuv" files in /myth/tv
# directory and delete them. It will also check the data base
# for references to non-existant ".nuv" files, and create a
# dummy ".nuv" file where necessary. To protect your system
# from "run away" deletions, this script uses the following
# logic:
#
# 1. It will not do anything to a "nuv" file that is referenced in the
#    "recorded shows" listing of the myth data base.
# 2. It will not do anything to a "nuv" file that is less than 2 hours old.
# 3. If it detects more than 8 "nuv" files that appear to be orphaned,
#    it will exit without taking any action.
# 4. Files that pass the previous 3 tests are not deleted. Instead they are
#    moved to the directory /myth/tv/TRASH. If they remain untouched in this
#    directory for 7 days, then they are automatically deleted.
#
#
TV="/myth/tv"
TRASH=$TV/TRASH
AGE="7"
MAX=8
PASSWORD=""
#
# Verify existance of input directories
#
if [ ! -e "$TV" ]
then
    echo "$TV does not exist -- script halted."
    exit 1
fi
mkdir -p $TRASH
if [ ! -e "$TRASH" ]
then
    echo "Unable to created directory $TRASH"
    exit 1
fi
if [ "$PASSWORD" == "" ]
then
    PASS=""
else
    PASS="-p$PASSWORD"
fi
#
# Create a list of files that exist in $TV that aren't in the DB
#    and a list of files that exist in the DB that aren't in $TV.
#
mysql -uroot mythconverg $PASS -B --exec \
      "select chanid,DATE_FORMAT(starttime,'%Y%m%d%H%i%s'),\
      DATE_FORMAT(endtime,'%Y%m%d%H%i%s') \
      from recorded;" >/tmp/mythclean.db
cat /tmp/mythclean.db | grep -v "^chanid" | sed -e "s/\t/_/g" | \
      sed -e "s/$/.nuv/" | sed -e "s#^#$TV/#" | sort > /tmp/nuv-db-list
find $TV -maxdepth 1 -name \*.nuv -mmin +120 -print | sort > /tmp/nuv-files
orphaned_files=(`join -v 2 /tmp/nuv-db-list /tmp/nuv-files`)
missing_files=(`join -v 1 /tmp/nuv-db-list /tmp/nuv-files`)
#
# If a file exists in $TV, has not been modified for at least 1 day,
# and is not referenced in the database, then move it to the trash can
#
if [ ${#orphaned_files[@]} -gt $MAX ]
then
    echo ${#orphaned_files[@]} nuv files were identified for removal, but
    echo script is configured to limit removals to $MAX files.
    echo No action taken.
    exit 1
fi
for f in ${orphaned_files[@]};
  do
  echo Moving $f to the trash can
  touch $f
  mv -f $f $TRASH
  if [ -e $f.png ]
  then
      echo Moving $f.png to the trash can
      touch $f.png
      mv -f $f.png $TRASH
  fi
done
#
# Empty the trash can of all files that are older the $AGE days.
#
echo ""
echo "Checking $TRASH for files more than $AGE days old."
find $TRASH -maxdepth 1 -mtime "+$AGE" -a \( -name \*.nuv -o -name \*.png \) \
     -print -exec rm -f \{\} \; | sed -e "s/^/  Removing file /"
#
# Create a dummy "nuv" file for any DB entry that does not point at
# a vaild file in $TV.
#
sleep 1
echo ""
echo "Checking for missing nuv files"
for f in ${missing_files[@]};
do
    if [ ! -e "$f" ]
    then
        echo "  Creating missing file $f"
        echo "Dummy" > $f
    fi
done
exit 0

Author:  RCS [ Thu Feb 02, 2006 3:05 pm ]
Post subject:  Question about Deadwood

After reading this thread I think the Deadwood script should work for me. Here is my problem -
I have deleted several shows from the MythTV Interface and the shows do not show up in the listings. I went to the pretty dir several days later and the shows I deleted were still there, so I just deleted them. 30 minutes later Mythlink kicks in and the shows popup again as 1 byte files. Found this thread with Deadwood. Ran the Deadwood script and no joy. I looked in the new trash folder and there is nothing in there and the 1 byte files are still listed in Pretty and TV. Tried again after 24 hours to take in account the 1 day delay and I am still having no progress. So my question is the Deadwood script the one I should be running for this problem?

Thanks

Author:  marc.aronson [ Sat Feb 04, 2006 1:23 pm ]
Post subject: 

I am working with RCS via email to figure out what is happening, but in the meantime, a problem has come to light.

Earlier in this thread it was suggested that people both run the "deadwood" script and add the following lines to "mythlink.sh":

Code:
ls -Li /myth/pretty/*.mpg | sort > /tmp/mpg-files
ls -Li /myth/tv/*.nuv | sort > /tmp/nuv-files
join -v 2 /tmp/mpg-files /tmp/nuv-files | cut -d " " -f 2 > /tmp/dead-files
cat /tmp/dead-files | sed -e "s/^/rm -f /" > /tmp/rm-dead-files


If you added those lines to mythlink.sh I suggest you remove them. They will interfear with the deadwood script and they are not necessary, as "deadwood" will take all the necessary actions. Thanks.

Marc

Page 5 of 5 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/