From 5c6e9c7404a3529affb53e7d64ae696aba4f47f1 Mon Sep 17 00:00:00 2001 From: Lars Hanisch Date: Sat, 30 May 2015 15:53:26 +0200 Subject: [PATCH 1/2] output priority in status list --- vdrctl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vdrctl b/vdrctl index 0433342..f521cd0 100755 --- a/vdrctl +++ b/vdrctl @@ -39,7 +39,10 @@ GetOptions( # Try name.conf ($name) = basename($file) =~ /^(.*?).conf$/ unless $name; + ($priority) = 50 unless $priority; + $configfiles{$name}{available} = $file; + $configfiles{$name}{priority} = $priority; } foreach my $file (<"$argsdir/*.conf">) { @@ -49,7 +52,10 @@ GetOptions( # Try name.conf ($name) = basename($file) =~ /^(.*?).conf$/ unless $name; + ($priority) = 50 unless $priority; + $configfiles{$name}{enabled} = $file; + $configfiles{$name}{priority} = $priority; } if ($ARGV[1]) { @@ -76,24 +82,26 @@ GetOptions( sub status { my $configfiles_ref = shift; - print sprintf('%-22s%s', 'PLUGIN', 'STATE'), "\n"; + print sprintf('%-22s%-10s%s', 'PLUGIN', 'STATE', 'PRIORITY'), "\n"; foreach my $plugin (sort(keys(%$configfiles_ref))) { print sprintf('%-22s', $plugin); if (!$configfiles_ref->{$plugin}->{enabled}) { # Not in $argsdir --> disabled - print colored['bright_red bold'], 'disabled'; + print colored['bright_red bold'], sprintf('%-10s', 'disabled'); } elsif (!$configfiles_ref->{$plugin}->{available}) { # Not in $availdir --> static - print 'static'; + print sprintf('%-10s', 'static'); } else { # In both directories --> enabled - print colored['bright_green bold'], 'enabled'; + print colored['bright_green bold'], sprintf('%-10s', 'enabled'); } + print $configfiles_ref->{$plugin}->{priority}; + print "\n"; } } From 3debd71a6e7fb295df7dd5f5dc7414e25ea6210a Mon Sep 17 00:00:00 2001 From: Lars Hanisch Date: Sat, 30 May 2015 16:19:09 +0200 Subject: [PATCH 2/2] don't create link if it exists with any priority --- vdrctl | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/vdrctl b/vdrctl index f521cd0..0f4b895 100755 --- a/vdrctl +++ b/vdrctl @@ -10,7 +10,7 @@ use Pod::PlainText; use Term::ANSIColor; my $PROGNAME = 'vdrctl'; -my $VERSION = '0.1.0'; +my $VERSION = '0.1.1'; my $argsdir = `pkg-config --variable argsdir vdr`; chomp($argsdir); @@ -21,11 +21,15 @@ my $availdir = "$argsdir/../conf.avail"; my $editor = $ENV{EDITOR}; $editor = 'vi' unless $editor; +my $default_priority = 50; + my $force; +my $force_prio; GetOptions( "argsdir=s" => \$argsdir, "availdir=s" => \$availdir, "force" => \$force, + "priority=i" => \$force_prio, "help" => \&help, "version" => \&version ) or die("Error in command line arguments\n"); @@ -39,7 +43,7 @@ GetOptions( # Try name.conf ($name) = basename($file) =~ /^(.*?).conf$/ unless $name; - ($priority) = 50 unless $priority; + ($priority) = $default_priority unless $priority; $configfiles{$name}{available} = $file; $configfiles{$name}{priority} = $priority; @@ -52,7 +56,7 @@ GetOptions( # Try name.conf ($name) = basename($file) =~ /^(.*?).conf$/ unless $name; - ($priority) = 50 unless $priority; + ($priority) = $default_priority unless $priority; $configfiles{$name}{enabled} = $file; $configfiles{$name}{priority} = $priority; @@ -134,10 +138,19 @@ sub enable { foreach my $plugin (@_) { my $filename = basename($configfiles_ref->{$plugin}->{available}) or die("$plugin is unknown\n"); + my $priority = basename($configfiles_ref->{$plugin}->{priority}); + if ($force_prio) { + $priority = $force_prio; + } # $file may be not the exact filename. - symlink(abs2rel("$availdir/$filename", $argsdir), "$argsdir/$filename") - or die "Cannot create symlink to $argsdir/$filename\n"; + unless ($configfiles_ref->{$plugin}->{enabled} and !$force_prio) { + symlink(abs2rel("$availdir/$filename", $argsdir), "$argsdir/$priority-$plugin.conf") + or die "Cannot create symlink to $argsdir/$priority-$plugin.conf\n"; + } + else { + die("$availdir/$filename is already linked to $argsdir"); + } } } @@ -234,6 +247,14 @@ AVAILDIR is /etc/vdr/conf.d/../conf.avail =over 5 +=item B<--force> + +force deleting static files in ARGSDIR + +=item B<--priority>= + +use as priority instead of the one coded in the filename + =item B<--argsdir>= read config-files from instead of ARGSDIR