Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mythlink user supplied source path #149

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added new sourcepath option to specify custom symlink source path
  • Loading branch information
Garret Picchioni committed Mar 8, 2017
commit 33b9bb74ea204d68467d043ea1b347db1b453835
28 changes: 24 additions & 4 deletions mythtv/contrib/user_jobs/mythlink.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use MythTV;

# Some variables we'll use here
our ($dest, $format, $usage, $underscores, $live, $rename, $maxlength);
our ($dest, $sourcepath, $format, $usage, $underscores, $live, $rename, $maxlength);
our ($chanid, $starttime, $filename);
our ($dformat, $dseparator, $dreplacement, $separator, $replacement);
our ($db_host, $db_user, $db_name, $db_pass, $video_dir, $verbose);
Expand All @@ -43,6 +43,7 @@

# Load the cli options
GetOptions('link|destination|path:s' => \$dest,
'sourcepath=s' => \$sourcepath,
'chanid=s' => \$chanid,
'starttime=s' => \$starttime,
'filename=s' => \$filename,
Expand Down Expand Up @@ -77,6 +78,15 @@
WARNING: ALL symlinks within the destination directory and its
subdirectories (recursive) will be removed.

--sourcepath [source path]

Specify an alternate directory path for the symlink link source.
Use case would be if you need to conform to specific path requirements. eg:

/../../recordings vs. /var/video/recordings

default: Use full directory path

--chanid chanid

Create a link only for the specified recording file. Use with --starttime
Expand Down Expand Up @@ -320,6 +330,9 @@
$dest ||= "$base_dir/show_names";
# Alert the user
vprint("Link destination directory: $dest");
if (defined($sourcepath)) {
vprint("Symlink source path: $sourcepath");
}
# Create nonexistent paths
unless (-e $dest) {
mkpath($dest, 0, 0775) or die "Failed to create $dest: $!\n";
Expand Down Expand Up @@ -411,8 +424,15 @@
mkpath($directory, 0, 0775)
or die "Failed to create $directory: $!\n";
}
symlink $show->{'local_path'}, "$dest/$name"
or die "Can't create symlink $dest/$name: $!\n";
# Generate source of symlink based on user supplied path or full file system path
if (defined($sourcepath)) {
symlink "$sourcepath/$show->{'basename'}", "$dest/$name"
or die "Can't create symlink $dest/$name: $!\n";
}
else {
symlink $show->{'local_path'}, "$dest/$name"
or die "Can't create symlink $dest/$name: $!\n";
}
vprint("$dest/$name");
}

Expand Down Expand Up @@ -495,4 +515,4 @@
}
}
exit 0;
}
}