[mythtv-users] Mythgallery directory permissions when using NFS

CTD ctd at minneapolish3.com
Fri Sep 9 00:58:24 UTC 2005

Not sure if this only occurred for me or if this is due to some other 
system config issue.  There was probably some simple way to overcome 
this, but I started down this path after trying many others.  This way 
seems to work, but I am curious what people with more Linux experience 
have to say.

Setup:  My frontend is on an xbox running xebian with /mnt/store mounted 
to an NFS on the backend.   Mythgallery  on the frontend  points to 

Issue: thumbnails cannot be generated by mythgallery due to permissions 
on .thumbcache directories.

Background:  I knew from previous posts that mythgallery needed write 
permissions on the base directories.  I could manually do this every now 
and then, but I wanted this to be somewhat automatic for new picture 
directories created on backend.

My Solution:
1) Setup directories on backend per:
 chmod 0777 +R /nfs/store/pictures
 chown +R mythtv /nfs/store/pictures (not sure if needed or if any 
non-root user is ok)
 chgrp +R mythtv /nfs/store/pictures (not sure if needed or if any 
non-root user is ok)

   Note: Hate having permissions of 0777, but unsure how to coordinate 
users on NFS client and server.

2) Ensured the following script is run every time my frontend is started 
which ensures that any new picture directores created since the last 
bootup have correct ./thumbcache directories.


# Purpose: Create needed thumbnail directories used by mythgallery.
#          This is done due to apparent issue in mthgallery on xebian
#          where the .thumbcache directories are created with the incorrect
#          permissions. #
# Functionality: This script will recurse the mythgallery picture directory
#                and create needed directories.  It will also ensure 
that all
#                thumbnail directories have permissions set.
# Added call to this script in live user's .bash_rc

use File::Find;
use Cwd;

use constant MODE => 0777;
use constant BASE_DIR => "/mnt/store/pictures/";
use constant SUB_DIR  => ".thumbcache";

# recursively search all directories where mythgallery stores images
finddepth (\&checkPermissions, BASE_DIR);

# function to call for each file and directory found
sub checkPermissions
   # ensure we do not recursively create directories under the 
thumbcache directories
   if ($File::Find::dir eq SUBDIR)

   # if this is a directory and not a thumbcache directory
   if ((-d $_) && ($_ ne SUB_DIR))

       opendir(DIR, $File::Find::name);
             # read file/directory names in that directory into @names
       @names = readdir(DIR);

        # determine if there already exists a cache directory
       my $thumbcacheFound = 0;

       # Search through entries in this directory
       foreach $name (@names)
           # Set flag if match found
           if ($name eq SUB_DIR)
               $thumbcacheFound = 1;

       my $new_dir = $File::Find::name . "/" . SUB_DIR;  
       # if mythgallery has already created a cache directory          
if ($thumbcacheFound)
           # do nothing.  chmod will occur below.
           print "Found existing cache directory: " . $new_dir . "\n";

           # create a .thumbcache directory
           if (mkdir $new_dir, MODE)
               print "Created new directory: " . $new_dir . "\n";
               print "Unable to create new directory: " . $new_dir . "\n";

         # change the directory permissions to ensure that mythgallery
       #   can write to the directory
       if ((chmod MODE, $new_dir) != 1)
           print "Unable to modify permissions of directory: " . 
$new_dir . "\n";
           print "Updated permissions of directory: " . $new_dir . "\n";
       # Do nothing

More information about the mythtv-users mailing list