# -*-perl-*-

# $Id: ScheduleGroup.plm,v 1.6 2009/10/30 17:05:41 koczan Exp $

# Create a daily group

# $Log: ScheduleGroup.plm,v $
# Revision 1.6  2009/10/30 17:05:41  koczan
# typo
#
# Revision 1.5  2002/12/30 22:05:28  thomas
# fix log->error calls
#
# Revision 1.4  2002/09/24 18:45:27  thomas
# fixes for scheduler checks
#
# Revision 1.3  2002/09/23 22:03:00  thomas
# 0.3.2 to production
#
# Revision 1.2  2002/07/08 15:56:35  thomas
# 0.2.3 release
#
# Revision 1.1.1.1  2002/05/21 14:13:33  thomas
# sushi - backup to disk
#

package Sushi::Command::ScheduleGroup;

use strict;
use Time::localtime;

###############################################################################

sub main {

  my $class = shift;
  my $grouptoschedule = shift @ARGV;

  my $groupname = &Sushi::Misc::dailyGroup;

  # Schedule all the backup types
  foreach (@$::groups) {
    if (defined $grouptoschedule) {
      ($_ eq $grouptoschedule) or next;
    }

    my $group = "Sushi::Group::$_"->new (
					 schedule_group => $groupname
					);
    if (!defined $group) {
      $main::log->Error ("Failed to create a scheduler for $_\n");
      return 0;
    }
    my $res;
    if (!($res = $group->getAtoms)) {
      $main::log->error ("Failed to get atoms for $_\n");
      return;
    }
    if (!($res = $group->scheduleGroup)) {
      $main::log->error ("Failed to schedule atoms for $_\n");
      return;
    }
    if (!($res = $group->writeAtoms)) {
      $main::log->error ("Failed to write atoms for $_\n");
      return;
    }
  }
}

###############################################################################

sub shortHelp {
  return "Create today's daily group";
}

###############################################################################

sub help {

  my $help = <<__Eof__

schedulegroup [atom type to schedule]

Create today's daily group.  If an atom type is specified, only that
type will be scheduled.

__Eof__
;
}

###############################################################################

1;
