1#
2# (c) Jan Gehring <jan.gehring@gmail.com>
3#
4# vim: set ts=2 sw=2 tw=0:
5# vim: set expandtab:
6
7package Rex::Cron;
8
9use 5.010001;
10use strict;
11use warnings;
12
13our $VERSION = '1.13.4'; # VERSION
14
15use Rex::Commands::Gather;
16use List::Util qw'first';
17
18sub create {
19  my ($class) = @_;
20
21  my $type = "Linux";
22  if ( operating_system_is("SunOS") ) {
23    $type = "SunOS";
24  }
25
26  my $exec = Rex::Interface::Exec->create;
27
28  # here we're using first and not any, because in older perl versions
29  # there is no any() function in List::Util.
30  if ( operating_system_is( "FreeBSD", "OpenBSD", "NetBSD" )
31    && first { $exec->shell->name eq $_ } (qw/csh ksh tcsh/) )
32  {
33    $type = "FreeBSD";
34  }
35
36  my $klass = "Rex::Cron::$type";
37  eval "use $klass;";
38  if ($@) {
39    die("Error creating cron class: $klass\n$@");
40  }
41
42  return $klass->new;
43}
44
451;
46