summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2016-08-03 17:01:47 (GMT)
committerChristian Pointner <equinox@helsinki.at>2016-08-03 17:01:47 (GMT)
commit9ca564354715514ad7199294749fb80085d9fec9 (patch)
tree98c861a77ea8354e7d7f5d855b587ed8ed67e84b /utils
parent04b0ce29cb5d25565ce68ae3cd195c5f0f7565b0 (diff)
added clear command to rhrd-pool
Diffstat (limited to 'utils')
-rwxr-xr-xutils/rhrd-pool42
1 files changed, 41 insertions, 1 deletions
diff --git a/utils/rhrd-pool b/utils/rhrd-pool
index acaff65..ada9b6f 100755
--- a/utils/rhrd-pool
+++ b/utils/rhrd-pool
@@ -29,7 +29,7 @@ sub print_usage
{
print STDERR "Usage: rhrd-pool list\n" .
" rhrd-pool show <short-name>\n" .
- " rhrd-pool remove <short-name> [--force]\n" .
+ " rhrd-pool remove|clear <short-name> [--force]\n" .
" rhrd-pool add <groupname> <title>\n" .
" rhrd-pool edit <short-name> <title>\n";
}
@@ -209,6 +209,38 @@ sub remove
return 0;
}
+sub clear
+{
+ my ($ctx, $shortname, $force) = @_;
+
+ if(defined($force) && $force ne "--force") {
+ print_usage();
+ return 1;
+ }
+
+ my @slots = RHRD::rddb::get_musicpool_clock_usage($ctx, $shortname);
+ if(!defined $slots[0] && defined $slots[1]) {
+ print STDERR "$slots[1]: $slots[2]";
+ return 1;
+ }
+ if(scalar(@slots) > 0) {
+ print STDERR "musicpool is still in use (" . scalar(@slots) . " grid entries)\n";
+ return 1 unless(defined($force));
+ print STDERR " *** forced clearing ***\n"
+ }
+
+ my @results = RHRD::rddb::clear_musicpool($ctx, $shortname);
+ if(!defined $results[0] && defined $results[2]) {
+ print STDERR $results[1] . ": " . $results[2] . "\n";
+ return 1;
+ }
+ for my $href (@results) {
+ print int($href->{cnt}) . " " . $href->{name} . " deleted\n";
+ }
+
+ return 0;
+}
+
my $num_args = $#ARGV + 1;
if($num_args < 1) {
print_usage();
@@ -243,6 +275,14 @@ if(defined $ctx) {
$ret = remove($ctx, $ARGV[1], $ARGV[2]);
}
}
+ elsif($cmd eq "clear") {
+ if($num_args < 2 || $num_args > 3) {
+ print_usage();
+ $ret = 1;
+ } else {
+ $ret = clear($ctx, $ARGV[1], $ARGV[2]);
+ }
+ }
elsif($cmd eq "add") {
if($num_args != 3) {
print_usage();