### ### Copyright 2000-2007 University of Illinois Board of Trustees ### All rights reserved. ### ### PSGConf::Action::RemoveCrontab - remove action type for psgconf ### ### Campus Information Technologies and Educational Services ### University of Illinois at Urbana-Champaign ### package PSGConf::Action::RemoveCrontab; use strict; use PSGConf::Action; use PSGConf::Util; our @ISA = qw(PSGConf::Action); ############################################################################### ### check method ############################################################################### sub check { my ($self) = @_; if (-e $self->{fullpath} || -l $self->{fullpath}) { $self->{changed} = 1; return 1; } return 0; } ############################################################################### ### diff method ############################################################################### sub diff { my ($self) = @_; print "###############################################################################\n"; print "### DIFF FOR $self->{name}\n"; print "###############################################################################\n"; print "- REMOVE CRONTAB: $self->{name}\n\n"; } ############################################################################### ### do() method ############################################################################### sub do { my ($self, $psgconf) = @_; my ($cmd, $rc); $cmd .= "su $self->{name} -c \"" if ($self->{name} ne 'root'); $cmd .= 'crontab -r" > /dev/null 2>&1'; ### ### If the crontab -r command fails, then assume that cron ### actually does not know about the file and just remove ### it via unlink ### if (($rc=PSGConf::Util::RunCommand($cmd, 1))) { $rc=unlink ($self->{fullpath}) if ( -f $self->{fullpath} ); } return !$rc; } ############################################################################### ### documentation ############################################################################### 1; __END__ =head1 NAME PSGConf::Action::RemoveCrontab - crontab removal action class for PSGConf =head1 SYNOPSIS use PSGConf::Action::RemoveCrontab; $psgconf->register_actions( PSGConf::Action::RemoveCrontab->new( 'name' => '/path/to/crontab', ... ), ... ); =head1 DESCRIPTION The B module provides a B action class for removing an entry from the filesystem (regular file, directory, symlink, etc). The B class is derived from the B class, but it defines/overrides the following methods: =over 4 =item check() Checks to see if the file currently exists. =item diff() Prints a message indicating that the file needs to be removed. =item do() Removes the crontab entry. =back =head1 SEE ALSO L Ccrontab(1)E> L L L =cut